RE: Session Scope ActionForm, ActionErrors and the Back Button
On the controller element in the struts config, set the nocache attribute to true. We just did this for our current project and it has fixed a lot of issues with our wizard-type flows where we use a SessionBean to dictate flow. The other option is to manually write the pragma/expire headers on the action that displays the form to make sure that the particular page doesn't get cached by the client. We've found that having the JSP declare the no cache headers doesn't work too consistently (possibly web designer error). Action.execute(..) { response.setHeader(Pragma, No-cache); response.setHeader(Cache-Control, no-cache); response.setDateHeader(Expires, 1); return mapping.findForward(someval); } Jacob Hookom Senior Analyst/Programmer McKesson Medical-Surgical Golden Valley, Minnesota http://www.mckesson.com -Original Message- From: John Topley [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 02, 2003 12:31 PM To: [EMAIL PROTECTED] Subject: Session Scope ActionForm, ActionErrors and the Back Button My application has a sequence of pages that submit to a single ActionForm with session scope. The problem I have is that if the user clicks the Back button any previous ActionErrors are still displayed, even though the form fields may be populated with valid values. Is it possible to specify a session scope ActionForm with request scope ActionErrors? How can I solve this problem? I really want to keep the ActionForm in the session. I've searched this list but didn't find any solutions. Thanks in anticipation, John - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Session Scope ActionForm, ActionErrors and the Back Button
John, ActionErrors is stored under the key: Globals.ERROR_KEY. You can implement your ActionForm reset (which is called on all ActionForm objects on every request) method to remove the ActionErrors found under this key from your Request or Session. Jonathan -Original Message- From: John Topley [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 02, 2003 1:31 PM To: [EMAIL PROTECTED] Subject: Session Scope ActionForm, ActionErrors and the Back Button My application has a sequence of pages that submit to a single ActionForm with session scope. The problem I have is that if the user clicks the Back button any previous ActionErrors are still displayed, even though the form fields may be populated with valid values. Is it possible to specify a session scope ActionForm with request scope ActionErrors? How can I solve this problem? I really want to keep the ActionForm in the session. I've searched this list but didn't find any solutions. Thanks in anticipation, John - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Session Scope ActionForm, ActionErrors and the Back Button
Note that when you hit the Back button on a page not cached and retrieved by a GET, the browser will perform a new request... If the page was retrieved by a POST, the browser will display an error message or ask the user if he wants to repost the form. Hookom, Jacob [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On the controller element in the struts config, set the nocache attribute to true. We just did this for our current project and it has fixed a lot of issues with our wizard-type flows where we use a SessionBean to dictate flow. The other option is to manually write the pragma/expire headers on the action that displays the form to make sure that the particular page doesn't get cached by the client. We've found that having the JSP declare the no cache headers doesn't work too consistently (possibly web designer error). Action.execute(..) { response.setHeader(Pragma, No-cache); response.setHeader(Cache-Control, no-cache); response.setDateHeader(Expires, 1); return mapping.findForward(someval); } Jacob Hookom Senior Analyst/Programmer McKesson Medical-Surgical Golden Valley, Minnesota http://www.mckesson.com -Original Message- From: John Topley [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 02, 2003 12:31 PM To: [EMAIL PROTECTED] Subject: Session Scope ActionForm, ActionErrors and the Back Button My application has a sequence of pages that submit to a single ActionForm with session scope. The problem I have is that if the user clicks the Back button any previous ActionErrors are still displayed, even though the form fields may be populated with valid values. Is it possible to specify a session scope ActionForm with request scope ActionErrors? How can I solve this problem? I really want to keep the ActionForm in the session. I've searched this list but didn't find any solutions. Thanks in anticipation, John - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: session-scope ActionForm issue - confused
According to the ActionForm API, the reset() method is called before the properties are repopulated by the controller servlet. So by overriding it in your form, the field value should be reset prior to the next action regardless the form scope. -Erica -Original Message- From: apachep2 [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2003 9:53 AM To: [EMAIL PROTECTED] Subject: session-scope ActionForm issue - confused Since I didn't receive any response regarding my previous post session-scope actionform too persistent, I spent 2 hours this morning digging through struts source code. What I want to achieve is - load action to pre-populate some properties' values and load page. - action to forward to next action if Proceed is clicked, or to cleanup some properties' values and forwards to previous action if Previous is clicked. The process sequence of struts that I am interested in is found in process method of RequestProcessor. After all the pre-processes, - processor calls processActionForm to get an instance of action form associated with the action. In detail, processActionForm tries to find the actionform in scope and saves this object in scope specified by action mapping. If one found in session, it uses that object and saves that object in session scope under name of mapping.getAttribute(). - processor then calls processPopulate, processValidate, processForward, processInclude. - processor calls processActionCreate to create an instance of Action. - finally processor calls processActionPerform which calls Action class' execute method to return a forward string. According to my understanding, Action's execute method is the last place that I can change any value to my properties in a session scope ActionForm. What I feel frustrated is, although I set null value to my properties or set something else, after I come back, I still see the value that I have entered before. Of course, I wont' have this problem if scope is request. Has any one encountered the same problem? ps - get/set my action form request.getSession().setAttribute(mapping.getAttribute(), myActionForm) (MyActionForm) request.getSession().getAttribute(mapping.getAttribute()) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: session-scope ActionForm issue - confused
form.reset method is called by processPopulate method in class RequestProcessor. That is way before processActionPerform method is called. form.execute method is called by processActionPerform method in RequestProcessor. My issue is - value abcd is entered on the page; - changed value to 1234 in execute method in action class A; - check value, it is 1234; - forward to other actions that load other pages. I found that the value is still abcd. -Original Message- From: Erica Leung [mailto:[EMAIL PROTECTED] Sent: March 24, 2003 2:02 PM To: Struts Users Mailing List Subject: RE: session-scope ActionForm issue - confused According to the ActionForm API, the reset() method is called before the properties are repopulated by the controller servlet. So by overriding it in your form, the field value should be reset prior to the next action regardless the form scope. -Erica -Original Message- From: apachep2 [mailto:[EMAIL PROTECTED] Sent: Monday, March 24, 2003 9:53 AM To: [EMAIL PROTECTED] Subject: session-scope ActionForm issue - confused Since I didn't receive any response regarding my previous post session-scope actionform too persistent, I spent 2 hours this morning digging through struts source code. What I want to achieve is - load action to pre-populate some properties' values and load page. - action to forward to next action if Proceed is clicked, or to cleanup some properties' values and forwards to previous action if Previous is clicked. The process sequence of struts that I am interested in is found in process method of RequestProcessor. After all the pre-processes, - processor calls processActionForm to get an instance of action form associated with the action. In detail, processActionForm tries to find the actionform in scope and saves this object in scope specified by action mapping. If one found in session, it uses that object and saves that object in session scope under name of mapping.getAttribute(). - processor then calls processPopulate, processValidate, processForward, processInclude. - processor calls processActionCreate to create an instance of Action. - finally processor calls processActionPerform which calls Action class' execute method to return a forward string. According to my understanding, Action's execute method is the last place that I can change any value to my properties in a session scope ActionForm. What I feel frustrated is, although I set null value to my properties or set something else, after I come back, I still see the value that I have entered before. Of course, I wont' have this problem if scope is request. Has any one encountered the same problem? ps - get/set my action form request.getSession().setAttribute(mapping.getAttribute(), myActionForm) (MyActionForm) request.getSession().getAttribute(mapping.getAttribute()) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: session scope ActionForm
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 08, 2003 3:51 PM To: [EMAIL PROTECTED] Subject: session scope ActionForm I am a bit confused about session scope of ActionForm. For example, in my ActionForm testForm private String field1 ; private String filed2 ; I instantiate testForm in a PageOneLoadAction TestForm testForm = new TestForm() ; Request.getSession().setAttribute(testForm, testForm) ; On page one, I only need to enter field 1 html:form ... html:text property=field1/ /html:form Once I subimit, I assume that value of field 1 is saved into testForm. Only if the action-mapping for the above form uses the form-bean named testForm. Now I load page 2 which only requires user entering field 2. html:form... ... html:text property=field2/ /html:form If I submit, value of field 2 is saved into testForm. Will value of field 1 be kept in testForm? Yes, unless the reset() method of TestForm is clears it. Another obscure reason when it won't show up is if the action for page-2 refers to the form-bean with a different name. Regards, PQ Sri -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]