tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From duvduv <duv...@gmail.com>
Subject Partial include with Tiles
Date Sat, 09 Jul 2011 08:34:46 GMT
Hey all,

I'm new to Tiles and I'm having a bit of a difficulty maintaining a
large set of views. Maybe someone can tell me what I'm doing wrong/how
can I do it better.

I'm developing a webapp with many views, all of these are composed
around a single template. The template has about three or four
"placeholders" (attributes), and for each view, different, dynamically
generated content (JSP for that matter) should be placed in the
correct placeholder.

When I define a new view with Tiles I need to create multiple JSP file
- each with a placeholder's content. Then I need to update a huge XML
definition file that has a lot of entries that look just the same, and
a similar properties file (I'm working with Spring's
ResourceBundleViewResolver but that's not the main issue).

I'm looking for a solution that'll allow me to declare all these
placeholder's content in the same file, and partially include this
file into the template (every fragment to its placeholder).

For example, I might be having this as template.jsp:

    [...]
    <html>
    <head> [...] </head>
    <body>
    <div class="head">
        <tiles:insertAttribute name="head" />
    </div>
    <div class="body">
        <tiles:insertAttribute name="body" />
    </div>

Then I'll define the following tiles:

    <definition name="template" template="/WEB-INF/views/template.jsp" />
    <definition name="someView" extends="template">
        [something that points Tiles to someView.jsp - maybe it can
infer the file's name from the definition's name]
    </definition>

Then having someView.jsp as follows:

    <tiles:putAttribute name="head">
        <!-- This will be evaluated as JSP content -->
        <h1>Here's the title</h1>
    </tiles:putAttribute>
    <tiles:putAttribute name="body">
        <p>And here's the body...</p>
    </tiles:putAttribute>

Instead of having someView_head.jsp and someView_body.jsp each with a
single line.

Am I doing it all wrong? Is there another way I'm not aware of?

Thanks!

- Itay

Mime
View raw message