| Author |
ActionContext & ValueStack in struts2
|
sarada bokka
Ranch Hand
Joined: Jan 13, 2010
Posts: 80
|
|
Hi,
ActionContext holds the below all
1)parameters - Map of request parameters for this request
2)request - Map of request-scoped attributes
3)session - Map of session-scoped attributes
4)application - Map of application-scoped attributes
5)attr - Returns first occurrence of attribute occurring in page, request,session, or application scope, in that order
6)ValueStack - Contains all the application-domain–specific data for the request
I am having a variable name with getter & setter in my Action class ,is that it will store in the values in both parameters & value stack as mentioned above?
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
sarada chellub wrote:I am having a variable name with getter & setter in my Action class ,is that it will store in the values in both parameters & value stack as mentioned above?
It depends whether the variable (lets say username) came in as a request parameter or not. If the request did contain a parameter named username, then username will be in the parameters as well as the value stack (as the whole action object goes into the value stack)...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
sarada bokka
Ranch Hand
Joined: Jan 13, 2010
Posts: 80
|
|
Hi Ankit,
Thanks for your input.
You have mentioned that username will be in the parameters as well as the value stack
what's the purpose of storing the value in both (parameters & value stack)?
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
The value will go into the value stack as its in the action and the action goes into the value stack. And as it was received as a request parameter, it will also be in the parameters map for any future actions or JSPs. If its removed from the parameters, any further action or JSP which might process the request might think that the request didn't have that parameter, this might confuse it into thinking that the parameter wasn't sent so the request should be aborted or an error message sent to the user...
|
 |
 |
|
|
subject: ActionContext & ValueStack in struts2
|
|
|