-
FEATURED COMPONENTS
First time here? Check out the FAQ!
How to create auto sort in header listbox ?, i have code like this
Department.zul
<?xml version="1.0" encoding="UTF-8"?> <?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" root="./winDepartemen" ?> <?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?> <zk xmlns="http://www.zkoss.org/2005/zul" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd"> <zscript> <![CDATA[ zk.DepartmentController; ]]> </zscript> <window id="winDepartemen" width="650px" border="normal" apply="${DepartmentController}" > <listbox id="listDept" multiple="true" rows="10" model="@{winDepartemen$composer.allDepartment}" mold="paging" pageSize="10"> <listhead> <listheader label="Id" width="0px"/> <listheader label="Code" sort="auto"/> <listheader label="Description" sort="auto"/> <listheader label="Update/Delete"/> </listhead> <listitem self="@{each='department'}" value="@{department}"> <listcell label="@{department.id}"/> <listcell label="@{department.code}"/> <listcell label="@{department.description}"/> </listitem> </listbox> </window> </zk>
public class DepartmentController extends GenericForwardComposer { //show data dept public List<Department> getAllDepartment(){ try { List<Department> list=new ArrayList<Department>(); list=departmentService.getList(); return list; } catch (Exception ex) { ex.printStackTrace(); return null; } } //auto refresh data after crud public void refreshList(){ List<Department> list=new ArrayList<Department>(); list=departmentService.getList(); ListModel listModel = new SimpleListModel(list); listDept.setModel(listModel); } }
SEVERE: >>java.lang.ClassCastException: model.Department cannot be cast to java.lang.Comparable >> at org.zkoss.zul.ListitemComparator.compare(ListitemComparator.java:250) >> at java.util.TimSort.countRunAndMakeAscending(TimSort.java:324) >> at java.util.TimSort.sort(TimSort.java:189) >> at java.util.TimSort.sort(TimSort.java:173) >> at java.util.Arrays.sort(Arrays.java:659)
Asked: 2012-06-06 08:44:23 +0800
Seen: 165 times
Last updated: Jun 06 '12