You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Phanidhar Adusumilli <ph...@gmail.com> on 2006/01/03 16:08:58 UTC
Problem clearing form fields.
I have a form with various fields used as search criteria. All these fields
are mapped to backing beans properties. This form contains search and clear
buttons. Clear button is mapped to an action listener and its immediate
attribute is set to TRUE. The action listener resets all the backing beans
properties to default values. If I enter some criteria and chose to clear
the form (by clicking clear button), The form still shows the submitted
values. It is not showing the values of the backing bean.
After debugging I found that in RenderUtils class, the method getStringValue
returns the submitted value if it is not null.
In validation phase, the submitted value is made null only if the
validations are successfull. Since the clear action is immediate the
validations were not performed submitted value is not cleared and hence the
page shows the submitted values even though th ebacking beans properties are
reset.
Has any one run into this issue?
I found a posting at
http://mail-archives.apache.org/mod_mbox/myfaces-users/200504.mbox/%3C42725985.8040700@marathon-man.com%3E
But the fix is not done.
Re: Problem clearing form fields.
Posted by Mike Kienenberger <mk...@gmail.com>.
If you're going to clear form values from the server-side code, then
you need to manually go through in your action method and set the
submitted value for each component to null to force the values to be
retrieved from the backing beans.
I'd recommend explicitly binding each component to clear to your
backing bean and explicitly clearing each one.
However you can also "walk the form" and clear everything you find.
SubmittedValueCollectorWalker.java and its superclass, ComponentFormWalker
.java, at the following url do something similar (they collect
submitted values and restore them later). However, it's a component
and not a backing bean, so you'll have to hook up backing bean code
slightly differently.
http://cvs.sourceforge.net/viewcvs.py/jsf-comp/OptionalValidator/src/net/sf/jsfcomp/validator/#dirlist
On 1/3/06, Phanidhar Adusumilli <ph...@gmail.com> wrote:
> I have a form with various fields used as search criteria. All these fields
> are mapped to backing beans properties. This form contains search and clear
> buttons. Clear button is mapped to an action listener and its immediate
> attribute is set to TRUE. The action listener resets all the backing beans
> properties to default values. If I enter some criteria and chose to clear
> the form (by clicking clear button), The form still shows the submitted
> values. It is not showing the values of the backing bean.
>
> After debugging I found that in RenderUtils class, the method getStringValue
> returns the submitted value if it is not null.
> In validation phase, the submitted value is made null only if the
> validations are successfull. Since the clear action is immediate the
> validations were not performed submitted value is not cleared and hence the
> page shows the submitted values even though th ebacking beans properties are
> reset.
>
> Has any one run into this issue?
>
> I found a posting at
>
> http://mail-archives.apache.org/mod_mbox/myfaces-users/200504.mbox/%3C42725985.8040700@marathon-man.com%3E
>
> But the fix is not done.