You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jim Reynolds <ji...@gmail.com> on 2005/11/01 20:28:18 UTC

Beans in Request and Validation Question

I have a question about using request scoped beans and validation with an
ActionForm.
 Here is a example:
In a certain action, I go and create a Collection of objects for a select
list. I put the Collection into the request, and forward to a JSP page, and
I show the list.
 From the JSP page, the user is required to select an item from the select
list, then hit submit. Here is where the issues come into play. From that
action I am validating the form in the bean. If the user forgot to select an
item, I create ActionError, stuff it into the ActionErrors object and send
back to my input which is the original jsp page with the select list, the
one they just submitted from.
 But of course, when it goes back to the jsp page, there is no collection to
build the select list, and I get errors. Up to now, I have been putting
those types of list into the session, but really feel there should be a
better way. Can anyone possibly guide me here to a better way to handle
this?

Re: Beans in Request and Validation Question

Posted by Hubert Rabago <hr...@gmail.com>.
The way I dealt with this was to point my "input" attribute to a setup
Action which would put the needed collection into request scope for
me.  But that's just one approach.  Another is to handle validation
yourself (which really is very easy).  This is the approach
recommended by http://www.reumann.net/struts/articles/request_lists.jsp.
 That page actually lists a few approaches, though I would shorten my
list to the last three (plus the setup input Action).

Hubert

On 11/1/05, Jim Reynolds <ji...@gmail.com> wrote:
> I have a question about using request scoped beans and validation with an
> ActionForm.
>  Here is a example:
> In a certain action, I go and create a Collection of objects for a select
> list. I put the Collection into the request, and forward to a JSP page, and
> I show the list.
>  From the JSP page, the user is required to select an item from the select
> list, then hit submit. Here is where the issues come into play. From that
> action I am validating the form in the bean. If the user forgot to select an
> item, I create ActionError, stuff it into the ActionErrors object and send
> back to my input which is the original jsp page with the select list, the
> one they just submitted from.
>  But of course, when it goes back to the jsp page, there is no collection to
> build the select list, and I get errors. Up to now, I have been putting
> those types of list into the session, but really feel there should be a
> better way. Can anyone possibly guide me here to a better way to handle
> this?
>
>

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