-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Are ordinary constraints still supported with the new data-binding?
I tried to port a ZUL file which uses the old data-binding to the new ZK bind method.
This page has input fields, where the initial value would violate the given constraint, for example
<intbox cols="6" width="100px" constraint="no empty, no negative, no zero" value="@{model.intvalue}" />
I ported that to ViewModel - more or less there was almost no change to the model code needed. The new intbox looks like the following:
<intbox cols="6" width="100px" constraint="no empty, no negative, no zero" value="@bind(vm.intvalue)" />
The difference is, that I get now a WrongValueException, since the new data binder calls setValue on the Intbox while the old data binder called setRawValue.
Question: is this behavior intended - i.e. constraints are not supported anymore - or is it a bug?
In case of the latter, I can also provide a complete example if needed.
Hi, Matze
I know this issue, the problem is binder don't know when to call setRawValue or setValue. Always call setRawValue maybe is incorrect in some scenario.
We will figure out a easy to do this. currently, you could use.
<intbox cols="6" width="100px" constraint="no empty, no negative, no zero" value="@save(vm.intvalue)" rawValue="@load(vm.intValue)"/>
/Dennis
Hi, Matze
We decided to call this a bug, and will fix it, the tracker is here , http://tracker.zkoss.org/browse/ZK-682
Thanks.
Matze,
Are you evaluating to port old application to zk 6 or for new applications?
I try to port a private project of medium size, which runs with 5.0.9 currently. It heavily uses the old data binding, so it is a good candidate to try ZK bind.
This is just for evaluation to try the new features, detecting problems with the new concepts upfront and to estimate possible migration efforts.
Currently, this is only private interest, but the gained knowledge will also get used in our company, e.g. to generate some design rules for ZK5 applications to be able to port them to ZK6 easier, e.g. to work already with a kind of ViewModel class.
But there are no concrete plans yet for "really" moving to ZK6, neither with old nor with new applications.
Dennis,
just tried the latest freshly zk-bin-6.0.0-FL-2011-12-15, the fix for ZK-682 seems to work. Thank you very much.
BTW: the issue is not listed in release-note.
But now something else is broken with annotations and the old data binder:
It seems that Annotation.getAttributes now returns a Map<String, String[]>, but at least AnnotateDataBinder.loadComponent is not prepared for it.
There is a cast to String in
List expr = parseExpression((String) me.getValue(), ";");
Yes, the annotation spec. is changed in zk6.
could you provide the exception, then I can post to bug tracker, thanks.
Hi Dennis,
here is the relevant part of the stack:
java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.lang.String at org.zkoss.zkplus.databind.AnnotateDataBinder.loadComponentAnnotation(AnnotateDataBinder.java:444) at org.zkoss.zkplus.databind.AnnotateDataBinder.loadComponentAnnotation(AnnotateDataBinder.java:431) at org.zkoss.zkplus.databind.AnnotateDataBinder.loadAnnotations(AnnotateDataBinder.java:403) at org.zkoss.zkplus.databind.AnnotateDataBinder.loadAnnotations(AnnotateDataBinder.java:408) at org.zkoss.zkplus.databind.AnnotateDataBinder.loadAnnotations(AnnotateDataBinder.java:408) at org.zkoss.zkplus.databind.AnnotateDataBinder.init(AnnotateDataBinder.java:399) at org.zkoss.zkplus.databind.AnnotateDataBinder.<init>(AnnotateDataBinder.java:303)
Map attrs = ann.getAttributes(); for(final Iterator it = attrs.entrySet().iterator(); it.hasNext();) { Entry me = (Entry) it.next(); String attr = (String) me.getKey(); //[0] bean value, [1 ~ *] tag:expression List expr = parseExpression((String) me.getValue(), ";");
Asked: 2011-12-12 08:47:36 +0800
Seen: 662 times
Last updated: Dec 19 '11