org.zkoss.zul.Listbox.getModel()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中org.zkoss.zul.Listbox.getModel()方法的一些代码示例,展示了Listbox.getModel()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Listbox.getModel()方法的具体详情如下:
包路径:org.zkoss.zul.Listbox
类名称:Listbox
方法名:getModel

Listbox.getModel介绍

[英]Returns the model associated with this list box, or null if this list box is not associated with any list data model.

Note: if #setModel(GroupsModel) was called with a groups model, this method returns an instance of ListModel encapsulating it.
[中]返回与此列表框关联的模型,如果此列表框未与任何列表数据模型关联,则返回null。
注意:如果使用组模型调用#setModel(GroupsModel),此方法将返回封装它的ListModel实例。

代码示例

代码示例来源:origin: org.zkoss.zk/zkbind

protected ListModel<?> getComponentModel(Listbox comp) {
    return ((Listbox) comp).getModel();
  }
}

代码示例来源:origin: org.zkoss.zk/zkplus

protected ListModel<?> getComponentModel(Component comp) {
  return ((Listbox) comp).getModel();
}

代码示例来源:origin: org.zkoss.zk/zkplus

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);
  }
}

代码示例来源:origin: org.zkoss.zk/zul

/** Sets whether the content of this item is loaded; used if
 * the listbox owning this item is using a list model.
 */
/*package*/ void setLoaded(boolean loaded) {
  if (loaded != _loaded) {
    _loaded = loaded;
    final Listbox listbox = getListbox();
    if (listbox != null && listbox.getModel() != null)
      smartUpdate("_loaded", _loaded);
  }
}

代码示例来源:origin: org.carewebframework/org.carewebframework.cal.ui.patientselection.v1

public void onClick$btnManagedListImport() {
  for (Object item : (ListModelList<?>) lstPatientList.getModel()) {
    managedListAdd((PatientListItem) item, false);
  }
  
  managedListRefresh();
}

代码示例来源:origin: org.zkoss.zk/zul

public int getTotalSize() {
  final ListModel model = _listbox.getModel();
  return model != null ? model.getSize() : _listbox.getVisibleItemCount();
}

代码示例来源:origin: org.zkoss.zk/zkbind

public Object coerceToBean(Object val, Component comp, BindContext ctx) {
  if (val != null) {
    final Listbox lbx = (Listbox) comp;
    final ListModel<?> model = lbx.getModel();
    if (model != null && !(model instanceof Selectable)) {
      throw new UiException("model doesn't implement Selectable");
    }
    if (model != null) {
      Set<?> selection = ((Selectable<?>) model).getSelection();
      if (selection == null || selection.size() == 0)
        return null;
      return selection.iterator().next();
    } else { //no model
      return ((Listitem) val).getValue();
    }
  }
  return null;
}

代码示例来源:origin: org.zkoss.zk/zkbind

@SuppressWarnings("unchecked")
public Object coerceToBean(Object val, Component comp, BindContext ctx) {
  Set<Object> vals = new LinkedHashSet<Object>();
  if (val != null) {
    final Listbox lbx = (Listbox) comp;
    final ListModel<?> model = lbx.getModel();
    if (model != null && !(model instanceof Selectable)) {
      throw new UiException("model doesn't implement Selectable");
    }
    if (model != null) {
      Set<?> selection = ((Selectable<?>) model).getSelection();
      if (selection != null && selection.size() > 0) {
        for (Object o : selection) {
          vals.add(o);
        }
      }
    } else { //no model
      final Set<Listitem> items = (Set<Listitem>) Classes.coerce(HashSet.class, val);
      for (Listitem item : items) {
        vals.add(item.getValue());
      }
    }
  }
  return vals;
}

代码示例来源:origin: org.zkoss.zk/zul

/**
 * Scroll to the specified item by the given index.
 * @param index the index of item
 * @since 8.5.2
 */
public void scrollToIndex(int index) {
  ListModel<Object> model = getModel();
  int itemCount = model != null ? model.getSize() : getItemCount();
  if (index < 0 || index > itemCount - 1) {
    throw new IndexOutOfBoundsException("Illegal index: " + index);
  }
  response(new AuInvoke(this, "scrollToIndex", index, (double) index / itemCount));
}

代码示例来源:origin: org.zkoss.zk/zkbind

@SuppressWarnings("unchecked")
public Object coerceToUi(Object val, Component comp, BindContext ctx) {
  Listbox lbx = (Listbox) comp;
  final ListModel<?> model = lbx.getModel();
  if (model != null && !(model instanceof Selectable)) {
    //model has to implement Selectable if binding to selectedItems
    throw new UiException("model doesn't implement Selectable");
  }
  final Set<Listitem> items = new LinkedHashSet<Listitem>();
  Set<Object> vals = val == null ? null : (Set<Object>) Classes.coerce(LinkedHashSet.class, val);
  if (vals != null && vals.size() > 0) {
    if (model != null) {
      ((Selectable<Object>) model).setSelection(vals);
    } else {
      //no model case
      for (final Iterator<?> it = lbx.getItems().iterator(); it.hasNext();) {
        final Listitem li = (Listitem) it.next();
        Object bean = li.getValue();
        if (vals.contains(bean)) {
          items.add(li);
        }
      }
    }
  } else if (model != null && !((Selectable<Object>) model).isSelectionEmpty()) { //model !=null and no selection
    ((Selectable<Object>) model).clearSelection();
  }
  return model == null ? items : IGNORED_VALUE;
}

代码示例来源:origin: org.zkoss.zk/zkbind

@SuppressWarnings("unchecked")
public Object coerceToUi(Object val, Component comp, BindContext ctx) {
  Listbox lbx = (Listbox) comp;
  final ListModel<?> model = lbx.getModel();

代码示例来源:origin: org.zkoss.zk/zul

/**
 * updates the status of the changed group.
 * @param event
 * @since 8.0.4
 */
public void doGroupsDataChange(GroupsDataEvent event) {
  if (event.getType() == GroupsDataEvent.GROUPS_OPENED) {
    Listbox listbox = (Listbox) getOwner();
    GroupsListModel groupsListModel = ((GroupsListModel) listbox.getModel());
    int offset = groupsListModel.getGroupOffset(event.getGroupIndex());
    ((Listgroup) listbox.getItems().get(offset)).setOpen(groupsListModel.getDataInfo(offset).isOpen());
  }
}

代码示例来源:origin: org.zkoss.zk/zkplus

/**
 * Check if comp can be waived from linking templates
 * @param comp
 */
private static boolean isSkippable(Component comp) {
  // Bug: B50-3183438: skip only when it has model
  if (comp instanceof Comboitem) {
    Combobox b = (Combobox) ((Comboitem) comp).getParent();
    if (b != null && b.getModel() != null)
      return true;
  } else if (comp instanceof Row) {
    Grid g = ((Row) comp).getGrid();
    if (g != null && g.getModel() != null)
      return true;
  } else if (comp instanceof Listitem) {
    Listbox b = ((Listitem) comp).getListbox();
    if (b != null && b.getModel() != null)
      return true;
  }
  return false;
}

代码示例来源:origin: org.zkoss.zk/zul

if (listbox.getModel() == null) {

代码示例来源:origin: org.zkoss.zk/zkplus

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;
  }
}

代码示例来源:origin: org.zkoss.zk/zul

protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException {
  super.renderProperties(renderer);
  render(renderer, "selected", isSelected());
  render(renderer, "disabled", isDisabled());
  render(renderer, "_loaded", _loaded ? _loaded : getListbox().getModel() == null);
  renderer.render("_index", _index);
  if (_value instanceof String && getListbox().getName() != null)
    render(renderer, "value", _value);
  if (!isCheckable())
    renderer.render("checkable", false);
}

代码示例来源:origin: org.zkoss.zk/zul

/** Processes an AU request.
 *
 * <p>Default: in addition to what are handled by {@link XulElement#service},
 * it also handles onOpen.
 * @since 5.0.0
 */
public void service(org.zkoss.zk.au.AuRequest request, boolean everError) {
  final String cmd = request.getCommand();
  if (cmd.equals(Events.ON_OPEN)) {
    OpenEvent evt = OpenEvent.getOpenEvent(request);
    _open = evt.isOpen();
    final Listbox listbox = getListbox();
    if (listbox != null) {
      listbox.addVisibleItemCount(_open ? getVisibleItemCount() : -getVisibleItemCount());
      final ListModel model = listbox.getModel();
      if (model instanceof GroupsListModel) {
        int gindex = listbox.getGroupIndex(getIndex());
        GroupsModel gmodel = ((GroupsListModel) model).getGroupsModel();
        if (_open)
          gmodel.addOpenGroup(gindex);
        else
          gmodel.removeOpenGroup(gindex);
      }
    }
    Events.postEvent(evt);
  } else
    super.service(request, everError);
}

代码示例来源:origin: org.zkoss.zk/zul

/** Creates an new and unloaded listitem. */
protected final Listitem newUnloadedItem(ListitemRenderer renderer, int index) {
  final ListModel model = _listbox.getModel();
  Listitem item = null;
  if (model instanceof GroupsListModel) {
    final GroupsListModel gmodel = (GroupsListModel) model;
    final GroupingInfo info = gmodel.getDataInfo(index);
    switch (info.getType()) {
    case GroupDataInfo.GROUP:
      item = newListgroup(renderer);
      ((Listgroup) item).setOpen(info.isOpen());
      break;
    case GroupDataInfo.GROUPFOOT:
      item = newListgroupfoot(renderer);
      break;
    default:
      item = newListitem(renderer);
    }
  } else {
    item = newListitem(renderer);
  }
  ((LoadStatus) item.getExtraCtrl()).setLoaded(false);
  ((LoadStatus) item.getExtraCtrl()).setIndex(index);
  newUnloadedCell(renderer, item);
  return item;
}

代码示例来源:origin: org.zkoss.zk/zul

removePagingListener(_pgi);
if (getModel() != null) {
  getDataLoader().syncModel(0, initRodSize()); // change offset back to 0
  postOnInitRender();

代码示例来源:origin: org.carewebframework/org.carewebframework.cal.ui.patientselection.v1

/**
 * Update control states.
 */
private void updateControls() {
  if (manageListMode) {
    boolean filterSelected = lstManagedListFilter.getSelectedItem() != null;
    boolean patientSelected = lstManagedList.getSelectedItem() != null;
    btnManagedListFilterRename.setDisabled(!filterSelected);
    btnManagedListFilterDelete.setDisabled(!filterSelected);
    btnManagedListAddCurrent.setDisabled(!filterSelected || PatientContext.getActivePatient() == null);
    btnManagedListAdd.setDisabled(!filterSelected || activePatient == null);
    btnManagedListImport.setDisabled(!filterSelected || lstPatientList.getModel() == null);
    btnManagedListRemove.setDisabled(!patientSelected);
    btnManagedListRemoveAll.setDisabled(lstManagedList.getItemCount() == 0);
    btnOK.setDisabled(false);
    btnManageList.setDisabled(true);
  } else {
    btnManageList.setDisabled(activeList == null
        || (activeList.getItemManager() == null && activeList.getFilterManager() == null));
    btnOK.setDisabled(activePatient == null);
  }
}

相关文章