I would like to use values across multiple actions in strtus2 , concretelly, I developed following sample.
When I input like sample input
in input tag, this value is passed to updateAction.java
then nextAction.jsp
will be loaded then ServletHelperAction
will executed.
After that,sample input
is shown in my console.
My expectation is to show changed in Action
because this variable is changed in updateAction.java
.
Why this variables are not preserved in session ? Is this related to ValueStack
?
jsp
<input name="inputValue" value="${getInputValue()}" form="formCasePost">
<form method="post" id="formCasePost" submit="case-update"></form>
updateAction.java
public class updateAction extends ActionSupport implements SessionAware {
@Getter @Setter
private String inputValue;
@Getter @Setter
private Map<String, Object> session;
@Action(value = "case-update", results = {
@Result(location = "nextAction.jsp")
})
public String update() {
this.setInputValue("changed in Action");
this.session.put("changedInputValue",inputValue)
return SUCCESS;
}
}
nextAction.jsp
<s:action var="ServletHelperAction" name="login-user-to-bean" namespace="/servlet-helper"></s:action>
AnotherFileAction.java
public class ServletHelperAction extends ActionSupport implements SessionAware{
@Action(value = "login-user-to-bean", results = {
@Result(location = "servlethelper.jsp")
})
public String loginUserToBean() {
System.out.println(this.session.get("changedInputValue"));
// my expectation is "changed in Action", but actual value is "sample input"
}