Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8888919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:08:10+00:00 2026-06-14T22:08:10+00:00

I am involved in a JSF project and I am trying to make a

  • 0

I am involved in a JSF project and I am trying to make a view for a shopping cart. a user’s cart can contain tickets which are stored in a hash map (key = id, value = quantity) in the cartBean. In the cart.xhtml I try to output the tickets, here you can see the code:

<h:form>    
        <c:forEach var="tickets" items="#{cartBean.showTickets()}">

            <hr/>
            <div class="eight columns">
                <div class="two column count">
                    <h:outputText style="font-size:30px;" value="#{tickets.value}"/>
                </div>
                <div class="two columns eventimg">
                    <a href="event.xhtml"><img src="img/dummy/event2.jpg" /></a>
                </div>
                <div class="six columns eventinfo">
                    <h4><a href="event.xhtml">Party Hard! </a></h4>
                    <p>05. Nov 2012</p>
                    </div>
                <div class="two columns price">
                    <font style="font-size:30px;">35 &euro;</font>
                </div>
                <div class="eight columns">
                    <h:outputText value="#{tickets.key}"  escape="false"/>
                    <h:commandButton value="x" action="#{cartBean.removeFromCart(tickets.key)}"/>

                </div>
            </div>

        </c:forEach>
        </h:form>

That works fine until I try to delete one ticket from the cart. If I have two different id keys they are displayed correctly in the cart. when I try to delete the ticket with id 1 only the ticket with id 2 remains in the cart which is correct. But when I delete id 2 at first it displays ticket two in the cart although it has been deleted from the hash map. After refreshing the site it displays correctly ticket with id 1, but what is going wrong there?

Please help me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:08:11+00:00Added an answer on June 14, 2026 at 10:08 pm

    I have finally found a solution after searching intensively the web. enter link description here here you can see some problems of Problem 1 is simmilar to mine. The solution is to use therefore you have to write the map onto a Arraylist and then iterate the list. here the code how it’s done:

    public List<Entry<String, Integer>> getTicketsList() {
            return new ArrayList(tickets.entrySet());}
    

    btw. tickets is my hash map in your html file you have to use <ui:repeat value="#{cartBean.ticketsList}" var="tickets"> cartBean is my bean and ticketsList my arrayList. hope you it helps somebody, happy fixing B)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am involved in a personal project which will require pretty extensive knowledge of
I'm involved in a project which is able to connect to different hardware devices
I am involved in creating a project which has around 60 packages and more
I am involved in a project which is meant to eventually become open-source and
I'm developing a java EE web app using JSF with a shopping cart style
Technologies involved : ASP.NET Web-forms Javascript (jQuery for instance) Case To make it clearer
I am involved in the development of a WPF Prism application which uses the
I'm involved in a project where a team of developers is building a very
I have a fairly involved managed data model which has a central object with
I have been involved in building a custum QGIS application in which live data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.