java - Apache Tiles 2 : Set attribute value in child definition rendered ny parent definition template -


i want display <title> elements proper values in html pages. have 1 base layout jsp , corresponding tiles definition. i'd set value of <title> tag on per page basis, possibly in tile definition xml.

so far have following

tiles.xml:

<definition name="base" template="/web-inf/jsp/layouts/base.jsp">     <put-attribute name="page-title" value="" /> </definition>  <definition name="home" extends="base">     <put-attribute name="page-title" value="homepage" /> </definition> 

base.jsp:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%> <!doctype html> <html> <head>     <meta http-equiv="content-type" content="text/html; charset=utf-8">     <title><tiles:insertattribute name="title" ignore="true" /></title>      ... 

the title attribute set in home definition not displayed. why not? correct way this?

you're using tiles attribute "page-title" string, while default behaviour treat template (and template can't found , you've chosen ignore failure).

either declare attribute type="string", eg

<definition name="base" template="/web-inf/jsp/layouts/base.jsp">     <put-attribute name="page-title" value="" type="string"/> </definition>  <definition name="home" extends="base">     <put-attribute name="page-title" value="homepage" type="string" /> </definition> 

or explicitly use attribute string, eg

<tiles:getasstring name="title" /> 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -