Doubt when overwriting attribute with Apache Tiles

Asked

Viewed 40 times

1

I am studying a little about Tiles and I have a question. I have the following definition:

<definition name="main" template="/views/templates/main.jsp">
    <put-attribute name="titulo" value="##" />
    <put-attribute name="header">
        <definition template="/views/templates/header.jsp">
            <put-attribute name="first" value="/views/menu/first.jsp" />
            <put-attribute name="second" value="/views/menu/second.jsp" />
        </definition>
    </put-attribute>
    <put-attribute name="footer" value="/views/templates/footer.jsp" />
</definition>

I’m making a template for a crud screen, in which this screen will be composed of 2 panels. One with search fields and one with a table of results. But the search form and the results will be different for each screen obviously, so I would like to overwrite the attributes search-fields and result-table on pages extending this definition.

For this I created the following definition:

<definition name="crud" extends="main">
    <put-attribute name="content" >
        <definition template="/views/templates/crud-page.jsp">
            <put-attribute name="search-fields" value="override" />
            <put-attribute name="result-table" value="override" />
        </definition>
    </put-attribute>
</definition>

Once this template was set, I tried to create a page that would use this template as follows:

<definition name="crud-users" extends="crud">
    <put-attribute name="search-fields" value="/views/crud/usuario/search.jsp" />
    <put-attribute name="result-table" value="/views/crud/usuario/result-table.jsp"/>
</definition>

Look at the . jsp files -

main.jsp:

<body>
    <tiles:insertAttribute name="header" />
    <main>
        <tiles:insertAttribute name="content" />    
    </main>
    <tiles:insertAttribute name="footer" /> 
</body>

crud-page.jsp:

<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:insertAttribute name="search-fields" />
<tiles:insertAttribute name="result-table" />

But what appears on the screen is "override" and not the content of the pages I have overwritten. How to proceed in such cases? What mistake am I making?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.