You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Ken McWilliams <ke...@gmail.com> on 2013/01/30 06:22:10 UTC

Facilitating widgets in tiles

For lack of a better term I've got various user defined form controls. That
are made up of HTML, CSS and JS.

My main tiles definition is like so:

    <definition name="REGEXP:(.*)#(.*)"  extends="default">
        <put-attribute name="body" value="/WEB-INF/content{1}/{2}"/>
    </definition>

All the definitions are of the form /namespace#something.jsp

default is defined as:

    <definition name="default" template="/WEB-INF/template/template.jsp">
        <put-list-attribute name="cssList" cascade="true">
            <add-attribute value="/style/cssbase-min.css" />
            <add-attribute value="/style/cssfonts-min.css" />
            <add-attribute value="/style/cssreset-min.css" />
            <add-attribute value="/style/grids-min.css" />
            <add-attribute
value="/script/jquery-ui-1.8.24.custom/css/ui-lightness/jquery-ui-1.8.24.custom.css"
/>
            <add-attribute value="/style/style.css" />
        </put-list-attribute>
        <put-list-attribute name="jsList" cascade="true">
            <add-attribute value="/script/jquery/1.8.1/jquery.min.js" />
            <add-attribute
value="/script/jquery-ui-1.8.24.custom/js/jquery-ui-1.8.24.custom.min.js" />
            <add-attribute value="/script/jquery.sort.js" />
        </put-list-attribute>
        <put-attribute name="head" value="/WEB-INF/template/head.jsp"/>
        <put-attribute name="header" value="/WEB-INF/template/header.jsp"/>
        <put-attribute name="body" value="/WEB-INF/template/body.jsp"/>
        <put-attribute name="footer" value="/WEB-INF/template/footer.jsp"/>
    </definition>


This all works how I expect but I'd like to be able to somehow be able to
add these widgets to the pages...

My first attempt was to make a more specific definition like so:

    <definition name="REGEXP:\/recruiter#candidate-input\.(.*)"
extends="default">
        <put-list-attribute name="cssList" cascade="true" inherit="true">
            <add-attribute value="/style/recruiter/candidate-input.css" />
        </put-list-attribute>
        <put-list-attribute name="jsList" cascade="true" inherit="true">
            <add-attribute value="/script/widgets/resume/resume.js" />
        </put-list-attribute>
        <put-attribute name="body"
value="/WEB-INF/content/recruiter/candidate-input.jsp"/>
    </definition>

This works but it is quite verbose and defeats my attempt at a conventions
driven approach.

What I ideally need is for tiles to know that if it needs to render a tile
that that tile will result in wanting to use several widgets, and then
_before_ rendering the tile add the required attributes to cssList and
jsList respectively.


To enable such a feature seems like a lot of work because it will mean
storing the templates in a database such that when the templates are saved
they are scanned for widgets and I can keep track of dependencies such that
a preparer would then be able to act accordingly.

That is my understanding. I'm asking here in the hope that there may be an
easier way.