public Component getComponentCollectionOwner(Component comp) { if (comp instanceof Comboitem) { final Comboitem item = (Comboitem) comp; return item.getParent(); } else { throw new UiException("Unsupported type for ComboitemCollectionItem: " + comp); } }
/** Returns the index of this Comboitem. * @since 6.0.0 */ public int getIndex() { final Combobox cb = (Combobox) getParent(); if (cb != null) cb.syncItemIndices(); return _index; }
@Override protected Component getEventTarget() { return target.as(Comboitem.class).getParent(); // combobox }
public void setupBindingRenderer(Component comp, DataBinder binder) { if (comp instanceof Comboitem) { final Comboitem li = (Comboitem) comp; final Combobox cbbox = (Combobox) li.getParent(); if (cbbox.getItemRenderer() == null) { cbbox.setItemRenderer(new BindingComboitemRenderer(li, binder)); } } }
/** * 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; }
/** Deselects the currently selected items and selects the given item. * <p>Note: if the label of comboitem has the same more than one, the first * comboitem will be selected at client side, it is a limitation of {@link Combobox} * and it is different from {@link Listbox}.</p> * @since 3.0.2 */ public void setSelectedItem(Comboitem item) { if (item != null && item.getParent() != this) throw new UiException("Not a child: " + item); if (item != _selItem) { _selItem = item; if (item != null) { setValue(item.getLabel()); smartUpdate("selectedItemUuid_", item.getUuid()); } else { //Bug#2919037: don't call setRawValue(), or the error message will be cleared if (_value != null && !"".equals(_value)) { _value = ""; smartUpdate("value", coerceToString(_value)); } } _lastCkVal = getValue(); } }
public void setLabel(String label) { final String old = getLabel(); if (!Objects.equals(old, label)) { final Combobox cb = (Combobox) getParent(); final boolean syncValueToSelection = cb != null && cb.getSelectedItemDirectly() == this; super.setLabel(label); if (syncValueToSelection) { final Constraint constr = cb.getConstraint(); if (constr != null && constr instanceof SimpleConstraint && (((SimpleConstraint) constr).getFlags() & SimpleConstraint.STRICT) != 0) { cb.setValue(label); } else { cb.schedSyncValueToSelection(); } } } }
public void render(final Comboitem item, final Object data, final int index) { final Combobox cb = (Combobox) item.getParent(); final Template tm = cb.getTemplate("model"); if (tm == null) { } else { final Component[] items = ShadowElementsCtrl .filterOutShadows(tm.create(item.getParent(), item, new VariableResolver() { public Object resolveVariable(String name) { if ("each".equals(name)) {
public void render(final Comboitem item, final Object data, final int index) throws Exception { final Combobox cb = (Combobox) item.getParent(); final ListModel<?> model = cb.getModel(); final int size = model.getSize();