-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I want to concatenate @databinding expressions like you can with the ${ type expressions. This works:
<label value="${each.title} ${each.firstname} ${each.lastname}" />
This does not:
<label value="@{subscriber.title} @{subscriber.firstname} @{subscriber.lastname}" />
The data binding works because this does:
<label value="@{subscriber.lastname}" />
Is this possible?
Hi,
You have to create your own converter (org.zkoss.zkplus.databind.TypeConverter) and implement the coerceToUi method:
SubscriberConverter.java:
coerceToUi(java.lang.Object bean, org.zkoss.zk.ui.Component component) { Subscriber s = (Subscriber ) bean; return s.title + " " + s.firstname + " " + s.lastname; }
<label value="@{subscriber}, converter='SubscriberConverter'"/>
Regards,
edgar
I guess I already knew you could do it by reverting to java. You could also add a fullname read only attribute to the subscriber bean and concatenate in the getter. But I was really asking if there is a way to do this in zul.
Bill
It is not possible. Binding is not Expression Language and after parsing it stores one object per component (for set/get).
To do this, i went with an AbstractViewModel that contains all those "technical" methods i would like to use in my Zul.
Then i make every of my Viewmodel extends this abstractViewModel
public class AbstractTechnicalViewModel {
/** @see java.text.MessageFormat#format(String, Object...) */
public String format(final String pPattern, final Object... pParams) {
return MessageFormat.format(pPattern, pParams);
}
/** @see org.apache.commons.lang.StringUtils#concatenate(Object[]) */
public String concat(final Object... pParams) {
return StringUtils.join(pParams);
}
}
And then in my zul
tooltiptext="${vm.format(labels.my.label, param1)}"
Regards
Asked: 2009-06-23 12:45:38 +0800
Seen: 717 times
Last updated: Nov 14