You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ian Joyce <Ij...@aafp.org> on 2004/02/01 02:10:15 UTC

Re: request attributes and failed validation

This was exactly what I was looking for. Thanks.  

If anyone is interested in details I'd be happy to share...

>>> jakartauser@yahoo.com 01/31/04 03:59 AM >>>
This is the reasons I sometimes have an action in my "input" action
attribute.  What I mean is:

<action path="/showForm.do"
    type="com.actions.ShowFormAction">
    <forward name="form" path="myForm.jsp"/>
</action>

<action path="/submitForm.do"
    type="com.actions.SubmitFormAction"
    name="myFormBean"
    input="/showForm.do">
    ...
</action>

I sometimes (often?) use the Action that generated the form as my input
because my form has controls that need to be initialized (like your drop
downs).
Using an Action as "input" sometimes takes more work.  Your action should
know that it's only redisplaying a form and not reset all form values (or
else the user will have to reinput everything instead of just correct the
validation error).  
You *can* avoid this by placing your list in session scope, like Mike
suggested.  If it's used often enough, you can put it in application scope,
though you'd have to define when "often enough" is justified.  
Try the session scope approach first.

hth,
Hubert

--- Ian Joyce <Ij...@aafp.org> wrote:
> It's not slow, the lists are created from data from a database.  I am
> assuming when you say 'do it again' you mean add these Lists to the
> request.  Where should this be done at?
> 
> >>> mike@michaelmcgrady.com 01/31/04 01:48 AM >>>
> One way is to put them temporarily in the session.  But, why not just do it
> 
> again?  Is it too slow?
> 
> At 11:28 PM 1/30/2004, you wrote:
> >In my Action I am populating an ActionForm with data from a database.  I 
> >am also setting some additional request attributes with Lists of 
> >beans.  The purpose of these Lists are to create various drop down boxes 
> >in the form.  This works well, however when the form is submitted and 
> >validation fails these attributes are no longer in the request and the 
> >drop down boxes aren't created.
> >
> >What is the best way to have these Lists avaiable when the validation
> fails?


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