tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken McWilliams <ken.mcwilli...@gmail.com>
Subject Seeking Struts2 Tiles3 conventions plugin advice
Date Thu, 06 Dec 2012 07:49:13 GMT
Struts2 has a conventions plugin which I find very useful. Simply it
extracts a portion of the URL as a "namespace" and an "action".

Some basic background concerning rendering the result.
===============
If the url is http://contextroot/namespace/my-action

the namespace would be "/namespace" and the action would be "my-action"

By default conventions will look for a view called:
/WEB-INF/content/namespace/my-action.*

Where "*" may be of several types jsp, ftl, vm,...
===============
Now to the point, I want to integrate tiles3 into this flow.

So far I've got it so a definition called (namespace + "#" + action) is
sent to tiles. So I do have rudimentary integration.

IE:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD
Tiles Configuration 3.0//EN" "
http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>
    <definition name="/test"
template="/WEB-INF/content/template/template.jsp">
        <put-attribute name="head"
value="/WEB-INF/content/template/head.jsp"/>
        <put-attribute name="header"
value="/WEB-INF/content/template/header.jsp"/>
        <put-attribute name="body"
value="/WEB-INF/content/template/body.jsp"/>
        <put-attribute name="footer"
value="/WEB-INF/content/template/footer.jsp"/>
    </definition>
    <definition name="REGEXP:(.*)#(.*)"  extends="/test">
        <put-attribute name="body" value="/WEB-INF/content{1}/{2}"/>
    </definition>
</tiles-definitions>

So, does anyone have any ideas on how templates should be determined, if we
are going to try and apply conventions to tiles?

What are some good practices that you think people should follow?

Here are some ideas for rules:
- at startup /WEB-INF/content is searched for files called template.* or
maybe tiles-template.* if found a definition is created with the name of
that namespace ("/" if at the base)
- all namespaces will have an associated tiles definition, where if a
definition is not explicitly created from a template, it will inherit from
the definition of the first template up the hierarchy.
- packages will be searched for tiles-* files if a files is found not
called tiles-template but rather tiles-footer.jsp for example, the
definition for the package will be given a put attribute with the name
"footer" and provided a value pointing at the tiles-body.jsp file.
- body content will be assumed to be the action name and the file type will
be assumed to be (a user defined parameter)

This is only an example.

Struts2 aside, if you were to generate definitions from a url and content
layout what scheme would you use?

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message