views:

945

answers:

1

Hi Gurus,

I am using tiles 2.0.6 as my template framework together with struts 2.1.6. I am writing a simple cms page and want to let the user to define the title of each html page.

I have a title definition like this

    <definition name="base" template="/WEB-INF/jsp/templates/base.jsp">
        <put-attribute name="title" value=" "/>
        <put-attribute name="header" value="/WEB-INF/jsp/templates/header.jsp"/>  
        <put-attribute name="content" value="dummy"/>
        <put-attribute name="footer" value="/WEB-INF/jsp/templates/footer.jsp"/>   
        <put-attribute name="search" value="/WEB-INF/jsp/search.jsp"/>
    </definition>    
    <definition name="staticview" extends="base">
        <put-attribute name="title" value=" - Static"/>
        <put-attribute name="content" value="/WEB-INF/jsp/static/view.jsp"/>
    </definition>

Instead of making the title a jsp, is there a way to dynamically override the title (String) on my header.jsp in the later jsp attribute, for example view.jsp. Or even 1 step further using EL

<put-attribute name="title" value="%{title}"/>

and have it pick up the title on the struts ognl dynamically.

Please advise

Thanks in advance

A: 

I add the title to the request in the action class, here's my JSP code for the template (tiles 1):

<title>
    <tiles:getAsString name="title"/>
    <%-- add additional title (if found) --%>
    <logic:present scope="request" name="title"><bean:write scope="request" name="title"/></logic:present>
</title>
Pool