struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Moseley <>
Subject Re: modifying the mapping input path during validation
Date Tue, 17 Dec 2002 18:46:37 GMT
Erik Hatcher wrote:
> I'm not following why you need to do this in the form bean rather than 
> just dealing with this in the action.  The action class is designed for 
> flexible routing out of it, so the capability is already there as you've 
> already mentioned using.

because the form fails validation, the RequestProcessor immediately 
forwards to the form's input page instead of handing off to the action 
associated with the form. so no, i can't do it in that action.

there is a "prepare" action for the input page as well:

   flow a: EditFormPrepareAction ---> Edit.jsp
   flow b: Edit.jsp ---> EditForm ---> EditAction

during flow b, if EditForm fails to validate, the request is forwarded 
back to flow a.

i expected that, after EditForm fails to validate, the form object 
passed into EditFormPrepareAction would be the same instance of EditForm 
that failed validation (where the required bit of data is available as 
an attribute).

in fact, the form object that's passed into the prepare action is null. 
i don't know why.

> Sometimes we "hack" a request parameter in to the forward from the 
> action by creating a new ActionForward based on the path of an existing 
> one...
>     return new ActionForward(mapping.findForward("success").getPath() + 
> "?id=" + id);
> (hopefully no typos there, but you get the idea).  No need to do session 
> scope stuff to make this happen.

yep, when i need to change a forward path inside an action, i do almost 
exactly this. it may be a hack, but i don't see any way around it.

> So what you're trying to do is already possible, although even the above 
> is a 'hack' I think and while it comes in handy in a pinch it'd be nicer 
> to craft it so that the next page or action can deal with a request 
> scoped attribute rather than a parameter.

i apologize for being imprecise in the original post. the prepare action 
is the component that requires the request parameter. it then sets a 
request attribute, which is used by the jsp. so i'm already following 
that bit of advice :)

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message