struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Taylor" <rtay...@mulework.com>
Subject RE: empty HTML-Form after validator fail
Date Tue, 06 May 2003 15:44:15 GMT
Christian,

since your form is populated by a bean in request scope. 
That bean (and its accompanying data) is gone after you submit
the form for processing. When validation fails, Struts will forward
to the url defined in the "input" attribute of the action element in
struts-config file. If that value is the actual page, then the request
is forwarded back to the page where the jsp:userBean attempts to find
the bean in request scope. Since the bean is not there, it creates a new
bean with empty data. So your form data (which exists in the forwarded
request) is being overwritten with empty data in the UserData bean.

I might suggest that you have a set up action that populates the form
before displaying the page. Have your set up action populate the form
with UserData (use BeanUtils). Then if validation fails, the request is
forwarded back to the page where user input will be re-rendered as it
was entered.

hth,

robert

> -----Original Message-----
> From: Christian Traber [mailto:christian@traber-net.de]
> Sent: Tuesday, May 06, 2003 11:07 AM
> To: Struts Users Mailing List
> Subject: empty HTML-Form after validator fail
> 
> 
> Hi,
> 
> I have a ValidatorForm with simple validation rules to check if fields 
> are empty...
> If one validation rule fails, back at my jsp form all fields are empty!
> How can I rescue the already filled out  field values?
> 
> I fill the from from another Bean in request scope (not the 
> ValidatorForm!):
> <jsp:useBean id="UserData2Edit" class="de.traber.UserData" 
> scope="request"/>
> ...
>  <html:form action="/UserData.do" method="POST">
> ...
>     <html:text styleClass="entry" name="UserData2Edit" 
> property="username"/>
> ...
> ...
> 
> Is there the problem, howelse can I fill the form for editing?
> 
> Thanks and regards,
> Christian
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message