18 package org.turro.dossier.zul.dossier;
20 import org.turro.dossier.db.DossierPU;
21 import org.turro.dossier.entity.Dossier;
22 import org.turro.dossier.search.DossierResults;
23 import org.turro.zkoss.label.LabelExtended;
24 import org.zkoss.lang.Strings;
25 import org.zkoss.zk.ui.Component;
26 import org.zkoss.zk.ui.WrongValueException;
27 import org.zkoss.zk.ui.event.Event;
28 import org.zkoss.zk.ui.event.EventListener;
29 import org.zkoss.zk.ui.event.Events;
30 import org.zkoss.zk.ui.ext.AfterCompose;
31 import org.zkoss.zul.Bandbox;
32 import org.zkoss.zul.Bandpopup;
33 import org.zkoss.zul.Listbox;
34 import org.zkoss.zul.Listcell;
35 import org.zkoss.zul.Listitem;
41 public class DossierCtrl extends Bandbox implements AfterCompose {
45 private int wordWrap = 0, maxChars = 0, parentCount = 1;
46 private boolean showDescription =
false;
53 return showDescription;
57 this.showDescription = showDescription;
59 addEventListener(Events.ON_CHANGE,
new EventListener() {
61 public void onEvent(Event event)
throws Exception {
73 this.dossier = dossier;
84 this.maxChars = maxChars;
92 this.parentCount = parentCount;
100 this.wordWrap = wordWrap;
105 if(!showDescription)
return;
110 Component comp = getParent();
111 for(
int i = 1; i < parentCount; i++) {
112 comp = comp.getParent();
114 comp.appendChild(description);
118 public String
getValue() throws WrongValueException {
119 return Strings.isBlank(super.getValue()) ?
"0" : super.getValue();
123 public void setValue(String value)
throws WrongValueException {
124 if(Strings.isEmpty(value)) value =
"0";
125 super.setValue(value);
128 private void addPopup() {
129 Bandpopup popup =
new Bandpopup();
132 final Listbox dossiers =
new Listbox();
133 dossiers.addEventListener(Events.ON_SELECT,
new EventListener() {
135 public void onEvent(Event event)
throws Exception {
138 Events.postEvent(
new Event(Events.ON_CHANGE,
DossierCtrl.this));
142 popup.appendChild(dossiers);
144 DossierResults results =
new DossierResults();
146 for(Dossier d : results.getDossierList()) {
147 Listitem item =
new Listitem();
148 dossiers.appendChild(item);
150 Listcell cell =
new Listcell(d.getId() +
"");
151 item.appendChild(cell);
153 cell =
new Listcell(d.getFullDescription());
154 item.appendChild(cell);
159 private String loadValue() {
161 dossier =
new DossierPU().find(Dossier.class, Long.valueOf(
getValue()));
162 if(dossier !=
null) {
boolean isShowDescription()
void setMaxChars(int maxChars)
void setValue(String value)
void setDossier(Dossier dossier)
void setParentCount(int parentCount)
void setWordWrap(int wordWrap)
void setShowDescription(boolean showDescription)
LabelExtended setWordWrap(int wordWrap)
void setValue(String value)
LabelExtended setMaxChars(int maxChars)