0

Problem with ListModel using JSP servlet filter

asked 2008-08-22 21:34:58 +0800

blandrp gravatar image blandrp
72 2

I have my webapp set up to use JSP's and ZK 3.0.7 as outlined in the SmallTalk Work with Legacy Web Applications, Part II - JSP. Everything has been working fine until I started trying to use a ListModel and ListitemRenderer in one of my Listboxes. I've narrowed down the issue to something with the setting of the model attribute on the Listbox.

Consider the following contents of my JSP, with the ZK portion taken directly from the [a href=http://www.zkoss.org/doc/devguide/ch07s11s11.html"]List Boxes Live Data section of the Developers Guide.

<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>ZK ListModel JSP Test</title>
</head>
<body xmlns:zk="http://www.zkoss.org/2005/zul">
<zscript>
String[] data = new String[30];
for (int j=0; j < data.length; ++j) {
data = "option " + j;
}
final org.zkoss.zul.ListModel strset = new org.zkoss.zul.SimpleListModel(data);
</zscript>
<zk:listbox width="200px" rows="10" model="${strset}">
<zk:listhead>
<zk:listheader label="Load on demend"/>
</zk:listhead>
</zk:listbox>
</body>
</html>

The exception I receive when I try to open my page is the following:
[8/22/08 16:24:14:669 CDT] 0000002e WebApp E [Servlet Error]-[/listbox_model_test.jsp]: java.lang.ClassCastException: class java.lang.String cannot be converted to interface org.zkoss.zul.ListModel.
at org.zkoss.lang.Classes.coerce(Classes.java:1287)
at org.zkoss.zk.xel.ExValue.coerce(ExValue.java:116)
at org.zkoss.zk.xel.ExValue.getValue(ExValue.java:111)
at org.zkoss.zk.ui.metainfo.Property.assign(Property.java:161)
at org.zkoss.zk.ui.metainfo.ComponentInfo.applyProperties(ComponentInfo.java:613)
at org.zkoss.zk.ui.impl.AbstractUiFactory.newComponent(AbstractUiFactory.java:95)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:537)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:520)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:481)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:465)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:546)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:520)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:481)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:465)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild0(UiEngineImpl.java:546)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:520)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:481)
at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:465)
at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:359)
at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:292)
at org.zkoss.zk.ui.http.DHtmlLayoutFilter.process(DHtmlLayoutFilter.java:104)
at org.zkoss.zk.ui.http.DHtmlLayoutFilter.doFilter(DHtmlLayoutFilter.java:189)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:701)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:646)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:475)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:115)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:168)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.handleRequest(AbstractJSPExtensionProcessor.java:270)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3129)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:238)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1433)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:93)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:274)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:194)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:741)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:863)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
Caused by: java.lang.InstantiationException: org.zkoss.zul.ListModel
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1263)
at org.zkoss.lang.Classes.coerce(Classes.java:1285)
... 49 more

I doubt this has anything to do with it, but I did notice that I can't use <zk:zscript>...</zk:zscript> to declare my zscript because it causes an error when accessing the page (but declaring it with <zkscript>...</zkscript> works). I also tried creating a window component that could be used by the page, and then creating the ListModel in there and accessing the ListModel directly from the EL expression in the Listbox tag. I get the same exception when I do that, but the getter method on the window class I created is never called. This leads me to believe that the filter isn't handling the model property of the Listbox tag correctly.

Any pointers or thoughts from anyone?

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2008-08-25 14:51:30 +0800

blandrp gravatar image blandrp
72 2

I just noticed that the code of the JSP is slightly wrong, but even the corrected JSP doesn't work. Use the following JSP contents instead.

<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>ZK ListModel JSP Test</title>
</head>
<body xmlns:zk="http://www.zkoss.org/2005/zul">
<zscript>
String[] data = new String[30];
for (int j=0; j < data.length; ++j) {
data = "option " + j;
}
final org.zkoss.zul.ListModel strset = new org.zkoss.zul.SimpleListModel(data);
</zscript>
<zk:listbox width="200px" rows="10" model="${strset}">
<zk:listhead>
<zk:listheader label="Load on demend"/>
</zk:listhead>
</zk:listbox>
</body>
</html>

link publish delete flag offensive edit

answered 2008-08-25 16:32:23 +0800

robertpic71 gravatar image robertpic71
1275 1

I've no expierence with JSP/ZK, but i think it should be:

<zk:zscript> instead of <zscript>
and of course </zk:zscript>

/Robert

link publish delete flag offensive edit

answered 2008-08-25 18:09:33 +0800

blandrp gravatar image blandrp
72 2

The JSP filter won't take zk:zscript as a tag. I originally tried that but it fails, so I tried just the <zscript> tag and it works (seems like that might be another bug to me, but it doesn't stop me).

link publish delete flag offensive edit

answered 2008-08-25 20:00:20 +0800

robertpic71 gravatar image robertpic71
1275 1

Try this


<%@ taglib uri="http://www.zkoss.org/2005/zul/jsp" prefix="zk" %>
<z:page zscriptLanguage="java">

See also: Docs

/Robert

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2008-08-22 21:34:58 +0800

Seen: 451 times

Last updated: Aug 25 '08

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More