This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
How can I refresh(reset) inputText in a dataTable?
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
I'm having what must be a simple and common problem, but nothing I've tried has solved it. I want to be able to refresh (reset) the inputText field values in a dataTable.
I have a dataTable that holds required inputText components. I want to have a "cancel" button which would abandon any edits on these components and refresh (reset) them with their backing values, as well as removing the last row from the table (used to enter a new record). Because the inputText components are required, I made the cancel button immediate. I don't know what code I can put in the button's actionListener. Right now, the displayed values survive the round trip to the server and back to the browser, but I want them to be reset to their backing values.
Here is the page, and the backing bean of a test example:
If it makes a difference, my implementation of JSF is MyFaces. Thanks! [ October 26, 2005: Message edited by: Jeff Albrechtsen ]
There is no emoticon for what I am feeling!
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
I think I found a solution to my own problem: add the following to my immediate, command button cancel:
o~n~c~l~i~c~k="reset()"
(The ~'s are in there because I can seem to submit a reply with that attribute.) That's the form's javascipt method reset. This seems cheeky to me -- I thought there would be a server-side, JSF solution. Anyone?
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
*bump*
I'm not happy with having javascript reseting fields in a table before submitting: there's a noticable screen flash, and I'd like a server-side solution anyway.
Question: UIInput has methods getSubmittedValue and setSubmittedValue, so I can use these to ignore or clear submitted values when I press an immediate command button. This takes care of subclasses like HtmlInputText but not for data tables. Is there a way to manipulate all the submitted values of a data table?
Daniel Gee
Ranch Hand
Joined: Aug 29, 2003
Posts: 202
posted
0
Hi, how do you use the setSubmittedValue( "xxx" ); to take care of the HtmlInputText? Would you mind showing your code?
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted
0
Here's how to do it for a single field, where it works great. I haven't been able to get it to work for fields in a data table.
Anybody? [ October 31, 2005: Message edited by: Jeff Albrechtsen ]
Simon Prinzleve
Greenhorn
Joined: Mar 03, 2009
Posts: 3
posted
0
Hi Folks,
to refresh the bean serverside simply reset the attributes of the bean.