BrightSide Workbench Full Report + Source Code
CustomerCombobox.java
Go to the documentation of this file.
1 package org.turro.crm.zul.customer;
2 
3 import java.util.LinkedList;
4 import java.util.List;
5 import org.turro.crm.db.CrmPU;
6 import org.turro.crm.entity.Customer;
7 import org.turro.elephant.db.WhereClause;
8 import org.turro.jpa.Dao;
9 import org.turro.zkoss.input.GenericCombobox;
10 
15 public class CustomerCombobox extends GenericCombobox<Customer> {
16 
17  @Override
18  public void populateList(String value, LinkedList list, int nRows) {
19  Dao dao = new CrmPU();
20  WhereClause wc = new WhereClause();
21  wc.addClause("select customer from Customer as customer");
22  wc.addClause("where 1=1");
23  wc.addLikeFields(new String[] {"customer.name"}, value);
24  wc.addClause("order by customer.name");
25  List<Customer> l = dao.getResultList(wc, nRows);
26  for(Object o : l) {
27  list.add((Customer) o);
28  }
29  }
30 
31  @Override
32  public String getTextFromObject(Customer value) {
33  return value.getName();
34  }
35 
36 }
void populateList(String value, LinkedList list, int nRows)
void addLikeFields(String[] fields, String value)