answered
2014-07-27 12:35:28 +0800
chillworld
5357 ● 4 ● 9
https://github.com/chillw...
Maybe you could use the if (or the visible attribute)?
<cell>
<label value="@load(each.prop)" if="@load(not each.withLink)"/>
<a href="..." if="@load(each.withLink)">
<label value="@load(each.prop)" />
</a>
</cell>
So the each should give a boolean back with the property "withLink".
Edit :
After reading your 2 comments :
1) You don't have to use each.withLink
, but I don't see the difference between ="@load(each.test() ? 'X' : 'Y')"
or use the visible attribute.
2) The if
can work but indeed you don't have to use @load but :
<label value="@load(each.prop)" if="${not each.withLink}"/>
3) Other (proper) solution :
Create a Taglib (here I call it 'mine-taglib.tld')
<taglib>
<function>
<name>instanceXX</name>
<function-class>be.chillworld.utils.ZkUtils</function-class>
<function-signature>
java.lang.Boolean checkInstanceXX(java.lang.Object)
</function-signature>
<description>Checks for a specific instance</description>
</function>
</taglib>
Create java class :
public class ZkUtils {
public static Boolean checkInstanceXX(Object o) {
return (o instanceof AtomicInteger);
}
}
Zul :
<?taglib uri="/WEB-INF/tld/mine-taglib.tld" prefix="mt"?>
.....
<cell>
<label value="@load(each.prop)" visible="@load(not mt:checkInstanceXX(each))"/>
<a href="..." visible="@load(not mt:checkInstanceXX(each))">
<label value="@load(each.prop)" />
</a>
</cell>
Greetz chill.
how do he decide what template to choose?
chillworld ( 2014-07-27 19:58:22 +0800 )editBy everthing the EL allows, for ex. ="@load(each.test() ? 'X' : 'Y')" or "@load(each.template)".
aznavour ( 2014-07-28 10:51:53 +0800 )edithi Charles, I think "if" will work if the entity won't become to linkable by some interaction. Or I think using visible attribute is a feasible solution.
vincentjian ( 2014-07-31 04:41:53 +0800 )edit