BrightSide Workbench Full Report + Source Code
CustomerGrid.java
Go to the documentation of this file.
1 package org.turro.crm.zul.customer;
2 
3 import java.util.Collection;
4 import org.turro.command.CommandUtil;
5 import org.turro.crm.entity.Customer;
6 import org.turro.i18n.I_;
7 import org.turro.zkoss.grid.PagingGrid;
8 import org.zkoss.zk.ui.ext.AfterCompose;
9 import org.zkoss.zul.Column;
10 import org.zkoss.zul.Columns;
11 import org.zkoss.zul.Row;
12 import org.zkoss.zul.Rows;
13 
18 public class CustomerGrid extends PagingGrid implements AfterCompose {
19 
20  private CustomerFilter filter = new CustomerFilter();
21  private CustomerFilterGrid filterGrid;
22 
24  return filter;
25  }
26 
27  public void setFilterGrid(CustomerFilterGrid filterGrid) {
28  this.filterGrid = filterGrid;
29  }
30 
31  public void reload() {
32  if(getRows() != null) {
33  getRows().detach();
34  }
35  addRows();
36  }
37 
38  @Override
39  public void afterCompose() {
40  addColumns();
41  }
42 
43  private void addRows() {
44  if(!filterGrid.hasValues()) return;
45 
46  Collection<Customer> list = filter.getObjectValues(filterGrid.getValues());
47 
48  Rows rows = new Rows();
49  appendChild(rows);
50 
51  for(final Customer cd : list) {
52  Row row = new Row();
53  rows.appendChild(row);
54  row.appendChild(CommandUtil.getLinkOrSpace(cd));
55  }
56 
57  setRowCount(list.size());
58  }
59 
60  private void addColumns() {
61  Columns cols = new Columns();
62  appendChild(cols);
63 
64  Column col = new Column(I_.get("Customer"));
65  cols.appendChild(col);
66  }
67 
68 }
static HtmlBasedComponent getLinkOrSpace(Object entity)
Collection< Customer > getObjectValues(List< IFilterValue > values)
void setFilterGrid(CustomerFilterGrid filterGrid)
List< IFilterValue > getValues()
Rows getRows(boolean create)