You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jon Burford <jb...@xsilogy.com> on 2002/02/01 23:48:21 UTC

form validation failure and state

I've got a form with text fields and drop down list boxes which is fully
populated by an init action before the form is displayed.  The user can then
make changes and submit the form, which in turn calls the validate function
on my form object.  If I detect invalid input, I return one or more errors
from my validate function and the errors are displayed by struts along with
the form they were changing.  The problem I am having is that struts seems
to remember and populate all the text fields correctly when it redisplays
the form with the errors, but the drop downs are empty.  I know of a couple
ways I could repopulate the drop downs, but I was wondering why struts
remembers what's in the text fields, but not in the drop downs?  Am I
missing something, or is this how it works?


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: form validation failure and state

Posted by Robert Scaduto <rs...@douwantit.com>.
The collections that are used in the drop-down's.  Where are they created?
If they are created in your init method and stored in request scope. Then
they won't be there for the form unless they are created again when the
validation fails.  You can store these collections in application scope so
that they will always be available to the options tag.  Another solution
would be to make the input attribute in your action mapping the action that
creates the collections.

-----Original Message-----
From: Jon Burford [mailto:jburford@xsilogy.com]
Sent: Friday, February 01, 2002 5:48 PM
To: struts-user@jakarta.apache.org
Subject: form validation failure and state


I've got a form with text fields and drop down list boxes which is fully
populated by an init action before the form is displayed.  The user can then
make changes and submit the form, which in turn calls the validate function
on my form object.  If I detect invalid input, I return one or more errors
from my validate function and the errors are displayed by struts along with
the form they were changing.  The problem I am having is that struts seems
to remember and populate all the text fields correctly when it redisplays
the form with the errors, but the drop downs are empty.  I know of a couple
ways I could repopulate the drop downs, but I was wondering why struts
remembers what's in the text fields, but not in the drop downs?  Am I
missing something, or is this how it works?


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: form validation failure and state

Posted by Robert Scaduto <rs...@douwantit.com>.
In my experience, struts will repopulate all fields including any drop-down
menus but only if they are implemented using the <html:select> tag.  If you
are generating the drop-downs without the help of the struts taglib then it
cannot repopulate the form.

A) Are you using the struts tags for the drop-downs?
B) If so does the validate function wipe out the values that would be
displayed by the drop down?

-----Original Message-----
From: Jon Burford [mailto:jburford@xsilogy.com]
Sent: Friday, February 01, 2002 5:48 PM
To: struts-user@jakarta.apache.org
Subject: form validation failure and state


I've got a form with text fields and drop down list boxes which is fully
populated by an init action before the form is displayed.  The user can then
make changes and submit the form, which in turn calls the validate function
on my form object.  If I detect invalid input, I return one or more errors
from my validate function and the errors are displayed by struts along with
the form they were changing.  The problem I am having is that struts seems
to remember and populate all the text fields correctly when it redisplays
the form with the errors, but the drop downs are empty.  I know of a couple
ways I could repopulate the drop downs, but I was wondering why struts
remembers what's in the text fields, but not in the drop downs?  Am I
missing something, or is this how it works?


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>