BrightSide Workbench Full Report + Source Code
SaleActionGrid.java
Go to the documentation of this file.
1 package org.turro.crm.zul.sale;
2 
3 import java.util.Date;
4 import org.turro.crm.entity.SaleAction;
5 import org.turro.crm.entity.SaleProspect;
6 import org.turro.zkoss.grid.PagingGrid;
7 import org.zkoss.zk.ui.ext.AfterCompose;
8 import org.zkoss.zul.Include;
9 import org.zkoss.zul.Row;
10 import org.zkoss.zul.Rows;
11 
16 public class SaleActionGrid extends PagingGrid implements AfterCompose {
17 
18  private SaleProspect saleProspect;
19  private Date from, to;
20 
21  public SaleActionGrid() {
22  }
23 
24  public void setSaleProspect(SaleProspect saleProspect) {
25  this.saleProspect = saleProspect;
26  }
27 
28  public void setFrom(Date from) {
29  this.from = from;
30  }
31 
32  public void setTo(Date to) {
33  this.to = to;
34  }
35 
36  public void refresh() {
37  if(saleProspect != null) {
38  addRows(saleProspect.getSaleActions());
39  } else {
40  getRows(true).getChildren().clear();
41  }
42  }
43 
44  private void addRows(SaleActionSet saleActions) {
45  Rows rows = getRows(true);
46  rows.getChildren().clear();
47 
48  for(final SaleAction saleAction : saleActions) {
49  Row row = new Row();
50  Include inc = new Include("/WEB-INF/_zul/crm/saleaction.zul");
51  inc.setDynamicProperty("saleAction", saleAction);
52  inc.setDynamicProperty("row", row);
53  inc.setWidth("100%");
54  inc.setHeight("100%");
55  row.appendChild(inc);
56  rows.appendChild(row);
57  }
58 
59  Row row = new Row();
60  Include inc = new Include("/WEB-INF/_zul/crm/saleaction.zul");
61  inc.setDynamicProperty("saleProspect", saleProspect);
62  inc.setDynamicProperty("from", from);
63  inc.setDynamicProperty("to", to);
64  inc.setDynamicProperty("grid", this);
65  inc.setWidth("100%");
66  inc.setHeight("100%");
67  row.appendChild(inc);
68  rows.appendChild(row);
69  }
70 
71  @Override
72  public void afterCompose() {
73  refresh();
74  }
75 
76 }
void setSaleProspect(SaleProspect saleProspect)
Rows getRows(boolean create)