You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by gd...@cmhc-schl.gc.ca on 2004/07/06 19:39:17 UTC
Request bean is lost
Greetings,
I have an action Page.do that gets 3 lists from a database.
It then places the lists inside a bean which is set in the request.
The Page.jsp iterates thru the bean to display the data.
The form is posted to the PageSubmit.do.
But before the PageForm.validate() is executed.
Assume that an error is found...
The response is returned
And this is where my bean is lost.
Why?
I do not want to store thr bean in the HTTP Session.
TIA,
Glenn.
Re: Request bean is lost
Posted by Bill Siggelkow <bi...@bellsouth.net>.
Try specifying
input="/Page.do"
instead of
input="/Page.jsp"
gdeschen@cmhc-schl.gc.ca wrote:
> Greetings,
>
> I have an action Page.do that gets 3 lists from a database.
> It then places the lists inside a bean which is set in the request.
> The Page.jsp iterates thru the bean to display the data.
>
> The form is posted to the PageSubmit.do.
> But before the PageForm.validate() is executed.
> Assume that an error is found...
> The response is returned
>
> And this is where my bean is lost.
> Why?
>
> I do not want to store thr bean in the HTTP Session.
>
> TIA,
> Glenn.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Request bean is lost
Posted by Rick Reumann <st...@reumann.net>.
gdeschen@cmhc-schl.gc.ca wrote:
> I have an action Page.do that gets 3 lists from a database.
> It then places the lists inside a bean which is set in the request.
> The Page.jsp iterates thru the bean to display the data.
>
> The form is posted to the PageSubmit.do.
> But before the PageForm.validate() is executed.
> Assume that an error is found...
> The response is returned
>
> And this is where my bean is lost.
> Why?
(As mentioned your form bean won't be lost but the lists you put into
the request would be. That's the nature of the request/response lifecycle).
> I do not want to store thr bean in the HTTP Session.
This is why I'm not so fond of the way Struts handles default validation
with the validation framework - this problem comes up all the time in an
application. In a case like this, I would opt for not having
validate="true" in your config file for this action, and in instead
manually call the validate method in your action. Then if validation
fails you can make a query to yoru dao to return your Lists and forward
back to the page. Probably best if you had a setUp() method in your
Action which can be called to do this setup. You'd call it of course the
first time you need to present the form, and then after manually calling
the validate() method on the form, and validation fails, you'd call it
again.
--
Rick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Request bean is lost
Posted by Robert Taylor <rt...@mulework.com>.
One solution is to point the input attribute value of the PageSubmit.do action mapping
to the Page.do action mapping thus re-retrieving the lists before displaying the page.
An alternative solution is to override the reset() of your action form so that it
retrieves the lists from the database and places them in the appropriate scope.
If the lists are composed of static data, you might consider retrieving them on
application start up and placing them in application scope (ServletContext) where
they will be available to all requests and then there would be no need to retrieve
them each time the page is displayed.
robert
> -----Original Message-----
> From: gdeschen@cmhc-schl.gc.ca [mailto:gdeschen@cmhc-schl.gc.ca]
> Sent: Tuesday, July 06, 2004 1:39 PM
> To: user@struts.apache.org
> Subject: Request bean is lost
>
>
> Greetings,
>
> I have an action Page.do that gets 3 lists from a database.
> It then places the lists inside a bean which is set in the request.
> The Page.jsp iterates thru the bean to display the data.
>
> The form is posted to the PageSubmit.do.
> But before the PageForm.validate() is executed.
> Assume that an error is found...
> The response is returned
>
> And this is where my bean is lost.
> Why?
>
> I do not want to store thr bean in the HTTP Session.
>
> TIA,
> Glenn.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org