asked
2010-12-24 04:27:03 +0800
markdamne 33 My code:
Articolo.zul
<?xml version="1.0" encoding="UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
...
<window id="winArticolo" use="controller.ControllerArticolo" border="none" width="1000px" height="230px" >
<grid id="demoGrid" style="border:none;" width="1200" mold="paging" pageSize="6" >
<!-- <columns> fixedLayout="true" height="200px"
<column hflex="4">Cliente</column>
<column hflex="5">Comune Sede Legale</column>
<column hflex="2">Provincia</column>
<column hflex="3">Partita IVA</column>
</columns> mold="paging" pageSize="10" mold="paging" pageSize="6"-->
<rows>
<row>
<listbox Width="1060px" id="lb1" model="@{winArticolo.articoli}" mold="paging" pageSize="7" vflex="false" selectedItem="@{winArticolo.selected}" onSelect="OpenSouthPanel(lb1.getSelectedIndex())">
<listhead sizable="true">
<!-- <listitem self="@{each='curr'}" sclass="cells" value="@{curr}"> checkmark="true"-->
<listheader label="Scegli" width="5%" />
<listheader label="Codice" width="10%" />
<listheader label="Nome" width="10%" />
<listheader label="Descrizione" width="10%" />
<listheader label="Tipo" width="10%" />
<listheader label="IVA %" width="10%" />
<listheader label="Prezzo €" width="10%" />
</listhead>
<listitem self="@{each='articoli'}" value="@{articoli}">
<!-- <listcell label=""/>
<a:bind value = “seller.firstName”/>
<textbox/>-->
<listcell><checkbox label="" /></listcell>
<listcell label= "@{articoli.codice}"/>
<listcell label= "@{articoli.nome}"/>
<listcell label= "@{articoli.descrizione}"/>
<listcell label= "@{articoli.tipo}"/>
<listcell label= "@{articoli.iva}"/>
<listcell label= "@{articoli.prezzo}"/>
<!-- <listcell label="@{customers.ragione}" /> #{} -->
</listitem>
</listbox>
</row>
</rows>
</grid>
</window>
ControllerArticolo.java
public class ControllerArticolo extends Window
{
List articoli = new ArrayList();
Articolo selected = new Articolo();
public ControllerArticolo() throws InterruptedException
{
EntityManagerFactory emf;
emf = Persistence.createEntityManagerFactory("jpaTest");
EntityManager em = emf.createEntityManager();
javax.persistence.Query q = em.createQuery("SELECT a FROM Articolo a");
articoli = q.getResultList();
em.close();
}
public List getArticoli() {
return articoli;
}
public Articolo getSelected() {
return selected;
}
public void setSelected(Articolo selected) {
this.selected = selected;
}
}
exception
java.lang.ClassCastException: class entity.Articolo cannot be converted to class org.zkoss.zul.Listitem.
org.zkoss.lang.Classes.coerce(Classes.java:1301)
org.zkoss.lang.reflect.Fields.set(Fields.java:151)
org.zkoss.zkplus.databind.Binding.myLoadAttribute(Binding.java:387)
org.zkoss.zkplus.databind.Binding.loadAttribute(Binding.java:336)
org.zkoss.zkplus.databind.DataBinder.loadAttrs(DataBinder.java:591)
org.zkoss.zkplus.databind.DataBinder.loadComponent0(DataBinder.java:546)
org.zkoss.zkplus.databind.DataBinder.loadAll(DataBinder.java:575)
org.zkoss.zkplus.databind.AnnotateDataBinderInit.doAfterCompose(AnnotateDataBinderInit.java:175)
org.zkoss.zk.ui.impl.RealInits.doAfterCompose(Initiators.java:82)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:376)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:291)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:243)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:164)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.NoSuchMethodException: No contructor compatible with [entity.Articolo] in org.zkoss.zul.Listitem
org.zkoss.lang.Classes.newInstance(Classes.java:120)
org.zkoss.lang.Classes.coerce(Classes.java:1299)
org.zkoss.lang.reflect.Fields.set(Fields.java:151)
org.zkoss.zkplus.databind.Binding.myLoadAttribute(Binding.java:387)
org.zkoss.zkplus.databind.Binding.loadAttribute(Binding.java:336)
org.zkoss.zkplus.databind.DataBinder.loadAttrs(DataBinder.java:591)
org.zkoss.zkplus.databind.DataBinder.loadComponent0(DataBinder.java:546)
org.zkoss.zkplus.databind.DataBinder.loadAll(DataBinder.java:575)
org.zkoss.zkplus.databind.AnnotateDataBinderInit.doAfterCompose(AnnotateDataBinderInit.java:175)
org.zkoss.zk.ui.impl.RealInits.doAfterCompose(Initiators.java:82)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:376)
org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:291)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:243)
org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:164)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.
Thanks for advance.