-
FEATURED COMPONENTS
First time here? Check out the FAQ!
i am having a peculiar problem binding data in a autocomplete(autodrop) combobox using zkjsp.The problem lies in the <z:zscript></z:zscript> portion.
i am using struts1 with hibernate3.my jsp page is as follows.
subscriberlist.jsp
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@include file="commonheader.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Subscriber Master</title>
</head>
<body>
<z:page>
<center><z:hbox>
SEARCH BY:
<z:combobox id="combo1" autodrop="true" mold="rounded">
<z:comboitem label="UA KEY" />
<z:comboitem label="SUBSCRIBER CODE" />
<z:comboitem label="SUBSCRIBER NAME" />
<z:comboitem label="TELEPHONE NO" />
</z:combobox>
KEYWORD:
<z:combobox id="combo2" autodrop="true" mold="rounded"
onChange="populate()">
<z:zscript>
import hibernate.Complainmaster;
import com.hibernate.DAO.*;
ComplainmasterHome complainmasterHome=new ComplainmasterHome();
void populate(){
Combobox c1=(Combobox)Path.getComponent("/combo1");
if(c1.getValue().equals("UA KEY")){
Combobox c2=(Combobox)Path.getComponent("/combo2");
String keyword=c2.getValue();
List list=(List)complainmasterHome.getListByUakey(keyword);
Iterator it = list.iterator();
String[] data = new String[500];
int x=0;
while(it.hasNext()){
Complainmaster complainmaster=(Complainmaster)it.next();
data=complainmaster.getSubscribermaster().getSettopboxmaster().getVcnumber().toLowerCase();
x++;
}
ListModel listModel = new SimpleListModel(data);
c2.setModel(listModel);
}
}
</z:zscript>
</z:combobox>
<z:hlayout>
<z:label value=" " pre="true" />
<z:button label="GO" />
</z:hlayout>
</z:hbox></center>
</z:page>
</body>
</html>
my error stack is like::
Dec 3, 2010 6:26:47 PM org.zkoss.zk.ui.impl.UiEngineImpl handleError:1253
SEVERE: >>java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List
>> at org.zkoss.zk.ui.event.SelectEvent.getSelectEvent(SelectEvent.java:60)
>> at org.zkoss.zul.Combobox.service(Combobox.java:597)
>> at org.zkoss.zk.ui.impl.DesktopImpl.service(DesktopImpl.java:684)
>> at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1378)
>> at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1095)
>> at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:561)
>>...
plz plz help
I am getting the same error ! Plz help !!
data=complainmaster.getSubscribermaster().getSettopboxmaster().getVcnumber().toLowerCase();
ListModel listModel = new SimpleListModel(data);
SimpleListModel() doesn't accept String as input.
You may look into the api.
It's harder to find such problem in zscript,
It would be easy to found such bug, if using java syntax check.
Asked: 2010-12-03 06:58:05 +0800
Seen: 803 times
Last updated: Jan 27 '11