If I had a typical setup with an action that forwards to the JSP I would request my properties like so:
<s:property value="myVariable" />
where myVariable is a variable in the action.
I want to use action tags like this in another page:
<s:action name="actionName" executeResult="false">
<s:param name="switch">true</s:param>
</s:action>
How do I access myVariable when using an action tag like above? I tried <s:property value="myVariable" /> but it doesn’t work.
When you write
<s:property value="myVariable" />, Struts looks for the propertymyVariablein its “Value Stack”. The current action is in the ValueStack, and that’s why the typical setup works. Now, in the case ofwhen the last line is executed the
actionNameaction has already executed, the current action is not that but the main (“outer”) one . If you want to acces properties of your “inner” action, you have several alternatives, two of them are shown in the docs:Either add the
varattribute so that the executed (inner) action is assigned to a variable and reference it with the # syntax:Or, in your action method, add your property value explicitly to some scope ( eg: attribute)
Disclaimer: I’ve not tested this