aspose file tools*
The moose likes JSF and the fly likes How can I refresh(reset) inputText in a dataTable? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "How can I refresh(reset) inputText in a dataTable?" Watch "How can I refresh(reset) inputText in a dataTable?" New topic
Author

How can I refresh(reset) inputText in a dataTable?

Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
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
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
*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
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
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
Hi Folks,

to refresh the bean serverside simply reset the attributes of the bean.

All details are described here:
http://liferay-portlets.blogspot.com/2009/05/jsf-refresh-bean-and-get-different.html

Hope it helps!


Check http://liferay-portlets.blogspot.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can I refresh(reset) inputText in a dataTable?
 
Similar Threads
Add component on a button click
Bean request Scope won't Call method
select a row
Unable to call Action Methof
Clearing forms