You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Harring Figueiredo <ha...@gmail.com> on 2007/03/14 17:04:24 UTC
[s2] How to pass param to actions from Struts.xml
Folks,
Is there a way to pass parameter to an Action using the struts.xml config
file.
1 ) I see that the <action ..> has a param attribute. How can I access its
value from within the action?
My action already implements the ParameterAwre interface. However, I am
unable to see the value on the Map provided by the setParameter() IoC call.
2) Is this the same functionality as the the Struts ActionMapping?
Thanks in advance
Harring Figueiredo
Re: [s2] How to pass param to actions from Struts.xml
Posted by cilquirm <aa...@gmail.com>.
Create a setter with the same name as your param.
ex :
for :
<action name="blah" class="MyAction"
<param name="myValue">This value</param>
</action>
in MyAction :
public class MyAction implements Action {
private String myValue;
public void setMyValue( String value) { this.myValue = value; }
}
Type conversion's done on this param value just like any other parameter.
hth,
-a
Harring Figueiredo wrote:
>
> Folks,
>
> Is there a way to pass parameter to an Action using the struts.xml config
> file.
>
> 1 ) I see that the <action ..> has a param attribute. How can I access its
> value from within the action?
>
> My action already implements the ParameterAwre interface. However, I am
> unable to see the value on the Map provided by the setParameter() IoC
> call.
>
> 2) Is this the same functionality as the the Struts ActionMapping?
>
> Thanks in advance
>
> Harring Figueiredo
>
>
--
View this message in context: http://www.nabble.com/-s2--How-to-pass-param-to-actions-from-Struts.xml-tf3403074.html#a9478391
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