Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 newbie confused by value stack

 
Rain Skat
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you hit the action class, the value stack will push the property of your class on the value stack.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic