• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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

 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
*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?
 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, how do you use the setSubmittedValue( "xxx" ); to take care of the HtmlInputText? Would you mind showing your code?
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!

 
Live ordinary life in an extraordinary way. Details embedded in this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic