You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by apachep2 <ap...@hotmail.com> on 2003/03/24 18:52:49 UTC

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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: session-scope ActionForm issue - confused

Posted by apachep2 <ap...@hotmail.com>.
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:eleung@puremarkets.com] 
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:apachep2@hotmail.com]
Sent: Monday, March 24, 2003 9:53 AM
To: struts-user@jakarta.apache.org
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



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


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


RE: session-scope ActionForm issue - confused

Posted by Erica Leung <el...@puremarkets.com>.
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:apachep2@hotmail.com]
Sent: Monday, March 24, 2003 9:53 AM
To: struts-user@jakarta.apache.org
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: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



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