Two Laptop Bag*
The moose likes JSF and the fly likes InputText in DataTable does not store value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "InputText in DataTable does not store value" Watch "InputText in DataTable does not store value" New topic
Author

InputText in DataTable does not store value

Klaus Schuster
Ranch Hand

Joined: Feb 10, 2009
Posts: 30
I have the problem, that I am using a dataTable from tomahawk for iterating an List:





The update I made in the inputtext is not represented in the List.

What is the problem, when I save with the button, that my object model is not filled (by using setters) ?
In Debug mode I can see that a new instance is using my setters.
Therefore the different instances causes the problem, that I have to use the binding.
Any explaination for me?

Because I didn't find an answer for my question, I tried to use a binding as mentioned above.
But there is no updated data in the List. Can anyone help me?
Thanks,
Klaus

PS: Related Article: Same Problem in another code ranch article
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You need to access the 'populatedFoos' property in the action method. The updated model values are in there. You should also rather populate the list in the constructor of the backing bean. A getter can be called more than once in bean's life and is in fact solely intented to return a bean property, not to do some (non-lazy) loading actions. After all you need to ensure that the same list is constructed during the apply request values phase of the subsequent request as it was during the render response phase of the initial request. If the bean is request scoped (good choice) and you want to prevent the datamodel being loaded everytime, you can use preserveDataModel attribute of the t:dataTable for this.

You may find the examples in this article useful as well: http://balusc.blogspot.com/2006/06/using-datatables.html
Klaus Schuster
Ranch Hand

Joined: Feb 10, 2009
Posts: 30
My Code now looks like this:

I am using the session scope, and when I check the 'popultedFoos' Variable, no update is made after clicking the save button.
In the updatedFooList there is also the old value...
I don't know where the problem is located.
Klaus Schuster
Ranch Hand

Joined: Feb 10, 2009
Posts: 30
ok, everything works with an List. I thought i am using a list for my value in the datatable.
But it was a map. (values of map) which has shown me the data, but couldn't use any setter at the storing process...
 
Don't get me started about those stupid light bulbs.
 
subject: InputText in DataTable does not store value