Jake Vang wrote:
> 
>> If you want Spring to create your action class (as opposed to Struts
>> creating them) then you need to define your action in the
>> applicationContext.xml file.
> 
> how do you do that? here's a couple of ways i have tried that do NOT work.
> 

1) Add <constant name="struts.objectFactory"
value="org.apache.struts2.spring.StrutsSpringObjectFactory" /> to your
struts.xml file.

2) Add  <listener>
       
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

to your web.xml

3) Make sure that you have the Struts2 Spring plugin installed.

4) Put something along the lines of
<bean id="myAction" class="com.somwhere.mypackage.MyAction"
scope="prototype"/> (The scope prototype is important otherwise Spring
creates a singleton rather than a new action on each invocation which is
what Struts 2 expects)

and that should get Spring instantiating your action classes for you.

Although I'm guessing from your response you've already got to that stage.

I'm not sure that I understand what you are trying to acheive with 

<bean name="/action" class="com.services.MyAction">
 <property name="propertyA" value="${propertyA}"/>
</bean>  

If you're trying to inject another class, then the format is on the lines of

<bean name="/action" class="com.services.MyAction">
 <property name="classA" ref="classA"/>
</bean>  

where you need a setter that matches the name parameter (setClassA(ClassA
classA)) in MyAction. The ref value points to another <bean id="classA"
class="com.services.classA"/>

HTH and I haven't completely misunderstood what you are trying to do.

Regards


-- 
View this message in context: 
http://old.nabble.com/spring%2C-struts2%2C-convention-plugin%2C-how-to-%22wire%22-an-action-class-tp28545412p28547552.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to