2009/10/19 excurser <[email protected]>:
> On Thu, Oct 15, 2009 at 3:05 AM, Antonio Petrelli
>> In fact there is another option.
>> Instead of putting a simple JSP as an attribute, put a definition that
>> inserts a list of attributes, as mentioned in the previous e-mail.
>> Do you think it is "elegant" enough? :-D
>
> Sorry for the late reply. I'm not sure how your suggested solution
> would look like. Could you give me an example? My goal is to have a
> "universal" way to inherit and extend the value/content of an existing
> attribute.
Starting from your original idea:
<tiles:insertDefinition name="test.definition">
<tiles:putAttribute name="body" inherit=”true”>
<div>This text gets appended to the initial content of the body
attribute</div>
</tiles:putAttribute>
</tiles:insertDefinition>
It could be accomplished with this:
<tiles:insertDefinition name="test.definition">
<tiles:putAttribute name="body">
<tiles:definition template="/layout/listTemplate.jsp">
<tiles:putListAttribute name="list">
<tiles:addAttribute value="/firstElement.jsp" />
<tiles:addAttribute value="/firstElement.jsp" />
</tiles:putListAttribute>
</tiles:definition>
</tiles:putListAttribute>
</tiles:insertDefinition>
Then "listTemplate.jsp" has:
<tiles:importAttribute name="list" />
<c:forEach var="attribute" items="${list}">
<tiles:insertAttribute value="${attribute}" />
</c:forEach>
So you create an inline definition to be used as an attribute, and
this one iterates an attribute list.
Antonio