0

Concatenate @databinding expressions

asked 2009-06-23 12:45:38 +0800

billjakarta gravatar image billjakarta
21

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?

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2009-06-23 14:19:08 +0800

deved gravatar image deved
114 1

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;
  }

In the zul page:
<label value="@{subscriber}, converter='SubscriberConverter'"/>

Regards,

edgar

link publish delete flag offensive edit

answered 2009-06-23 23:32:30 +0800

billjakarta gravatar image billjakarta
21

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

link publish delete flag offensive edit

answered 2009-06-24 12:49:23 +0800

edudant gravatar image edudant
219 1 1 1
zk.datalite.cz

It is not possible. Binding is not Expression Language and after parsing it stores one object per component (for set/get).

link publish delete flag offensive edit

answered 2015-05-26 12:32:05 +0800

WilliamB gravatar image WilliamB
1609 1 6

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

link publish delete flag offensive edit

answered 2023-11-14 02:54:06 +0800

chemFelix gravatar image chemFelix
0

Nowadays, you can do this with pure EL, see books.zkoss.org/zk-mvvm-book/8.0/databinding/elexpression.html#el-30-support

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

Follow

RSS

Stats

Asked: 2009-06-23 12:45:38 +0800

Seen: 718 times

Last updated: Nov 14 '23

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