You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Manoel Pimentel <ma...@gmail.com> on 2008/01/09 18:54:44 UTC
Catch the element param in a action class
Hi to everyone,
Please, I need help :-).
Like are possible catch the values in a session using the
"ActionContext.getContext().getSession()", I want to know if have any way to
catch in a action class, the value of one parameter set in the struts.xml
file?
Example:
I need use in my Action class, the value set in a tag like: XLS inside a
action element.
Thanks for any help, ok?
Manoel Pimentel
www.visaoagil.com
--
View this message in context: http://www.nabble.com/Catch-the-element-param-in-a-action-class-tp14716540p14716540.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: Catch the element param in a action class
Posted by Manoel Pimentel <ma...@gmail.com>.
Hi Chris!
Good idea (why I never thought about this?), I will try this way, I think
that this tip will be much useful.
Tks,
Manoel Pimentel
www.visaoagil.com
Chris Pratt wrote:
>
> One thing you can do is use the tag in struts.xml (along with
> the staticParams interceptor from the defaultStack) to inject the
> value of a parameter into your action.
>
> If you have something like this in your struts.xml:
>
> <action name="login" class="my.company.controller.LoginAction">
> anybody
> <result>home.jsp</result>
> </action>
>
> And then you add a setRole(String role) method to your LoginAction, it
> will automatically be populated for you by the time your
> LoginAction.execute() method is called.
> (*Chris*)
>
> On Jan 10, 2008 5:48 AM, Manoel Pimentel <ma...@gmail.com> wrote:
>>
>> Hi Friends,
>>
>> I did one small workaround, I used the
>> "ServletActionContext.getActionMapping().getName()" for catch the name of
>> my
>> action and as i have two element action using the same action class,
>> this
>> way work well.
>> But, I still can't catch the value into the param element.
>>
>> Tks,
>>
>> Manoel Pimentel
>> www.visaoagil.com
>>
>>
>>
>>
>> Manoel Pimentel wrote:
>> >
>> > Hi to everyone,
>> >
>> > Please, I need help :-).
>> >
>> > Like are possible catch the values in a session using the
>> > "ActionContext.getContext().getSession()", I want to know if have any
>> way
>> > to catch in a action class, the value of one parameter set in the
>> > struts.xml file?
>> >
>> > Example:
>> > I need use in my Action class, the value set in a tag like: XLS inside
>> a
>> > action element.
>> >
>> > Thanks for any help, ok?
>> >
>> > Manoel Pimentel
>> > www.visaoagil.com
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Catch-the-element-param-in-a-action-class-tp14716540p14733722.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
>>
>>
>
> ---------------------------------------------------------------------
> 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/Catch-the-element-param-in-a-action-class-tp14716540p14752779.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: Catch the element param in a action class
Posted by Chris Pratt <th...@gmail.com>.
One thing you can do is use the <param> tag in struts.xml (along with
the staticParams interceptor from the defaultStack) to inject the
value of a parameter into your action.
If you have something like this in your struts.xml:
<action name="login" class="my.company.controller.LoginAction">
<param name="role">anybody</param>
<result>home.jsp</result>
</action>
And then you add a setRole(String role) method to your LoginAction, it
will automatically be populated for you by the time your
LoginAction.execute() method is called.
(*Chris*)
On Jan 10, 2008 5:48 AM, Manoel Pimentel <ma...@gmail.com> wrote:
>
> Hi Friends,
>
> I did one small workaround, I used the
> "ServletActionContext.getActionMapping().getName()" for catch the name of my
> action and as i have two element action using the same action class, this
> way work well.
> But, I still can't catch the value into the param element.
>
> Tks,
>
> Manoel Pimentel
> www.visaoagil.com
>
>
>
>
> Manoel Pimentel wrote:
> >
> > Hi to everyone,
> >
> > Please, I need help :-).
> >
> > Like are possible catch the values in a session using the
> > "ActionContext.getContext().getSession()", I want to know if have any way
> > to catch in a action class, the value of one parameter set in the
> > struts.xml file?
> >
> > Example:
> > I need use in my Action class, the value set in a tag like: XLS inside a
> > action element.
> >
> > Thanks for any help, ok?
> >
> > Manoel Pimentel
> > www.visaoagil.com
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Catch-the-element-param-in-a-action-class-tp14716540p14733722.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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Catch the element param in a action class
Posted by Manoel Pimentel <ma...@gmail.com>.
Hi Friends,
I did one small workaround, I used the
"ServletActionContext.getActionMapping().getName()" for catch the name of my
action and as i have two element action using the same action class, this
way work well.
But, I still can't catch the value into the param element.
Tks,
Manoel Pimentel
www.visaoagil.com
Manoel Pimentel wrote:
>
> Hi to everyone,
>
> Please, I need help :-).
>
> Like are possible catch the values in a session using the
> "ActionContext.getContext().getSession()", I want to know if have any way
> to catch in a action class, the value of one parameter set in the
> struts.xml file?
>
> Example:
> I need use in my Action class, the value set in a tag like: XLS inside a
> action element.
>
> Thanks for any help, ok?
>
> Manoel Pimentel
> www.visaoagil.com
>
>
--
View this message in context: http://www.nabble.com/Catch-the-element-param-in-a-action-class-tp14716540p14733722.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