-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
This might be pretty easy, but I haven't been able to figure out the right syntax and couldn't find a fitting example anywhere.
Lets say I have an object that has the attributes string1 and string2.
What i want to do is something like this: The important part is label="..."
<combobox id="combobox" readonly="true" model="@{controller.getAllObjects}"> <comboitem self="@{each=object}" label="@{object.string1 + object.string2}" value="@{object}"></comboitem> </combobox>
I tried different approaches like
label="@{object.string1} @{object.string2}"
A little bit offtopic: In the developers guide about ZK Expression Language the $ is used, but I have always used the @ and it worked well for me so far. Is there any case when I have to used the $ instead of the @? Maybe if I used zscript instead of java classes?
Thanks for your help!
First, you cannot use databinding to perform operations like that. What I have to do is put a convenience method on my domain object and access that. It's usually something that makes sense, anyway, so it's not a big deal, e.g. a full name composed of first + mi + last. So, I end up with zul that looks like this:
<combobox id="combobox" readonly="true" model="@{controller.allPeople}"> <comboitem self="@{each=person}" label="@{person.fullName}" value="@{person}"></comboitem> </combobox>
Second, the difference in the $ and @ is simple: $ is EL while @ is databinding. They're processed at different times. EL is evaluated in component creation and rendering phases ONE time while databinding is later and can be reevaluated using the binder. Take a look at these pages for some more explanation: http://docs.zkoss.org/wiki/Component_lifecycle and http://docs.zkoss.org/wiki/Basic_concepts#Architecture_Overview (Execution Flow and The Lifecycle of Loading Pages sections)
Asked: 2010-02-24 04:21:09 +0800
Seen: 296 times
Last updated: Mar 15 '10