private void initModel() { Executions.getCurrent().removeAttribute("zkoss.Listbox.deferInitModel_" + getUuid()); setModel(_model); //init the model }
public Object coerceToBean(Object val, Component comp) { //save final Listbox lbx = (Listbox) comp; if (Executions.getCurrent().getAttribute("zkoss.zkplus.databind.ON_SELECT" + lbx.getUuid()) != null) { //bug #2140491 //triggered by coerceToUi(), ignore this Executions.getCurrent().removeAttribute("zkoss.zkplus.databind.ON_SELECT" + lbx.getUuid()); return TypeConverter.IGNORE; } if (val != null) { final ListModel model = lbx.getModel(); //no model case, assume Listitem.value to be used with selectedItem return model != null ? model.getElementAt(((Listitem) val).getIndex()) : ((Listitem) val).getValue(); } return null; } }
items.add(item); Executions.getCurrent().setAttribute("zkoss.zkplus.databind.ON_SELECT" + lbx.getUuid(), Boolean.TRUE); Events.postEvent(new SelectEvent<Listitem, Object>("onSelect", lbx, items, item));
public void onPageAttached(Page newpage, Page oldpage) { super.onPageAttached(newpage, oldpage); if (oldpage == null) { // mark as a new attached Listbox final Execution exec = Executions.getCurrent(); exec.setAttribute("zkoss.Listbox.deferInitModel_" + getUuid(), Boolean.TRUE); exec.setAttribute("zkoss.Listbox.attached_" + getUuid(), Boolean.TRUE); // prepare a right moment to init Listbox (must be as early as possible) this.addEventListener("onInitModel", _modelInitListener = new ModelInitListener()); Events.postEvent(20000, new Event("onInitModel", this)); //first event to be called } GroupsModel groupsModel = getGroupsModel(); if (_model != null || groupsModel != null) { getDataLoader().syncModel(-1, -1); postOnInitRender(); } if (_model != null && _dataListener != null) { _model.removeListDataListener(_dataListener); _model.addListDataListener(_dataListener); } if (groupsModel != null && _groupsDataListener != null) { groupsModel.removeGroupsDataListener(_groupsDataListener); groupsModel.addGroupsDataListener(_groupsDataListener); } }
: exec.getAttribute("zkoss.Listbox.deferInitModel_" + getUuid()) != null; final boolean rod = evalRod(); if (!defer || !rod)
if (cmd.equals("onDataLoading")) { if (_rod) { Executions.getCurrent().setAttribute("zkoss.zul.listbox.onDataLoading." + this.getUuid(), Boolean.TRUE); //indicate doing dataloading } else if (cmd.equals(Events.ON_SELECT)) { if (_rod && Executions.getCurrent() .getAttribute("zkoss.zul.listbox.onDataLoading." + this.getUuid()) != null) //indicate doing dataloading return; //skip all onSelect event after the onDataLoading
public void render(Component comp, Writer out) throws IOException { final SmartWriter wh = new SmartWriter(out); final Listbox self = (Listbox)comp; final String uuid = self.getUuid(); wh.write("<select id=\"").write(uuid).write("\" z.type=\"zul.sel.Lisel\"") .write(self.getOuterAttrs()).write(self.getInnerAttrs()).writeln(">"); for (Iterator it = self.getItems().iterator(); it.hasNext();) { final Listitem item = (Listitem)it.next(); if (item.isVisible()) { wh.write("<option id=\"").write(item.getUuid()).write("\"") .write(item.getOuterAttrs()) .write(item.getInnerAttrs()).write(">"); new Out(item.getLabel()).setMaxlength(self.getMaxlength()) .render(out); wh.writeln("</option>"); } } wh.write("</select>"); }
: exec.getAttribute("zkoss.Listbox.deferInitModel_" + getUuid()) != null; final boolean rod = evalRod();
public void render(Component comp, Writer out) throws IOException { final SmartWriter wh = new SmartWriter(out); final Listbox self = (Listbox)comp; final String uuid = self.getUuid(); final String zcls = self.getZclass(); final Execution exec = Executions.getCurrent();
public void render(Component comp, Writer out) throws IOException { final SmartWriter wh = new SmartWriter(out); final Listbox self = (Listbox)comp; final String uuid = self.getUuid(); final String zcls = self.getZclass(); final Execution exec = Executions.getCurrent();