# Concatenating attribute values in a label

TOtte
93 2

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}"
, but in that case only string2 was shown.
Does anybody know the right syntax to show both of the strings seperated by a whitespace in the lablel?

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?

delete retag edit

## 4 Replies

TOtte
93 2

anybody got an idea?

TOtte
93 2

I still don't have a sulution to this. I just want to show two attributes in the same label attribute. Somebody enlighten me please.

caclark
1753 2 5
http://clarktrips.intltwi...

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)

TOtte
93 2

Thank you clark!

[hide preview]