struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wes Wannemacher <w...@wantii.com>
Subject Re: Best global parameter aproach for struts2
Date Wed, 28 Jan 2009 02:31:59 GMT
On Tuesday 27 January 2009 21:20:17 Ignacio de Córdoba wrote:
> Hi there,
> after starting some serious migration from struts to struts2 I am wondering
> is there is any "best practices" for global application parameters.
> I used to store this parameters in web.xml, but as struts2 finds important
> not to be tied to the "http" thing (I read it very often in docs... about
> unit testing, etc.) I find myself with problems every time I want to get a
> web.xml init parameter.
> In actions it is not that difficult, but it is in interceptors, as there is
> no way to get the ServletContext as they have no init method getting it as
> a parameter. (I am now lazy loading that parameter at first Action
> invocation to the interceptor)
> I wonder if there is another aproach to set init parameters and forget
> about web.xml... I need some init parameters easily readable from both
> actions and interceptors... struts.xml, struts.properties, ...
>
> Thanks for any ideas,
> Ignacio

It might seem a bit extreme for simple values, but I use Spring. If configured 
correctly, it will be mostly non-intrusive, then getting values for can be as 
simple as adding a setter to your action/interceptor/result. Then, in the 
long-run, you also get the benefit of having Spring's libraries (for when you 
decide to integrate JPA, AOP or whatever is cool that week).

-Wes

-- 

Wes Wannemacher
Author - Struts 2 In Practice 
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher


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


Mime
View raw message