struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeromy Evans <jeromy.ev...@blueskyminds.com.au>
Subject Re: Struts constants
Date Wed, 02 Apr 2008 02:39:26 GMT
Matthew Seaborn wrote:
> What I meant was if the following is defined in the struts.xml
>
>             <constant name="struts.url.includeParams" value="none" />
>
> How does that make it to the URLTag#setIncludeParams method and how can make our own
constants?
>
>   

Didn't I answer that?  Repeated below again.

---
If you want the value of a constant, use @Inject on a setter. This is 
available only to objects instantiated by the Struts2 Container (actions 
or beans in the config)

Example:

import com.opensymphony.xwork2.inject.Inject;

@Inject("struts.url.includeParams")
public void setIncludeParams(String value) {}

You can create new constants as struts.xml.
---
To access them elsewhere you'll have to get a reference to the 
com.opensymphony.xwork2.inject.Container instance which may be available 
from your DI framework (Guice/Spring). I'm not sure how much luck you'll 
have with that.

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


Mime
View raw message