You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael <mi...@comcast.net> on 2002/07/05 16:46:32 UTC

Recovering from form validation errors

I am validating fields in my ActionForm using the validate() method. Upon finding errors, I return a populated ActionErrors object. When the thread of control is passed back to the input JSP, a List of users used to populate an html:select is no longer in the request object (since this is a new request at this point). Since I never get to my Action class, I don't get the List populated.

I really don't want to put the List of users on the session if I can avoid it, since the List really should be re-built with each request.

Is there a "best-practices" way to deal with this problem?

Thanks

Re: Recovering from form validation errors

Posted by Michael <mi...@comcast.net>.
Thanks for the reply. I had just moved my validation code out of the Action
to clean it up a bit. I hadn't thought of calling validate() from the
action, though.

----- Original Message -----
From: Joe Germuska <Jo...@Germuska.com>
To: Struts Users Mailing List <st...@jakarta.apache.org>
Sent: Friday, July 05, 2002 11:40 AM
Subject: Re: Recovering from form validation errors


> At 10:46 AM -0400 2002/07/05, Michael wrote:
> >I am validating fields in my ActionForm using the validate() method.
> >Upon finding errors, I return a populated ActionErrors object. When
> >the thread of control is passed back to the input JSP, a List of
> >users used to populate an html:select is no longer in the request
> >object (since this is a new request at this point). Since I never
> >get to my Action class, I don't get the List populated.
> >
> >I really don't want to put the List of users on the session if I can
> >avoid it, since the List really should be re-built with each request.
> >
> >Is there a "best-practices" way to deal with this problem?
>
> set validate="false" in struts-config and do that validation in your
> action instead.  You can still call the validate method on the form,
> of course, and then you have the opportunity to repopulate the
> request  with that list.
>
> There's no other work around that I'm aware of.   Your situation
> falls outside of what the pre-action validation is supposed to handle.
>
> Joe
>
> --
> --
> * Joe Germuska    { joe@germuska.com }
> "It's pitiful, sometimes, if they've got it bad. Their eyes get
> glazed, they go white, their hands tremble.... As I watch them I
> often feel that a dope peddler is a gentleman compared with the man
> who sells records."
> --Sam Goody, 1956
> tune in posse radio: <http://www.live365.com/stations/289268>
>
> --
> 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: Recovering from form validation errors

Posted by Joe Germuska <Jo...@Germuska.com>.
At 10:46 AM -0400 2002/07/05, Michael wrote:
>I am validating fields in my ActionForm using the validate() method. 
>Upon finding errors, I return a populated ActionErrors object. When 
>the thread of control is passed back to the input JSP, a List of 
>users used to populate an html:select is no longer in the request 
>object (since this is a new request at this point). Since I never 
>get to my Action class, I don't get the List populated.
>
>I really don't want to put the List of users on the session if I can 
>avoid it, since the List really should be re-built with each request.
>
>Is there a "best-practices" way to deal with this problem?

set validate="false" in struts-config and do that validation in your 
action instead.  You can still call the validate method on the form, 
of course, and then you have the opportunity to repopulate the 
request  with that list.

There's no other work around that I'm aware of.   Your situation 
falls outside of what the pre-action validation is supposed to handle.

Joe

-- 
--
* Joe Germuska    { joe@germuska.com }
"It's pitiful, sometimes, if they've got it bad. Their eyes get 
glazed, they go white, their hands tremble.... As I watch them I 
often feel that a dope peddler is a gentleman compared with the man 
who sells records."
	--Sam Goody, 1956
tune in posse radio: <http://www.live365.com/stations/289268>

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