-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I am blocked by a problem for the whole day about the tree componenent. I build a simple tree and the tree shows perfectly.
But the problem arises when I select a node then expand the node. A alert box pops up and says "java.lang.String cannot be cast to java.util.List".
I traced the problem and found the function in org.zkoss.zk.ui.event.SelectEvent:
@SuppressWarnings("unchecked") public static final <T extends Component, E> SelectEvent<T,E> getSelectEvent(AuRequest request, SelectedObjectHandler<T> handler) { final Map<String, Object> data = request.getData(); final Desktop desktop = request.getDesktop(); final List<String> sitems = cast((List)data.get("items")); final Set<T> items = AuRequests.convertToItems(desktop, sitems); final Set<E> objs = (Set<E>) (handler == null ? null : handler.getObjects(items)); return new SelectEvent<T,E>(request.getCommand(), request.getComponent(), items, objs, (T) desktop.getComponentByUuidIfAny((String)data.get("reference")), null, AuRequests.parseKeys(data)); }
dtid:z_vgb cmd_0:onSelect uuid_0:mSHQ1 data_0:{"items":"","reference":"mSHQ7","clearFirst":false,"pageX":528,"pageY":86,"which":1,"x":62,"y":50} cmd_1:onOpen uuid_1:mSHQ7 data_1:{"open":false}
My environment: the zul page is used together Prototype framework and some other 3rd party libraries.
Cound someone help on this? Your help is really appreciated!
More Information:
I used ZK 6.0.2, found the problem, upgradde to ZK 6.5.0. But unfortunately the problems still exist.
About the data snippet: in "items" , there is a square bracket enclosing a string with no double quotes. It seems it is swallowed somehow in the post.
Update:
I access the .zul directly in order to isolate zk from other client side js. It works as expected.
The same operation(select and expand) sends out different data:
dtid:z_2hb cmd_0:onOpen uuid_0:h0APi1 data_0:{"open":true}
Only "onOpen" event is sent while in the faulty case, "onSelect" is send at the same time. Could it be a clue for somebody with more ZK experience to guess what's going wrong?
I doubt the problem is caused by client side js interference :(
I'm quite sure it's a compatibility problem introduced by Prototype. My quick analysis is that zk.copy function uses for...in loop on an Array, but that won't work because Prototype modifies the built-in Javascript Array. This is something that is explicitly warned about in the Prototype documentation.
Note that this isn't really a ZK bug, but a compatibility problem due to the extremely invasive nature of Prototype. I would strongly recommend against mixing it with ZK, because there might be other incompatibilities too.
Asked: 2012-09-19 03:23:53 +0800
Seen: 89 times
Last updated: Oct 02 '12