• Post Reply Bookmark Topic Watch Topic
  • New Topic

Data table displaying same item multiple times-not supposed to

 
Raymond Self
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I currently have a datatable on the bookingList.xhtml which is supposed to list all bookings made, if first booking petName is spot it displays the booking details perfect but if another booking is made (for example one with petName fluffy) then it displays 2 lines with fluffys details and spots details are not displayed, it carries on that if a third booking is made then the 3rd bookings details are displayed 3 times and neither spot or fluffys booking details are displayed, can anybody help on this I would really appreciate it thanks I have attached some code below if you need anymore just let me know thanks

bookingList.xhtml code


Booking.java code


And this is the booking.xhtml page where you make the booking
 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And a very fine welcome to yourself Raymond Self! Welcome to the JavaRanch!

We always recommend paring down your examples as small as you can before posting them. One of the problems with getting free assistance is that if the examples are too long and complicated, no one will volunteer to wade through them!

You're using an application-scope backing bean. Usually you wouldn't want to do that, because the same object is shared between all users and unless you take steps to make access thread-safe, multiple users can really scramble things.

However, what seems to be the real problem is that your datatable is attempting to use the same object ("booking") as both the backing bean that holds the table datamodel AND as the cursor/row model object (var) within that table.

So I imagine that JSF is probably getting pretty confused.
 
Raymond Self
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi thanks for the welcome sorry for the long code what do you mean by paring down? And have been thinking there should be a bookingData bean also as I have a customer and customerBean and the customerList displays perfectly but the booking one was setup in one file so am not sure what to copy into a new bookingData bean out of the booking bean, thanks for your help
 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a Wiki entry on keeping your examples simple, but basically, all we're asking is that you try and reduce the actual amount of stuff you post to just the minimum required to present the problem. In practical terms, once an example gets too big to fit on the screen, eyeballs glaze over. So, for example, your webapp may contain a set of 132 check boxes, but for our sakes, if it still mis-behaves when you have only 2, give us an example with just 2 check boxes. That way the forest doesn't obscure the trees.

What beans you have and how you partition stuff is mostly just what works for you. There's no requirement for a 1-1 correspondence between Model and View objects.

But, as I said, it looks like you were using the same name ("booking") to refer to 2 very different objects.

I usually just name my table cursor (var=) something imaginative like "row" or "item".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!