Announcement Announcement Module
Collapse
No announcement yet.
Struts 2 + Tiles 2 + Spring 3, Tiles ViewPreparer bean not found. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Struts 2 + Tiles 2 + Spring 3, Tiles ViewPreparer bean not found.

    I'm trying to integrate these technologies, I'm having problems with the "ViewPreparer" classes that list the results from queries...

    When this class tries to get customerDAO it cannot find it because it hasn't been injected...

    Code:
    package ro.action.list;
    
    import org.apache.tiles.AttributeContext;
    import org.apache.tiles.context.TilesRequestContext;
    import org.apache.tiles.preparer.PreparerException;
    import org.apache.tiles.preparer.ViewPreparerSupport;
    
    import ro.dao.CustomerDAO;
    import ro.model.Operator;
    
    public class OperatorActionListing extends ViewPreparerSupport {
    	
    	private CustomerDAO customerDAO;
    
    	@Override
    	public void execute(TilesRequestContext tilesContext, AttributeContext attributeContext)
    			throws PreparerException {
    
    		Operator operatorExample = (Operator) tilesContext.getRequestScope().get("operatorExample");
    			
    		if(operatorExample == null) {
    			tilesContext.getRequestScope().put("operators", getCustomerDAO().findConcrete(Operator.class));
    		} else {
    			tilesContext.getRequestScope().put("operators", getCustomerDAO().findConcreteByExample(operatorExample, Operator.class));
    		}
    
    	}
    
    	public CustomerDAO getCustomerDAO() {
    		return customerDAO;
    	}
    
    	public void setCustomerDAO(CustomerDAO customerDAO) {
    		this.customerDAO = customerDAO;
    	}
    }

    This are most of the beans implied...
    Code:
    	<bean id="genericHibernateDAO" class="ro.dao.hibernate.GenericHibernateDAO" abstract="true" autowire="no">
    		<property name="sessionFactory" ref="sessionFactory" />
    	</bean>	
    
    
    	<bean id="customerDAO" class="ro.dao.hibernate.CustomerDAOHibernate" parent="genericHibernateDAO" autowire="no"/>
    
    	<bean id="operatorActionListing" class="ro.action.list.OperatorActionListing" scope="prototype" autowire="no"> 
    		<property name="customerDAO" ref="customerDAO" />
    	</bean>
    I have put these beans together here but genericHibernateDAO is in ro-data.xml, while the other beans are in ro-servlet.xml. I don't know if this has something to do with anything, by the way... Besides as I'm using tomcat, the...

    Code:
    <context:load-time-weaver weaver-class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver" />
    is also in ro-data.xml...

    I get a warning that says that javax.* objects are not being woven but I don't know what this implies...

    This is the tiles definition

    Code:
    	<definition name="OperatorActionListing" extends="administratorBase" preparer="model.action.list.OperatorActionListing">
    		<put-attribute name="title" value="Operators Listing" />
    		<put-attribute name="body" value="/jsp/administrator/operatorList.jsp" />
    	</definition>
    If I, however, set the definition with the preparer attribute this way

    Code:
    preparer="operatorActionListing"
    the same name as the bean what is more logical, when debugging, the program doesn't even enter in the OperatorActionListing class...

    By the way, this is the tilesConfigurer:

    Code:
    	<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    		<property name="definitions">
    			<list>
    				<value>/WEB-INF/tiles.xml</value>
    			</list>
    		</property>
    		<property name="preparerFactoryClass" value="org.springframework.web.servlet.view.tiles2.SpringBeanPreparerFactory" />
    	</bean>
    Finally, i can add that I have set these properties in struts.properties... I don't know whether they are correct...

    Code:
    struts.objectFactory=spring
    struts.objectFactory.spring.autoWire=auto
    any ideas to help me?

    Thank you.
Working...
X