-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I am trying to apply the reference binding feature to this page of the zktodo2 demo app supervisingcontroller.zul
In that page the viewmodel is called "c" but all the data is in "c.model". So I want to do something like
<window apply="org.zkoss.bind.BindComposer" viewModel="@id('c') @init('org.zkforge.zktodo2.ui.Controller')"> <vlayout bm="@ref(c.model)"> <listbox model="@load(bm.reminders)" selectedItem="@bind(bm.selectedReminder)">
in that I am trying to @ref the "c.model" to the property "bm" then use "bm.reminders" and "bm.selectedReminder" to draw the page. I cannot get this to work with the current version of the sample code. What is the correct way to use @ref in this example?
Thanks,
Simon
Hi Simon,
I checked your source code from git repository. And here is my sample code modified from your origin code that works fine.
zul page:
<window title="ZkTodo2 - Supervising Controller" width="640px" border="normal" apply="org.zkoss.bind.BindComposer" viewModel="@id('c') @init('forum.ControllerVM')"> <vlayout bm="@ref(c.model)"> <listbox model="@bind(bm.reminders)" selectedItem="@bind(bm.selectedReminder)">
public class ControllerVM { // wired property @WireVariable Model model = null; public void setModel(Model model) { this.model = model; } public Model getModel() { return model; } @Init public void init(@ContextParam(ContextType.VIEW) Component view){ Selectors.wireComponents(view, this, false); model = new Model(); reload(); } protected void reload() { List<Reminder> reminders = new ArrayList<Reminder>(); reminders.add(new Reminder("event1", 2, new Date())); reminders.add(new Reminder("event2", 1, new Date())); reminders.add(new Reminder("event3", 3, new Date())); reminders.add(new Reminder("event4", 1, new Date())); reminders.add(new Reminder("event5", 4, new Date())); this.model.getReminders().clear(); this.model.getReminders().addAll(reminders); }
Using your example I get the following error:
org.zkoss.zk.ui.UiException: ref binding handler is not supported in current runtime.
at org.zkoss.bind.impl.BinderImpl.addReferenceBinding0(BinderImpl.java:1086)
at org.zkoss.bind.impl.BinderImpl.addReferenceBinding(BinderImpl.java:1074)
at org.zkoss.bind.impl.AnnotateBinderHelper.processReferenceBinding(AnnotateBinderHelper.java:229)
at org.zkoss.bind.impl.AnnotateBinderHelper.processPropertyBindings(AnnotateBinderHelper.java:201)
at org.zkoss.bind.impl.AnnotateBinderHelper.processComponentBindings0(AnnotateBinderHelper.java:103)
at org.zkoss.bind.impl.AnnotateBinderHelper.processAllComponentsBindings(AnnotateBinderHelper.java:78)
at org.zkoss.bind.impl.AnnotateBinderHelper.processAllComponentsBindings(AnnotateBinderHelper.java:81)
at org.zkoss.bind.impl.AnnotateBinderHelper.initComponentBindings(AnnotateBinderHelper.java:68)
at org.zkoss.bind.AnnotateBinder.init(AnnotateBinder.java:49)
at org.zkoss.bind.BindComposer.doAfterCompose(BindComposer.java:136)
I am running as "mvn jetty:run" on Mac OS Lion using
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04-415-11M3646)
Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01-415, mixed mode)
and maven3.0.3.
I have committed your sample code which shows my error as test.zul
Hi, Simon
@ref is new in zk 6.0.1 and you need PE(or EE) version to use @ref feature.
/Dennis
Asked: 2012-05-07 14:01:18 +0800
Seen: 318 times
Last updated: May 14 '12