You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kibo <to...@gmail.com> on 2008/04/27 08:28:58 UTC

action tag

Hi konference

I would like use tag action but from action I need only property, dont
executed/rendered.

When I use this:
<s:action name="Action1" namespace="/" executeResult="true" />
<s:property value="%{testValue}" />
rendered it result and view.

When I use this:
<s:action name="Action1" namespace="/" executeResult="false" />
<s:property value="%{testValue}" />
the action probably dont execute and the value is empty
--------------------------
struts.xml
 <action name="Action1" class="cz.test.ActionTest" method="list">       
        <result>/index.jsp</result>                               	  	       	                        	              
 </action>	
------------------------
ActionTest.class

    int testValue;

    public void prepare() throws Exception {
         testValue=3;
   }

   public String list() throws Exception{				
		return SUCCESS; //==========>
	}

    public int getTestValue()...
   public void setTestValue(int value)...
------------------------------------------------

Thanks for help

-----
Tomas Jurman
Czech Republic
-- 
View this message in context: http://www.nabble.com/action-tag-tp16920759p16920759.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: action tag

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Kibo wrote:
> Hi konference
>
> I would like use tag action but from action I need only property, dont
> executed/rendered.
>
> When I use this:
> <s:action name="Action1" namespace="/" executeResult="true" />
> <s:property value="%{testValue}" />
> rendered it result and view.
>
> When I use this:
> <s:action name="Action1" namespace="/" executeResult="false" />
> <s:property value="%{testValue}" />
> the action probably dont execute and the value is empty
> --------------------------
> struts.xml
>  <action name="Action1" class="cz.test.ActionTest" method="list">       
>         <result>/index.jsp</result>                               	  	       	                        	              
>  </action>	
> ------------------------
> ActionTest.class
>
>     int testValue;
>
>     public void prepare() throws Exception {
>          testValue=3;
>    }
>
>    public String list() throws Exception{				
> 		return SUCCESS; //==========>
> 	}
>
>     public int getTestValue()...
>    public void setTestValue(int value)...
> ------------------------------------------------
>
> Thanks for help
>
> -----
> Tomas Jurman
> Czech Republic
>   


Hi Tomas,

The action you invoke via the tag does not remain on the stack after it 
is executed. It and it's properties are gone. You have two options to 
achieve what you're attempting.
1. pass body content to the action tag that will be rendered as the result
2. have the action place the properties of interest into request scope

Technique 1 is in the second example of the documentation. 
http://struts.apache.org/2.x/docs/action.html
After the action places a value into the scope, the property is obtained 
via #attr

Technique 2 looks like this:

<s:action name="Action1" namespace="/" executeResult="false">
<s:property value="%{testValue}" />
</s:action>

The body of the tag is the result and is executed while that action is 
on top of the stack.
 
Caution: The action tag is powerful, dangerous and broken. I don't 
recommend  becoming dependent on it for componentization of your pages. 
It cannot safely execute all result types and it cannot safely invoke 
any action.

Hope that helps,
Jeromy Evans






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