-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I have general problem when entity is bound to a detail view.
Let say that I have Partner entity (Loaded with Spring Data JPA) and it's bound in following way to some detail view.
public class City {
private name;
// ... get/set
}
public class Partner {
private String name;
private String address;
private City city;
// .. get/set
}
public class PartnerViewModel {
private Partner item;
// get/set ...
}
<grid>
<rows>
<row>
<label value="Name:"/>
<textbox value="@bind(vm.item.name)" />
</row>
<row>
<label value="Address:"/>
<textbox value="@bind(vm.item.address)" />
</row>
<rows>
<label value="City:"/>
<combobox model="@load(vm.cities)" selectedItem="@bind(vm.item.city)" />
</row>
</ros>
</grid>
When the value of name textbox is changed, and focus is sent to some other control, OnChange event is fired and a org.zkoss.zel.PropertyNotFoundException is thrown. For example "Property 'name' not found on type 'City'"
After few debuging sessions I have found that problem might be in the following code in fajl BindELResolver.java.
//save value into equal beans
private void saveEqualBeans(ELContext elCtx, Object base, String prop, Object value) {
final BindELContext ctx = (BindELContext)((EvaluationContext)elCtx).getELContext();
final BindContext bctx = (BindContext) ctx.getAttribute(BinderImpl.BINDCTX);
if (bctx.getAttribute(BinderImpl.SAVE_BASE) != null) { //recursive back, return
return;
}
ctx.setAttribute(BinderImpl.SAVE_BASE, Boolean.TRUE);
try {
final Binder binder = bctx.getBinder();
final TrackerImpl tracker = (TrackerImpl) ((BinderCtrl)binder).getTracker();
final Set<Object> beans = tracker.getEqualBeans(base);
beans.remove(base); // POSSIBLE PROBLEM
for (Object candidate : beans) {
super.setValue(elCtx, candidate, prop, value); //might recursive back
}
} finally {
ctx.setAttribute(BinderImpl.SAVE_BASE, null);
}
}
When method is entered, "base" is "Partner", "prop" is "name", but "base" is removed from "beans" candidates set, so it will never be found.
Posible solution is to make ViewModel adapter methods:
public String getName() {
return this.item.getName();
}
public void setName(String name) {
this.item.setName(name);
}
And to bind to the vm.name instead of vm.item.name, but it's time consuming.
I there any other solutions?
A have also found this code in BindEvaluatorXImpl.java
public void setValue(BindContext ctx, Component comp, ExpressionX expression, Object value)
throws XelException {
//ZK-1063 No exception if binding to a non-existed property
//Dennis, Removed the try-catch PropertyNotFoundException, we don't have history to check why we did try-catch before
//However, it should throw the property-not-found to let user be aware it.
expression.setValue(newXelContext(ctx, comp), value);
}
Maybe because of this problem that I have stated there was PropertyNotFoundException try-catch.
I have the same problem, someone knows what is happening, copy all the code of another project that works if it works and it still does not work.
tengo el mismo problema, alguien sabe qe es lo qe pasa?, copie todo el codigo de otro proyecto qe si funciona en este y aun no funciona.
I'm facing the same problem here. Strangely it doesnt reproduce with other codes. My other codes works fine, except for this one. I tried, but i cant find out why its happening only in this particular code.
Asked: 2013-07-08 13:01:39 +0800
Seen: 111 times
Last updated: Nov 28 '17
Editable interface to add users
Problem binding values to a composite component
How can i load a constant in .zul
MVVM Validator: class not found ? [closed]
[Ugent please] connect Web service .net view in grid group ZK
Dirty state for forms with collection properties
It sounds like a bug, could you post to tracker http://tracker.zkoss.org/secure/Dashboard.jspa and provide the reproducible case(and code), thanks.
dennis ( 2013-07-09 02:03:02 +0800 )editUnfortunately I can't submit my project code, when I try to reproduce this problem with some simple example everything is working just fine. I suppose, that problem might be somewhere in my code.
miks ( 2013-07-09 10:49:45 +0800 )edit