Em Mon, 06 Oct 2008 11:01:34 -0300, Russell Brown <[EMAIL PROTECTED]>
escreveu:
In jsp
<c:forEach items="${someList}" var="myItem"
varStatus="counter">
<c:if test="${!empty someVar}">
<somemarkup attr="$someVar}"/>
</c:if>
<someothermarkup/>
<c:set var="someVar" value="${myItem.myProperty}"/>
</c:forEach>
You don't need to create a component from that, just stop thinking JSP
when coding Tapestry. :)
In Tapestry, all the logic is implemented in pages classes, with no logic
in templates. And this is a very good thing, as the logic is easily tested
when implemented in classes. ;)
Not tested, but hopefully it will give you an idea on how to do that:
YourClass.java:
private ItemType item;
@Property /* so we don't need to provide the getter and setter, as they
don't have any logic */
private ItemType lastItem;
public ItemType getItem() {
return item;
}
public void ItemType setItem(ItemType item) {
lastItem = this.item;
this.item = item;
}
public List getList() {
return ...; // list to be iterated
}
public boolean isNotEmpty() {
return lastItem != null; // or any other logic
}
YourTemplate.tml:
<t:loop source="list" value="item">
<t:if test="notEmpty">
<somemarkup attr="${lastItem.myProperty}"/>
</t:if>
<someothermarkup/>
</t:loop>
If you don't get it, tell us. :)
--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
Consultor, desenvolvedor e instrutor em Java
http://www.arsmachina.com.br/thiago
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]