tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric B <ebe...@hotmail.com>
Subject Cascading preference when a view name matches several templates
Date Tue, 29 Oct 2013 15:45:55 GMT
Given multiple definitions in the tiles.xml file or tiles*.xml files that may be scattered
throughout the classpath, how does tiles.xml decide which 
definition(s) to use?

For example, given the following view name:

	@RequestMapping(value = "/login", method = RequestMethod.GET)
	public String login(ModelMap model) {
		return "secure/login";
	}


and the following tiles*.xml files:


tiles.xml
<tiles-definitions>

<definition name="REGEXP:([^.]+)" template="/WEB-INF/views/tiles/layouts/default.jsp">
     <put-attribute name="meta" value="/WEB-INF/views/tiles/{options[defaultPaths]}/meta.jsp"/>
     <put-attribute name="head" value="/WEB-INF/views/tiles/{options[defaultPaths]}/head.jsp"/>
     <put-attribute name="header" value="/WEB-INF/views/tiles/{options[defaultPaths]}/header.jsp"/>
     <put-attribute name="menu" value="/WEB-INF/views/tiles/{options[defaultPaths]}/menu.jsp"/>
     <put-attribute name="body" value="/WEB-INF/views/tiles/{options[defaultPaths]}/body.jsp"/>
     <put-attribute name="footer" value="/WEB-INF/views/tiles/{options[defaultPaths]}/footer.jsp"/>

	<put-list-attribute name="defaultPaths" cascade="true" >
		<add-attribute value="{1}"/>
		<add-attribute value="common"/>
	</put-list-attribute>
</definition>


<definition name="REGEXP:secure/(.*)" template="/WEB-INF/views/tiles/layouts/secure.jsp">
     <put-attribute name="body" value="/WEB-INF/views/tiles/secure/{1}/body.jsp"/>
</definition>

</tiles-definitions>


tiles-login.xml:


<tiles-definitions>
<definition name="secure/login" template="/WEB-INF/views/tiles/secure/layout/secure.jsp">
     <put-attribute name="body" value="/WEB-INF/views/tiles/secure/login/body.jsp"/>
     <put-attribute name="captcha" value="/WEB-INF/views/tiles/secure/login/captcha.jsp"/>
</definition>

</tiles-definitions>



How does tiles know which definition to use?  Is there a precedence order?  Is it based on
the order in which the tile*.xml files are registered/loaded?

Thanks,

Eric



Mime
View raw message