Struts tiles to Tiles migration - Changes in Spring support classes

1.4k Views Asked by At

This situation arose when I tried to upgrade Spring from version 2.1 to Spring 3.0.x in my web application. Spring 3.0.x doesn't support struts-tiles 1.3, it requires Apache Tiles 2.x. So, I also have to upgrade Struts-Tiles 1.3 to Apache Tiles 2.x. Apache tiles has this migration guide that helped me with this effort. However, I seem to have hit a wall on this which is not mentioned in the migration guide.Here are the details:

This is the tilesConfigurer we were using,

<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles.TilesConfigurer">
        <property name="factoryClass">
            <value>org.apache.struts.tiles.xmlDefinition.I18nFactorySet</value>
        </property>
        <property name="definitions">
            <list>
                <value>/WEB-INF/tiles-defs.xml</value>
            </list>
        </property>
</bean>

Since, the class tiles.TilesConfigurer is deprecated in Spring 3.0.x, I changed it to use org.springframework.web.servlet.view.tiles2.TilesConfigurer

The tiles2.TilesConfigurer does not have a setFactoryClass(..) method unlike tiles.TilesConfigurer which is now deprecated. And hence my bean initialization fails.

I have looked up the tiles2.TilesConfigurer api, which now has the methods, setDefinitionsFactoryClass(..) and setPreparerFactoryClass(..). Not only I am unable to decide which one is relevant here, I can't find an equivalent class for org.apache.struts.tiles.xmlDefinition.I18nFactorySet. Is there something of this sort directly available in Tiles 2.2, or do I need to revisit some of my existing code with an equivalent that is available in Tiles 2.2?

Any pointer will be appreciated.

1

There are 1 best solutions below

0
On BEST ANSWER

A gentleman from the Tiles Community gave the solution. You may find the thread in Apache Tiles user list May 2012 archive. Cross posting it here:

The factoryClass org.apache.struts.tiles.xmlDefinition.I18nFactorySet is supported out of the box in Tiles 2.2. So, we don't need to inject anything special to the new tiles2.TilesConfigurer class. The final XML element will look like this

<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        <property name="definitions">
            <list>
                <value>/WEB-INF/tiles-defs.xml</value>
            </list>
        </property>
</bean>

So, removing the property does the trick.