2012/1/23 MiB <[email protected]>
> 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:
<snip>
<tiles:importAttribute name="scripts" />
<c:forEach var="scriptAttribute" items="${scripts}" />
<script src="${scriptAttribute.value}" type="text/javascript"></**script>
</c:forEach>
</snip>
And in your definition:
<definition name="...">
<put-list-attribute>
<add-attribute value="script1.js" />
<add-attribute value="script2.js" />
</put-list-attribute>
</definition>
See more here:
http://tiles.apache.org/2.2/framework/tutorial/advanced/list-attributes.html
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:
http://tiles.apache.org/2.2/framework/tutorial/advanced/preparer.html
HTH
Antonio