18 package org.turro.contacts.zul.contact;
20 import java.util.Arrays;
21 import java.util.Comparator;
22 import java.util.List;
23 import org.turro.contacts.FieldDef;
24 import org.turro.contacts.db.ContactsPU;
25 import org.turro.elephant.db.WhereClause;
26 import org.turro.jpa.Dao;
27 import org.zkoss.zul.AbstractListModel;
28 import org.zkoss.zul.ListModel;
29 import org.zkoss.zul.ListSubModel;
30 import org.zkoss.zul.event.ListDataEvent;
31 import org.zkoss.zul.ext.Sortable;
37 public class FieldValueComboModel extends AbstractListModel implements Sortable<Object>, ListSubModel, java.io.Serializable {
39 private static final long serialVersionUID = 20081029L;
41 private Object[] data;
46 this.fieldDef = fieldDef;
50 this.data = data.toArray(
new Object[data.size()]);
51 this.fieldDef = fieldDef;
56 if(data ==
null || data.length <= index)
return null;
66 public void sort(Comparator cmpr,
boolean ascending) {
67 Arrays.sort(data, cmpr);
68 fireEvent(ListDataEvent.CONTENTS_CHANGED, -1, -1);
80 wc.
addClause(
"select distinct fieldValue.value");
81 wc.
addClause(
"from FieldValue as fieldValue");
82 wc.
addClause(
"where fieldValue.fieldDef = :fieldDef");
83 wc.
addLikeFields(
new String[] {
"fieldValue.value" }, value.toString());
84 wc.
addClause(
"order by fieldValue.value");
86 if(nRows < 1) nRows = 10;
void addClause(String clause)
void addLikeFields(String[] fields, String value)
void addNamedValue(String name, Object value)