You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Rick Mangi <Ri...@nick.com> on 2008/08/08 17:59:49 UTC

Two-phase rendering?

Hello list!

This is something that I was looking for in the previous version of tiles
and I know there was some thought about it then.

Basically what I would like is for the ability to do a two-phase rendering,
the idea is that sometimes an enclosed tile has a dependency on a css or js
file that should be put in the head. So I have head tiles for js includes
and css includes that use a list-attribute. I'd like to be able to append to
that list from an included tile farther down the tree. The idea would be
something like this:

<definition name="js-tile" template="/WEB-INF/tiles/fragments/jstile.jsp">

    <put-list-attribute name="js_files">

     <add-attribute value="/js/prototype.js"/>

     <add-attribute value="/js/common.js" />

     <add-attribute value="/js/messages.js" />

     <add-attribute value="/js/mousePos.js"/>
    </put-list-attribute>
</definition>


<definition name="my-other-tile">
    <put-list-attribute name="js_files">
        <add-attribute value="/js/myotherjs.js"/>
    </put-list-attribute>
</definition>


I could see how this could be expanded to maybe use an
<append-list-attribute> tag instead to be more explicit.

Is there a way to do this in code if not in the tiles.xml?

Thanks,

Rick



Re: Two-phase rendering?

Posted by Greg Reddin <gr...@gmail.com>.
On Fri, Aug 8, 2008 at 10:59 AM, Rick Mangi <Ri...@nick.com> wrote:
>
> The idea would be something like this:
>
> <definition name="js-tile" template="/WEB-INF/tiles/fragments/jstile.jsp">
>
>    <put-list-attribute name="js_files">
>
>     <add-attribute value="/js/prototype.js"/>
>
>     <add-attribute value="/js/common.js" />
>
>     <add-attribute value="/js/messages.js" />
>
>     <add-attribute value="/js/mousePos.js"/>
>    </put-list-attribute>
> </definition>
>
>
> <definition name="my-other-tile">
>    <put-list-attribute name="js_files">
>        <add-attribute value="/js/myotherjs.js"/>
>    </put-list-attribute>
> </definition>
>
>
> I could see how this could be expanded to maybe use an
> <append-list-attribute> tag instead to be more explicit.
>
> Is there a way to do this in code if not in the tiles.xml?

Just a sanity check: have you tried it? I'm not sure if extended
<put-list-attribute> tags are "additive" or not - meaning I'm not sure
if things added in extended <put-list-attribute> tags are added to the
original list or if the extended list replaces the original. If it
doesn't work one thing you could try is creating a placeholder list in
the master tile and putting attributes in it in the child tile. For
example:

<definition name="js-tile" template="/WEB-INF/tiles/fragments/jstile.jsp">
   <put-list-attribute name="js_files">
      <add-attribute value="/js/prototype.js"/>
      <add-attribute value="/js/common.js" />
      <add-attribute value="/js/messages.js" />
      <add-attribute value="/js/mousePos.js"/>
   </put-list-attribute>
   <put-list-attribute name="js_extended"/>
</definition>

<definition name="my-other-tile">
   <put-list-attribute name="js_extended">
       <add-attribute value="/js/myotherjs.js"/>
   </put-list-attribute>
</definition>

Then in your template you would need to reference both the "js_files"
and "js_extended" attributes.

Greg

Re: Two-phase rendering?

Posted by Antonio Petrelli <an...@gmail.com>.
2008/8/8 Rick Mangi <Ri...@nick.com>:
> <definition name="my-other-tile">
>    <put-list-attribute name="js_files">
>        <add-attribute value="/js/myotherjs.js"/>
>    </put-list-attribute>
> </definition>

<add-attribute> is not additive in Tiles 2.0.x, but in Tiles 2.1.0 you
can make it additive this way (notice the "inherit" attribute):

    <put-list-attribute name="js_files" inherit="true">
       <add-attribute value="/js/myotherjs.js"/>
    </put-list-attribute>

HTH
Antonio