Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DataTable datas are not actual

 
Karoly Guba
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I work on a small project now. This software registers a client who is enter into the office (datetime, name, id, destination). The registration process is OK, but I have problems with reports showed in dataTable.
How the report works:

When I click on report, the browser shows me report about how many clients have each official today(you can see it on the following picture):



When I click on one official, the browser shows me another page with the list of clients visited that official (you can see it on the following pic):



Lets get back to the first report (how many clients have each official today). Of course there is a possibility to change the date range. Lets say that I want to see how many clients have each official from 6 of december to 9 of december. For this I get the following:




Everything is OK till this point, but if I click on one official I get the list of clients visited another official. What I noticed is that when I click on an official I get the client list of another official who was on this position later when I started report (how many clients have each official TODAY). For example if I click on a "Томашев Рожа" I get clients of "Ђенге Терез".

Here is the code of report JSF (how many clients have each official today):
Sumarno.xhtml



Code of client list JSF:
klienti.xhtml



Code of managed bean destinationManager:



 
Brendan Healey
Ranch Hand
Posts: 218
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This is a very well described question. I think you need to use f:setPropertyActionListener as a child tag of
the h:commandLink to set a backing bean value (target=) to the value of the table row (source="#{var}").
 
Karoly Guba
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please explain how to do this through an example!

Thank You!
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "value=" of a dataTable should NOT be a method call or reference to a simple collection object. It should reference a backing bean property whose "get" method returns a JSF DataModel object.

The JSF DataModel interface is implemented by several different stock JSF classes, although the one I use most often is the ListDataModel. It wraps a Java List and provides the cursor services needed for JSF to be able to tell which row of the table you are interacting with.

One important thing to know about dataTables and DataModels. A class containing a DataModel has to be of at least View scope (Session scope, if JSF1.x). Request scope won't work, because the original DataModel object is destroyed and re-created, losing the cursor position.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic