Concatenating attribute values in a label

asked 2010-02-24 04:21:09 +0800

TOtte gravatar image TOtte
93 2

updated 2010-02-24 04:21:57 +0800

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>

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?

Thanks for your help!

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2010-02-25 05:25:14 +0800

TOtte gravatar image TOtte
93 2

anybody got an idea?

link publish delete flag offensive edit

answered 2010-03-12 05:46:43 +0800

TOtte gravatar image 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.

link publish delete flag offensive edit

answered 2010-03-12 07:10:46 +0800

caclark gravatar image caclark
1753 2 5

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>

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)

link publish delete flag offensive edit

answered 2010-03-15 02:19:03 +0800

TOtte gravatar image TOtte
93 2

Thank you clark!

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2010-02-24 04:21:09 +0800

Seen: 291 times

Last updated: Mar 15 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More