You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Brown, James" <ja...@ca.unisys.com> on 2003/12/12 18:47:00 UTC

Redisplaying form after validation failure

(Possibly a misunderstanding of scope and ActionForm functionality but ...)

We have a simple application that uses struts with tiles.  We are using an ACtionForm to validate the user's input and redisplay the page with ActionErrors returned by the form beans validate(...) method.  This works only if the form's scope is set to "session" within the struts-config.xml; if it set to "request" all entries on the form are blank.

I have done some digging and have removed all code in the reset method of the form bean, but that does not seem to do the trick.

Suggestions?

                                  Cheers,
                                  James

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


Re: Redisplaying form after validation failure

Posted by Joe Germuska <Jo...@Germuska.com>.
At 12:47 PM -0500 12/12/03, Brown, James wrote:
>(Possibly a misunderstanding of scope and ActionForm functionality but ...)
>
>We have a simple application that uses struts with tiles.  We are 
>using an ACtionForm to validate the user's input and redisplay the 
>page with ActionErrors returned by the form beans validate(...) 
>method.  This works only if the form's scope is set to "session" 
>within the struts-config.xml; if it set to "request" all entries on 
>the form are blank.
>
>I have done some digging and have removed all code in the reset 
>method of the form bean, but that does not seem to do the trick.

It seems likely that somehow your process is requiring two HTTP 
requests.  You shouldn't have to have a session-scoped form to use 
this functionality.  The normal request process (details in 
org.apache.struts.action.RequestProcessor) involves recognizing that 
an action mapping has a form bean associated with it, then if it 
does, retrieving or instantiating it, populating it, validating it 
(if the mapping is so marked) and then passing on to the Action class 
(if the form is valid) or the input forward (specified in the 
mapping's "input" attribute) if the form's validate returns a 
non-empty ActionErrors object.  But if the input forward is a JSP, 
then when control is forwarded to it the same request object should 
be in scope that was used originally, so a request scoped form bean 
should be available.

You might crank up the logging to see more clearly what's going on. 
Can you send your <action> mapping from struts-config ?

Joe
-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
  "We want beef in dessert if we can get it there."
   -- Betty Hogan, Director of New Product Development, National 
Cattlemen's Beef Association


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