ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

ZK6 (any) + <template> + zkspring-security3.0 = VirtualIdSpace cannot be cast Component

YADA
27 Jan 2012 00:40:45 GMT
27 Jan 2012 00:40:45 GMT

Hi!

After some year without ZK, now started gain with ZK6.


I just began to evaluate the new zk6 with zkspring-security. Everything work just fine, until using any of the new <template> tag.

<window title="teszt" 
	apply="org.zkoss.bind.BindComposer"viewModel="@id('vm') @init('org.zkoss.bind.examples.order.OrderVM')" >
		<listbox model="@load(vm.orders)" selectedItem="@bind(vm.selected)">
			<listhead>
				<listheader label="Id"/>
				<listheader label="Quantity"/>
			</listhead>
			<template name="model" var="item">
				<listitem >
					<listcell label="@load(item.id)"/>				
					<listcell label="@load(item.quantity)"/>
				</listitem>
			</template>
		</listbox>
</window>

With/without event filtering do the same.

	<zksp:zk-event login-template-close-delay="5">
		<zksp:intercept-event path="/**" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
		<zksp:form-login login-page="/login.zul?nodecor=1" force-https="true"/>
	</zksp:zk-event>


After this failed with next exception:

...
Caused by: java.lang.ClassCastException: org.zkoss.zk.ui.VirtualIdSpace cannot be cast to org.zkoss.zk.ui.Component
at org.zkoss.spring.security.intercept.zkevent.ZkEventProcessDefinitionSourceImpl.toPath(ZkEventProcessDefinitionSourceImpl.java:145)
at org.zkoss.spring.security.intercept.zkevent.ZkEventProcessDefinitionSourceImpl.toPath(ZkEventProcessDefinitionSourceImpl.java:156)
at org.zkoss.spring.security.intercept.zkevent.ZkEventProcessDefinitionSourceImpl.getAttributes(ZkEventProcessDefinitionSourceImpl.java:135)
at org.springframework.security.access.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:172)
at org.zkoss.spring.security.intercept.zkevent.ZkEventProcessInterceptor.beforeInvocation(ZkEventProcessInterceptor.java:52)
at org.zkoss.spring.security.intercept.zkevent.ZkEventProcessListener.beforeProcessEvent(ZkEventProcessListener.java:54)
at org.zkoss.zk.ui.impl.EventInterceptors.beforeProcessEvent(EventInterceptors.java:146)
at org.zkoss.zk.ui.util.Configuration.beforeProcessEvent(Configuration.java:2524)
at org.zkoss.zk.ui.impl.DesktopImpl.beforeProcessEvent(DesktopImpl.java:1189)
at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:130)
at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1696)
... 65 more

This looks like the template tag makes org.zkoss.zk.ui.VirtualIdSpace, and zkspring-security try to iterate over each zk Component.
But VirtualIdSpace is not a descendant of Component, and zkspring-sec module fails in ZkEventProcessDefinitionSourceImpl.java @ line145.

Heris the code section where fails (line 142-150):

		if (comp instanceof Page) {
			sb.append("//").append(((Page)comp).getId());
		} else {
			final Component xcomp = (Component) comp;
			IdSpace spaceOwner = null;
			if (xcomp instanceof IdSpace) {
				final Component parent = xcomp.getParent();
				spaceOwner = parent == null ? xcomp.getPage() : parent.getSpaceOwner();
			} else if (xcomp != null){

SimonPai
30 Jan 2012 01:30:53 GMT
30 Jan 2012 01:30:53 GMT

Hi YADA,

We have post the issue to bug tracker here.

Thanks,
Simon

YADA
30 Jan 2012 10:24:02 GMT
30 Jan 2012 10:24:02 GMT

Thank you.
I was not sure wether this is a bug of ZK component hierarchy or zkspring-security.

hawk
29 Feb 2012 01:52:04 GMT
29 Feb 2012 01:52:04 GMT

hi,
There is a freshly release that contains the fix to this issue.

http://code.google.com/p/zkspring/downloads/detail?name=zk-spring-security-bin-3.1-FL-2012-02-24.zip&can=2&q=#makechanges

YADA
7 Mar 2012 09:55:26 GMT
7 Mar 2012 09:55:26 GMT

zk-spring 3.1 out now

thanks! :)