Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Data table displaying same item multiple times-not supposed to

 
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
 
Saloon Keeper
Posts: 22511
151
Android Eclipse IDE Tomcat Server Redhat Java 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
Saloon Keeper
Posts: 22511
151
Android Eclipse IDE Tomcat Server Redhat Java 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".
 
Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic