tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Stefaniuk <daniel.stefan...@gmail.com>
Subject Multiple Tiles definitions within one application
Date Mon, 24 Jan 2011 11:05:14 GMT
Hi all

I'm trying to load multiple Tiles definitions within one application. My
problem is that the last definition overrides any previous one. Here is a
sample configuration.


<!-- WEB-INF/web.xml -->

<servlet>
    <servlet-name>app1-front-controller</servlet-name>

<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <init-param>
        <param-name>namespace</param-name>
        <param-value>app1/configs/front-controller-servlet</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>app1-front-controller</servlet-name>
    <url-pattern>/app1/*</url-pattern>
</servlet-mapping>
<servlet>
    <servlet-name>app2-front-controller</servlet-name>

<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
    <init-param>
        <param-name>namespace</param-name>
        <param-value>app2/configs/front-controller-servlet</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>app2-front-controller</servlet-name>
    <url-pattern>/app2/*</url-pattern>
</servlet-mapping>

<!-- WEB-INF/app1/configs/front-controller-servlet.xml -->

<bean class="app1.controller.AppController" />
<import resource="mvc.xml" />

<!-- WEB-INF/app2/configs/front-controller-servlet.xml -->

<bean class="app2.controller.AppController" />
<import resource="mvc.xml" />

<!-- WEB-INF/app1/configs/mvc.xml -->

<bean id="app1TilesViewResolver"
class="org.springframework.web.servlet.view.tiles2.TilesViewResolver">
    <property name="order" value="0" />
</bean>
<bean id="app1TilesConfigurer"
class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    <property name="definitions">
        <list>
            <value>/WEB-INF/app1/configs/tiles.xml</value>
        </list>
    </property>
</bean>
<mvc:annotation-driven />

<!-- WEB-INF/app2/configs/mvc.xml -->

<bean id="app2TilesViewResolver"
class="org.springframework.web.servlet.view.tiles2.TilesViewResolver">
    <property name="order" value="0" />
</bean>
<bean id="app2TilesConfigurer"
class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    <property name="definitions">
        <list>
            <value>/WEB-INF/app2/configs/tiles.xml</value>
        </list>
    </property>
</bean>
<mvc:annotation-driven />

<!-- WEB-INF/app1/configs/tiles.xml -->

<tiles-definitions>
    <definition name="app1.layout"
template="/WEB-INF/app1/layouts/application.jsp">
        <put-attribute name="title" value="Application 1" />
    </definition>
</tiles-definitions>

<!-- WEB-INF/app2/configs/tiles.xml -->

<tiles-definitions>
    <definition name="app2.layout"
template="/WEB-INF/app2/layouts/application.jsp">
        <put-attribute name="title" value="Application 2" />
    </definition>
</tiles-definitions>

In my controller I can access 'app2.layout' but trying to use 'app1.layout'
throws "javax.servlet.ServletException: Could not resolve view with name
'app1.layout' in servlet with name 'app1-front-controller'".

How can I solve this problem?

I posted exactly the same question at the Spring
Formu<http://forum.springsource.org/showthread.php?t=101828>.
I'm sorry if you consider it as a cross-posting but I'm new to the Spring
Framework and Tiles and not sure to which library the problem is related to.

Many thanks

Daniel Stefaniuk

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message