Package org.zkoss.zul

Examples of org.zkoss.zul.Listbox$ModelInitListener


  private void dropPerformed(DropEvent dropEvent) {
    Component target = dropEvent.getTarget();
    Component dragged = dropEvent.getDragged();
    Node[] draggedNodes = null;
    if (dragged instanceof Listitem) {
      Listbox listbox = ((Listitem) dragged).getListbox();
      Set<Listitem> itemSet = new HashSet(listbox.getSelectedItems());
      itemSet.add((Listitem) dragged);
      List<Node> nodes = new ArrayList();
      for (Object item : listbox.getItems()) {
        if (itemSet.contains(item)) {
          if (((Listitem) item).getValue() instanceof Node) {
            nodes.add((Node) ((Listitem) item).getValue());
          }
        }
      }
      listbox.clearSelection();
      draggedNodes = nodes.toArray(new Node[] {});
    }
    if (dragged instanceof Treerow) {
      draggedNodes = new Node[] { (Node) ((Treeitem) ((Treerow) dragged)
          .getParent()).getValue() };
View Full Code Here


  public void service(HttpServletRequest request, HttpServletResponse response)
  throws javax.servlet.ServletException, java.io.IOException {
    final Desktop desktop = getDesktop(request);
    Bridge bridge = Bridge.start(getServletContext(), request, response, desktop);
    try {
      final Listbox listbox = (Listbox) ((Page)desktop.getPages().iterator().next()).getRoots().iterator().next();
      listbox.appendChild(new Listitem("Ajax " + ++cnt));
      response.getWriter().write(bridge.getResult());
    } finally {
      bridge.close();
    }
  }
View Full Code Here

    }
  }

  public ListModel getModelByOwner(Component comp) {
    if (comp instanceof Listbox) {
      final Listbox listbox = (Listbox) comp;
      return listbox.getModel();
    } else {
      throw new UiException(
          "Unsupported type for ListitemCollectionItem: " + comp);
    }
  }
View Full Code Here

    }
  }

  public Component getComponentAtIndexByOwner(Component comp, int index) {
    if (comp instanceof Listbox) {
      final Listbox listbox = (Listbox) comp;
      return listbox.getItemAtIndex(index);
    } else {
      throw new UiException(
          "Unsupported type for ListitemCollectionItem: " + comp);
    }
  }
View Full Code Here

  }

  public void setupBindingRenderer(Component comp, DataBinder binder) {
    if (comp instanceof Listitem) {
      final Listitem li = (Listitem) comp;
      final Listbox lbx = li.getListbox();
      if (lbx.getItemRenderer() == null) {
        lbx.setItemRenderer(new BindingListitemRenderer(li, binder));
      }
    }
  }
View Full Code Here

    }
  }

  public List getItems(Component comp) {
    if (comp instanceof Listbox) {
      final Listbox listbox = (Listbox) comp;
      return listbox.getItems();
    } else {
      throw new UiException(
          "Unsupported type for ListitemCollectionItem: " + comp);
    }
  }
View Full Code Here

*/
public class SelectedItemConverter implements TypeConverter, java.io.Serializable {
  private static final long serialVersionUID = 200808191439L;
 
  public Object coerceToUi(Object val, Component comp) { //load
    Listbox lbx = (Listbox) comp;
      if (val != null) {
        final ListModel xmodel = lbx.getModel();
        if (xmodel instanceof BindingListModel) {
          final BindingListModel model = (BindingListModel) xmodel;
          int index = model.indexOf(val);
          if (index >= 0) {
            final Listitem item = (Listitem) lbx.getItemAtIndex(index);
            //Bug #2728704: Listbox with databinding generates onSelect w/o user action
            //Shall not fire event by spec. For backward compatibility(still want to
            //fire onSelect event as usual), user can specifies in zk.xml
            //<library-property>
            //  <name>org.zkoss.zkplus.databind.onSelectWhenLoad</name>
            //  <value>true</value>
            //</library-property>
            //then data binder will still fire the onSelect event as usual.
            if (SelectedItemConverter.isOnSelectWhenLoad()) {
              final int selIndex = lbx.getSelectedIndex();
             
            //We need this to support load-when:onSelect when first load
            //the page in (so it is called only once).
              if (item != null && selIndex != index) { // bug 1647817, avoid endless-loop
                Set items = new HashSet();
                items.add(item);
                //bug #2140491
                Executions.getCurrent().setAttribute("zkoss.zkplus.databind.ON_SELECT"+lbx.getUuid(), Boolean.TRUE);
                Events.postEvent(new SelectEvent("onSelect", lbx, items, item));
              }
            }
            return item;
          }
        } else if (xmodel == null) { //no model case, assume Listitem.value to be used with selectedItem
          //iterate to find the selected item assume the value (select mold)
          for (final Iterator it = lbx.getItems().iterator(); it.hasNext();) {
            final Listitem li = (Listitem) it.next();
            if (val.equals(li.getValue())) {
              return li;
            }
          }
View Full Code Here

      _onSelectWhenLoad = Boolean.valueOf("true".equals(str));
    }
    return _onSelectWhenLoad.booleanValue();
  }
  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;
  }
View Full Code Here

        SqlSession sess = IBatisFactory.getInstance().getSqlSession();
        List buildingList = sess.selectList("Building.getAll");
        sess = null;

        // show to the building listbox
        Listbox buildingListbox = (Listbox) getFellow("buildingListbox");
        ListModelList buildingListModel = new ListModelList(buildingList, true);
        buildingListbox.setModel(buildingListModel);
        buildingListbox.setItemRenderer(buildingListRenderer);
    }
View Full Code Here

        System.out.println("--------->>> "+form.getObjectId());
         
    }
   
    public void selectBomByBuilding() {
        Listbox buildingListboxLB = (Listbox) getFellow("buildingListbox");
        Building building = (Building) buildingListboxLB.getSelectedItem().getValue();
        Map para = new HashMap();
        para.put("buildingId", building.getBuildingId());

        refreshObjEntities(para);
       
View Full Code Here

TOP

Related Classes of org.zkoss.zul.Listbox$ModelInitListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.