tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Petrelli <antonio.petre...@gmail.com>
Subject Re: change content in one Tile for one page only?
Date Mon, 23 Jan 2012 12:40:14 GMT
2012/1/23 MiB <digital.discuss@gmail.com>

> So I'd like to be able to change 1 above to other values per the current
> view for the script attribute "src" or omit it totally and also in 2 above
> change the attribute value "id" in the body element. I suppose I could make
> an alternative tile and swap the this for the views where I need this, but
> then I'd need one for every page, which seems over the top and clumsy.

You can use Tiles attributes even as simple value holders. In your case,
think about having a list of scripts to load. In your template page do:

<tiles:importAttribute name="scripts" />
<c:forEach var="scriptAttribute" items="${scripts}" />
  <script src="${scriptAttribute.value}" type="text/javascript"></**script>

And in your definition:

<definition name="...">
    <add-attribute value="script1.js" />
    <add-attribute value="script2.js" />

See more here:
About the id of the body, it is even simpler, simply use an attribute of
type "string" and import it in your layout page with
<tiles:importAttribute> and use it as a normal bean in page scope.

On 3 above I'd like to change the class attribute on list items based on
> the current view. I suppose it's a similar solution like for the previous I
> need here, and also in this case what I need to affect is inside a tile and
> as with the previous 1 I'd like to avoid making one big tile per view.

You can apply the same suggestions I gave you above. Moreover, you might be
interested in the View Preparer:


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