You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Manish Kumar Wadhwa <Ma...@niit.com> on 2008/11/24 11:37:48 UTC

How to read struts2 constants in action class

Hi All,

Is there a away to get the value of a constant, declared in the struts.xml file, in my action class?

<constant name="custom.myConstant" value="true" />

Thanks,
Manish

-------------------------------------------------------------------------------------------------------------

DISCLAIMER
This email and any files transmitted with it are confidential and are solely for the use of the individual or entity to which it is addressed. Any use, distribution, copying or disclosure by any other person is strictly prohibited. If you receive this transmission in error, please notify the sender by reply email and then destroy the message. Opinions, conclusions and other information in this message that do not relate to official business of the company shall be understood to be neither given nor endorsed by NIIT Ltd. Any information contained in this email, when addressed to Clients is subject to the terms and conditions in governing client contract.

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


RE: How to read struts2 constants in action class

Posted by Manish Kumar Wadhwa <Ma...@niit.com>.
Great.... it works.....

Thanks so much Musachy... :)

Manish.

-----Original Message-----
From: Musachy Barroso [mailto:musachy@gmail.com]
Sent: Monday, November 24, 2008 10:51 PM
To: Struts Users Mailing List
Subject: Re: How to read struts2 constants in action class

use "@Inject".

@Inject("custom.myConstant")
public void setSomeString(String mystring) {...}

Things to note about that:

1. Struts needs to be the one creating your actions (no object factory from
an IoC, like Spring, Guice, etc)
2. This is not guaranteed to work in the future, but it is unlikely to
change anytime soon.

musachy

On Mon, Nov 24, 2008 at 5:37 AM, Manish Kumar Wadhwa <Manish.Wadhwa@niit.com
> wrote:

> Hi All,
>
> Is there a away to get the value of a constant, declared in the struts.xml
> file, in my action class?
>
> <constant name="custom.myConstant" value="true" />
>
> Thanks,
> Manish
>
>
> -------------------------------------------------------------------------------------------------------------
>
> DISCLAIMER
> This email and any files transmitted with it are confidential and are
> solely for the use of the individual or entity to which it is addressed. Any
> use, distribution, copying or disclosure by any other person is strictly
> prohibited. If you receive this transmission in error, please notify the
> sender by reply email and then destroy the message. Opinions, conclusions
> and other information in this message that do not relate to official
> business of the company shall be understood to be neither given nor endorsed
> by NIIT Ltd. Any information contained in this email, when addressed to
> Clients is subject to the terms and conditions in governing client contract.
>
> ---------------------------------------------------------------------
> 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

-------------------------------------------------------------------------------------------------------------

DISCLAIMER
This email and any files transmitted with it are confidential and are solely for the use of the individual or entity to which it is addressed. Any use, distribution, copying or disclosure by any other person is strictly prohibited. If you receive this transmission in error, please notify the sender by reply email and then destroy the message. Opinions, conclusions and other information in this message that do not relate to official business of the company shall be understood to be neither given nor endorsed by NIIT Ltd. Any information contained in this email, when addressed to Clients is subject to the terms and conditions in governing client contract.

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


Re: How to read struts2 constants in action class

Posted by Musachy Barroso <mu...@gmail.com>.
use "@Inject".

@Inject("custom.myConstant")
public void setSomeString(String mystring) {...}

Things to note about that:

1. Struts needs to be the one creating your actions (no object factory from
an IoC, like Spring, Guice, etc)
2. This is not guaranteed to work in the future, but it is unlikely to
change anytime soon.

musachy

On Mon, Nov 24, 2008 at 5:37 AM, Manish Kumar Wadhwa <Manish.Wadhwa@niit.com
> wrote:

> Hi All,
>
> Is there a away to get the value of a constant, declared in the struts.xml
> file, in my action class?
>
> <constant name="custom.myConstant" value="true" />
>
> Thanks,
> Manish
>
>
> -------------------------------------------------------------------------------------------------------------
>
> DISCLAIMER
> This email and any files transmitted with it are confidential and are
> solely for the use of the individual or entity to which it is addressed. Any
> use, distribution, copying or disclosure by any other person is strictly
> prohibited. If you receive this transmission in error, please notify the
> sender by reply email and then destroy the message. Opinions, conclusions
> and other information in this message that do not relate to official
> business of the company shall be understood to be neither given nor endorsed
> by NIIT Ltd. Any information contained in this email, when addressed to
> Clients is subject to the terms and conditions in governing client contract.
>
> ---------------------------------------------------------------------
> 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