Eh, that's the more complicated way... struts2 autowires by name, no
need to implement ApplicationContextAware. I think people are missing
the point.

I got it working just fine by adding 10 properties to my action with
appropriate getters and setters, but I'm trying to sneak around having
to add them to my Actions because I'd rather just have them available
in my JSPs. No big deal I guess because I got it to work by adding the
properties to my Action and they get auto-wired by Spring, but it'd be
REALLY nice if they were available on the context map... it looks like
I can either writer an Interceptor to put the beans on the stack.

Thanks,
James

On Tue, Sep 8, 2009 at 6:30 PM, Marty Milligan<milligansisl...@gmail.com> wrote:
> On Tue, Sep 8, 2009 at 5:55 PM, James Carr<james.r.c...@gmail.com> wrote:
>> Yeah, I was looking for a way around it... these are simple hash maps
>> that are used to display select options. I wound up with an action
>> with 5 Maps in it :(
>
> If it were me, this is what I would do.
>
> First,use a Spring object factory in your Struts configuration:
> <constant name="struts.objectFactory" value="spring" />
>
> Second, in your action class, implement
> org.springframework.context.ApplicationContextAware:
>    public void setApplicationContext(ApplicationContext ctx) throws
> BeansException {
>        this.ctx = ctx;
>    }
>
> Third, implement any getters on the action that your view will need
> from the context.
>
> Fourth, define your action in the Spring configuration file:
>    <bean id="yourAction" scope="prototype" class="your.action.ClassName" >
>        ...
>    </bean>
>
> Fifth, test this to see if my memory is as good as I recall.
>
> And lastly, sorry I have not yet introduced myself, I just joined
> because I'm converting one of my applications to Struts 2.
>
> --
> cordially,
> Marty Milligan PO Box 434, Falling Waters, WV 25419
> http://milligansisland.com/ http://byteslinger.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>

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

Reply via email to