Announcement Announcement Module
Collapse
No announcement yet.
Multiple Tiles definitions within one application. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple Tiles definitions within one application.

    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.

    HTML Code:
    <!-- 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?
Working...
X