You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Joe Lam <jo...@moni-media.net> on 2007/08/17 12:49:41 UTC

[S2] how to get the constants in struts.xml programmatically?

In my class, I want to read a constant in struts.xml. 
I see some examples using @inject , somehow I cant make it work.

May someone help me? just wanna to get those constants in struts.xml
(don't want to use java properties file this time. I think it is easier to
maintain in struts.xml)

Thanks

Joe

-- 
View this message in context: http://www.nabble.com/-S2--how-to-get-the-constants-in-struts.xml-programmatically--tf4285007.html#a12197579
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: [S2] how to get the constants in struts.xml programmatically?

Posted by Joe Lam <jo...@moni-media.net>.
Anyone know the answer?

Thank you very much



Joe Lam wrote:
> 
> In my class, I want to read a constant in struts.xml. 
> I see some examples using @inject , somehow I cant make it work.
> 
> May someone help me? just wanna to get those constants in struts.xml
> (don't want to use java properties file this time. I think it is easier to
> maintain in struts.xml)
> 
> Thanks
> 
> Joe
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--how-to-get-the-constants-in-struts.xml-programmatically--tf4285007.html#a12271289
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: [S2] how to get the constants in struts.xml programmatically?

Posted by "Crocker, Patrick" <Pa...@bear.com>.
And what if you are using a different ObjectFactory... such as Spring?

- Patrick.

-----Original Message-----
From: Don Brown [mailto:donald.brown@gmail.com] 
Sent: Wednesday, August 22, 2007 5:26 AM
To: Struts Users Mailing List
Subject: Re: [S2] how to get the constants in struts.xml
programmatically?

First, ensure that the object that Struts will be injecting to is
created by Struts.  Then, you can do:

@Inject(StrutsConstants.SOME_CONSTANT_HERE)
public void setSomeConstant(String val) {...}

For example, Actions, Interceptors, and Result objects are generally
processed for injections by Struts, so you could put the setter in one
of those.

Don

On 8/17/07, Joe Lam <jo...@moni-media.net> wrote:
>
> In my class, I want to read a constant in struts.xml.
> I see some examples using @inject , somehow I cant make it work.
>
> May someone help me? just wanna to get those constants in struts.xml 
> (don't want to use java properties file this time. I think it is 
> easier to maintain in struts.xml)
>
> Thanks
>
> Joe
>
> --
> View this message in context: 
> http://www.nabble.com/-S2--how-to-get-the-constants-in-struts.xml-prog
> rammatically--tf4285007.html#a12197579
> 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
>
>



***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation, 
offer or agreement or any information about any transaction, customer 
account or account activity contained in this communication.
***********************************************************************

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


Re: [S2] how to get the constants in struts.xml programmatically?

Posted by Don Brown <do...@gmail.com>.
First, ensure that the object that Struts will be injecting to is
created by Struts.  Then, you can do:

@Inject(StrutsConstants.SOME_CONSTANT_HERE)
public void setSomeConstant(String val) {...}

For example, Actions, Interceptors, and Result objects are generally
processed for injections by Struts, so you could put the setter in one
of those.

Don

On 8/17/07, Joe Lam <jo...@moni-media.net> wrote:
>
> In my class, I want to read a constant in struts.xml.
> I see some examples using @inject , somehow I cant make it work.
>
> May someone help me? just wanna to get those constants in struts.xml
> (don't want to use java properties file this time. I think it is easier to
> maintain in struts.xml)
>
> Thanks
>
> Joe
>
> --
> View this message in context: http://www.nabble.com/-S2--how-to-get-the-constants-in-struts.xml-programmatically--tf4285007.html#a12197579
> 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