To the action mapping

-----Original Message-----
From: David Johnson [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 06, 2005 1:52 PM
To: Michael Jouravlev; Struts Users Mailing List
Subject: Re: Losing request attributes after validate()


ahhhh I see. Soam I adding scrope="session" to the Form Bean or the Action 
Mapping? 

On 5/6/05, Michael Jouravlev <[EMAIL PROTECTED]> wrote: 
> 
> > I do have redirect="true" set on the actionMapping that brings me to
> this
> > page, and tthe browser should be caching field values.
> >
> > the weird thing is this works in other places
> 
> If you want to keep redirect="true" (I personally prefer redirects for 
> better user experience), then you may want to set scope="session" for 
> your form.
> 
> This should not work in other places. Maybe your other forms have 
> session scope or somehow browser thinks that it can cache those pages?
> 
> > > You need to include hidden files for any static text properties.
> > >
> > > Typically I have <bean:write name="form" property="property" 
> > > /><html:hidden name="form" property="property" />
> > >
> > > NOTE: this should not be done for input fields
> > >
> > > <html:text name="form" property="property" /> <!-- do not include 
> > > a
> hidden
> > > field for this property -->
> > >
> > I actually am for one of the properties.
> > In the page I have :
> > <html-el:hidden property="queryName" value="${queryName}"/> and in 
> > the Action Class (right before the reditrct to this page) 
> > request.setAttribute("queryName",queryName);
> > and it shows fine in view--> source.
> > thn if I submit the form (wiuth an error) the hidden field is 
> > **not** populated
> 
> It will not be populated. You redirect to the page, that is, you 
> reload the page from the server using empty GET request with no query 
> parameters. Struts cannot populate your form bean since there is no 
> input data. So it just shows you JSP using current form field values. 
> If your form has request scope, it is recreated for each request, so 
> there are no values in it.
> 
> Do not use hidden fields. You started well using redirection to the 
> View ;-) Just change scope of your form to "session", and it will 
> retain values for you. But now you would have to clean unneeded values 
> in the reset() method. It is a bit of a hassle, but it works better 
> for an end user, and you do not need to pass viewstate in hidden HTML 
> fields.
> 
> Maybe you will find this useful: 
> http://wiki.apache.org/struts/StrutsCatalogRedirectToInputPage
> http://wiki.apache.org/struts/StrutsMultipleActionForms
> 
> Michael.
> 



-- 
-Dave
[EMAIL PROTECTED]

**************************************************************************** 
This email may contain confidential material. 
If you were not an intended recipient, 
Please notify the sender and delete all copies. 
We may monitor email to and from our network. 
****************************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to