-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I'm just getting started with zk and am enjoying it so far. I have a question about the CRUD sample. Here is a snippet of the .zul from the example:
...
<listbox id="personslb" rows="10" model="@{mainCtrl.model}"
selectedItem="@{mainCtrl.selected}">
<listhead>
<listheader label="Name"/>
<listheader label="Title"/>
</listhead>
<listitem self="@{each=person}">
<listcell label="@{person.name}" />
<listcell label="@{person.title}" />
</listitem>
</listbox>
...
Is there an easy way to combine values that are returned from the @{} databinding expressions? For example, if I wanted the first column of the table to contain the person's name *and* title, I wish I could just do this:
<listcell label="@{person.name} @{person.title}" />
Since that doesn't work, what's the next best way? Do I have to use a renderer?
Thanks!
Jeff
I would use a converter.
Something like the following should work:
public Object coerceToUi(Object val, Component comp) {
if (val instanceof Person) {
Person person = (Person) val;
return person.getName() + " " + person.getTitle();
}
return val;
}
the corresponding label should look like that:
label="@{person, converter='your.package.name.PersonNameTitleConverter'}"
Hope this helps.
Asked: 2010-07-30 17:46:08 +0800
Seen: 569 times
Last updated: Nov 14