aspose file tools*
The moose likes Struts and the fly likes Struts 2 newbie confused by value stack Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 newbie confused by value stack" Watch "Struts 2 newbie confused by value stack" New topic

Struts 2 newbie confused by value stack

Rain Skat

Joined: May 05, 2011
Posts: 1
I am confused about how the value stack works. I thought every attribute in your action classes (with getter&setter methods) get pushed on the value stack automatically. Is this true or not? If it's true, how do you access the attributes of another action class? I've tried using stack.findValue method but it's returning empty. Here's code example:

public class FirstAction extends ActionSupport{
private Object a;
// getter and setter method for a

public class SecondAction extends ActionSupport{

public String execute() throws Exception {
ValueStack stack = ActionContext.getContext().getValueStack();
Object a = stack.findValue("a");
// At this point, Object a is null. Why???
Manuel Schenkhuizen

Joined: Apr 20, 2011
Posts: 14
When you hit the action class, the value stack will push the property of your class on the value stack.
I agree. Here's the link:
subject: Struts 2 newbie confused by value stack
Similar Threads
parameter variable to action class instance variable
How to access the property of action in case of ModelDriven
Struts2 Model Driven question for a complex model
Prepare,ModelDriven interface
need to transfer productID from url to action class in struts 2