You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Tom Butler <to...@adelphia.net> on 2006/01/27 05:24:45 UTC

form fields clearing on validation errors

I am using validators within my form - when a validation error occurs, all
the form fields are cleared when the validation error messages are
displayed?  If there are not validation errors, everything is passed to the
bean correctly.  The issue only occurs when there is a validation error and
the original form is re-rendered with all the previously inputted fields
cleared (want fields to remain intact so user can correct)?  This is my
first validator, however, I must be missing something obvious?

 

Example validators:

 

<h:inputText id="lastname" value="#{enrollispbean.lastname}"
required="true">

 

and, 

 

<h:inputText id="email1" value="#{enrollispbean.email1}" required="true">   

<t:validateEmail /> 

</h:inputText>

 

enrollispbean is a managed bean:

 

<managed-bean> 

<managed-bean-name>enrollispbean</managed-bean-name>

<managed-bean-class>com.domain.EnrollIspBean</managed-bean-class> 

<managed-bean-scope>request</managed-bean-scope> 

</managed-bean>

 

 


RE: form fields clearing on validation errors

Posted by Tom Butler <to...@adelphia.net>.
Ps I see that validation steps occur before the update model values (assume
update model values invokes setters to updated properties in the backing
bean), so if a validation error occurs, the model (backing bean) is not
updated.  Based on this, I assume on the post-back that the form in the .jsf
form calls the getters in the backing bean which return null values (values
not yet set.)  Is this interpretation correct?  If so, what techniques can I
use to maintain the data inputted by the user without have the form fields
clearing?

 

JSF lifecycle diagram of conversion and validation phases

 

 

  _____  

From: Tom Butler [mailto:tom.butler@adelphia.net] 
Sent: Thursday, January 26, 2006 11:25 PM
To: 'MyFaces Discussion'
Subject: form fields clearing on validation errors

 

I am using validators within my form - when a validation error occurs, all
the form fields are cleared when the validation error messages are
displayed?  If there are not validation errors, everything is passed to the
bean correctly.  The issue only occurs when there is a validation error and
the original form is re-rendered with all the previously inputted fields
cleared (want fields to remain intact so user can correct)?  This is my
first validator, however, I must be missing something obvious?

 

Example validators:

 

<h:inputText id="lastname" value="#{enrollispbean.lastname}"
required="true">

 

and, 

 

<h:inputText id="email1" value="#{enrollispbean.email1}" required="true">   

<t:validateEmail /> 

</h:inputText>

 

enrollispbean is a managed bean:

 

<managed-bean> 

<managed-bean-name>enrollispbean</managed-bean-name>

<managed-bean-class>com.domain.EnrollIspBean</managed-bean-class> 

<managed-bean-scope>request</managed-bean-scope> 

</managed-bean>