You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by doahh <ga...@prodia.co.uk> on 2009/03/13 16:49:20 UTC

Getting property with s:action tag

I have been playing with the s:action tag and have found it impossible to
reference any property of the action in a struts2 like way. If I call an
action, ActionOne.java and return success then I am redirected to a page
called one-success.jsp which has the following:

&lt;s:action namespace="/mynamespace" name="actionTwo" id="myActionTwo" />

 I would like to be able to reference myActionTwo and get a property called
myActionTwoProperty. I have tried many variations but if I use:

&lt;s:property value="top"/&gt;
&lt;s:property value="[0].top"/&gt;
&lt;s:property value="[1].top"/&gt;

Then the action at the top of the stack is always ActionOne or an instance
of com.opensymphony.xwork2.DefaultTextProvider. It is never myActionTwo.
This is true whether or not I am within the <s:action> tag.

>From this discussion here:

http://www.nabble.com/-S2--s:action-in-value-stack--td21551483.html

It says that:

Outside the action tag, "firstAction" is on top of the stack, and
"secondAction" can be referenced by name. 

But I don't understand what it means by 'referenced by name'. Does anyone
know of a Struts2 like way to reference the properties of the actionTwo?

Currently I am in the actionTwo and setting the value I need into the
request object where the JSP can then retrieve it as described in the
Struts2 wiki entry:

http://struts.apache.org/2.x/docs/action.html
-- 
View this message in context: http://www.nabble.com/Getting-property-with-s%3Aaction-tag-tp22499355p22499355.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Getting property with s:action tag

Posted by doahh <ga...@prodia.co.uk>.
I didn't see your post before I posted again - thanks for the answer.


Musachy Barroso wrote:
> 
> "By name" means by the id in the "action" tag, like:
> 
> <s:action var="myaction" ..>
> </s:action>
> 
> <s:property value="#myaction.someProperty" />
> 
> musachy
> 
> On Fri, Mar 13, 2009 at 11:49 AM, doahh <ga...@prodia.co.uk> wrote:
>>
>> I have been playing with the s:action tag and have found it impossible to
>> reference any property of the action in a struts2 like way. If I call an
>> action, ActionOne.java and return success then I am redirected to a page
>> called one-success.jsp which has the following:
>>
>> &lt;s:action namespace="/mynamespace" name="actionTwo" id="myActionTwo"
>> />
>>
>>  I would like to be able to reference myActionTwo and get a property
>> called
>> myActionTwoProperty. I have tried many variations but if I use:
>>
>> &lt;s:property value="top"/&gt;
>> &lt;s:property value="[0].top"/&gt;
>> &lt;s:property value="[1].top"/&gt;
>>
>> Then the action at the top of the stack is always ActionOne or an
>> instance
>> of com.opensymphony.xwork2.DefaultTextProvider. It is never myActionTwo.
>> This is true whether or not I am within the <s:action> tag.
>>
>> From this discussion here:
>>
>> http://www.nabble.com/-S2--s:action-in-value-stack--td21551483.html
>>
>> It says that:
>>
>> Outside the action tag, "firstAction" is on top of the stack, and
>> "secondAction" can be referenced by name.
>>
>> But I don't understand what it means by 'referenced by name'. Does anyone
>> know of a Struts2 like way to reference the properties of the actionTwo?
>>
>> Currently I am in the actionTwo and setting the value I need into the
>> request object where the JSP can then retrieve it as described in the
>> Struts2 wiki entry:
>>
>> http://struts.apache.org/2.x/docs/action.html
>> --
>> View this message in context:
>> http://www.nabble.com/Getting-property-with-s%3Aaction-tag-tp22499355p22499355.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 
> 
> -- 
> "Hey you! Would you help me to carry the stone?" Pink Floyd
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Getting-property-with-s%3Aaction-tag-tp22499355p22502385.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Getting property with s:action tag

Posted by Musachy Barroso <mu...@gmail.com>.
"By name" means by the id in the "action" tag, like:

<s:action var="myaction" ..>
</s:action>

<s:property value="#myaction.someProperty" />

musachy

On Fri, Mar 13, 2009 at 11:49 AM, doahh <ga...@prodia.co.uk> wrote:
>
> I have been playing with the s:action tag and have found it impossible to
> reference any property of the action in a struts2 like way. If I call an
> action, ActionOne.java and return success then I am redirected to a page
> called one-success.jsp which has the following:
>
> &lt;s:action namespace="/mynamespace" name="actionTwo" id="myActionTwo" />
>
>  I would like to be able to reference myActionTwo and get a property called
> myActionTwoProperty. I have tried many variations but if I use:
>
> &lt;s:property value="top"/&gt;
> &lt;s:property value="[0].top"/&gt;
> &lt;s:property value="[1].top"/&gt;
>
> Then the action at the top of the stack is always ActionOne or an instance
> of com.opensymphony.xwork2.DefaultTextProvider. It is never myActionTwo.
> This is true whether or not I am within the <s:action> tag.
>
> From this discussion here:
>
> http://www.nabble.com/-S2--s:action-in-value-stack--td21551483.html
>
> It says that:
>
> Outside the action tag, "firstAction" is on top of the stack, and
> "secondAction" can be referenced by name.
>
> But I don't understand what it means by 'referenced by name'. Does anyone
> know of a Struts2 like way to reference the properties of the actionTwo?
>
> Currently I am in the actionTwo and setting the value I need into the
> request object where the JSP can then retrieve it as described in the
> Struts2 wiki entry:
>
> http://struts.apache.org/2.x/docs/action.html
> --
> View this message in context: http://www.nabble.com/Getting-property-with-s%3Aaction-tag-tp22499355p22499355.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Getting property with s:action tag

Posted by doahh <ga...@prodia.co.uk>.
Looking again at the post from:

http://www.nabble.com/-S2--s:action-in-value-stack--td21551483.html

I see that the answer is 

&lt;s:action namespace="/mynamespace" name="actionTwo" id="myActionTwo"
/&gt;

&lt;s:property value="#myActionTwo.myActionTwoProperty" /&gt;

I didn't understand the significance of the '#' symbol which I assume means
to reference by id or var. Anyway, the above works so I am happy.




doahh wrote:
> 
> I have been playing with the s:action tag and have found it impossible to
> reference any property of the action in a struts2 like way. If I call an
> action, ActionOne.java and return success then I am redirected to a page
> called one-success.jsp which has the following:
> 
> &lt;s:action namespace="/mynamespace" name="actionTwo" id="myActionTwo" />
> 
>  I would like to be able to reference myActionTwo and get a property
> called myActionTwoProperty. I have tried many variations but if I use:
> 
> &lt;s:property value="top"/&gt;
> &lt;s:property value="[0].top"/&gt;
> &lt;s:property value="[1].top"/&gt;
> 
> Then the action at the top of the stack is always ActionOne or an instance
> of com.opensymphony.xwork2.DefaultTextProvider. It is never myActionTwo.
> This is true whether or not I am within the <s:action> tag.
> 
> From this discussion here:
> 
> http://www.nabble.com/-S2--s:action-in-value-stack--td21551483.html
> 
> It says that:
> 
> Outside the action tag, "firstAction" is on top of the stack, and
> "secondAction" can be referenced by name. 
> 
> But I don't understand what it means by 'referenced by name'. Does anyone
> know of a Struts2 like way to reference the properties of the actionTwo?
> 
> Currently I am in the actionTwo and setting the value I need into the
> request object where the JSP can then retrieve it as described in the
> Struts2 wiki entry:
> 
> http://struts.apache.org/2.x/docs/action.html
> 

-- 
View this message in context: http://www.nabble.com/Getting-property-with-s%3Aaction-tag-tp22499355p22501213.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org