struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Moore <g...@clearridgeconsult.com>
Subject Re: [strut2] How to get ServletActionContext
Date Sat, 03 Oct 2009 14:58:53 GMT
Uh, no sooner than I sent this query did I realize that adding 
singleton="false" to the factory bean solves my problem.
Thanks
Gary
Gary Moore wrote:
> Newbie question here.
> In my struts1 apps stuff gets loaded into an application container on 
> start-up using ActionServlet, e.g. 
> servlet.getServletContext().setAttribute( 
> IConstants.APPLICATION_CONTAINER_KEY, app ); .
>
> I'm trying to do the comparable in struts2 using a bean in 
> applicationContext.xml:
>
> <bean id="apptainer" 
> class="com.clearridgeconsult.struts2.framework.AgricolaApplicationContainer" 
> >
>        <constructor-arg index="0" 
> value="/WEB-INF/config/NALTIndexConfig.xml"/>
>        <constructor-arg index="1" 
> value="/WEB-INF/config/AgricolaIndexConfig.xml"/>
> </bean>
>
> However, in the AgricolaApplicationContainer constructor, 
> ServletActionContext.getServletContext()  is null.  From seaching the 
> list archives, I've tried setting up a factory bean in 
> applicationContext.xml to make the servlet context available:
>
> <bean id="contextFactory" 
> class="com.clearridgeconsult.struts2.framework.StrutsServletContextLoader"/> 
>
>    <bean id="servletCtx" factory-bean="contextFactory" 
> factory-method="getServletContext"/>
>    <bean id="apptainer" 
> class="com.clearridgeconsult.struts2.framework.AgricolaApplicationContainer" 
> >
>        <constructor-arg index="0" 
> value="/WEB-INF/config/NALTIndexConfig.xml"/>
>        <constructor-arg index="1" 
> value="/WEB-INF/config/AgricolaIndexConfig.xml"/>
>        <constructor-arg index="2" ref="servletCtx"/>
>    </bean>
>
> But, again, ServletActionContext.getServletContext() is null in the 
> contextFactory bean.
>
> I'm know I'm missing some obvious point here, but how do you make 
> ServletActionContext made available?
>
> Thanks,
> Gary
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message