protected String coerceToString(Object value) { final Constraint constr = getConstraint(); final String val = super.coerceToString(value); if (val.length() > 0 && constr != null && constr instanceof SimpleConstraint && (((SimpleConstraint) constr).getFlags() & SimpleConstraint.STRICT) != 0) { for (Iterator<Comboitem> it = getItems().iterator(); it.hasNext();) { final String label = ((Comboitem) it.next()).getLabel(); if (val.equalsIgnoreCase(label)) return label; } } return val; }
private void enableResultItems(String... labels) { List<String> enable = Arrays.asList(labels); Comboitem firstVisible = null; for (Object object : cboResults.getItems()) { Comboitem item = (Comboitem) object; boolean visible = enable.contains(item.getLabel()); item.setVisible(visible); if (visible && firstVisible == null) { firstVisible = item; } } cboResults.setSelectedItem(firstVisible); }
private void syncValueToSelection() { final String value = getValue(); if (!Objects.equals(_lastCkVal, value)) { _lastCkVal = value; _selItem = null; for (final Comboitem item : getItems()) { if (Objects.equals(value, item.getLabel())) { _selItem = item; break; } } syncSelectionToModel(); } }
if (oldSel != null && !oldSel.equals(_selItem) && oldSel.getLabel().equals(val)) Events.postEvent(new InputEvent(Events.ON_CHANGE, this, val, val)); Events.postEvent(evt);
/** 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(); } }
for (Iterator it = ((Combobox) comp).getItems().iterator(); it.hasNext();) { final Comboitem ci = (Comboitem) it.next(); if (!ci.isDisabled() && ci.isVisible() && s.equalsIgnoreCase(ci.getLabel())) return;
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(); } } } }
Comboitem cboitem = cboServiceCategory.getSelectedItem(); Date date = datEncounter.getDate(); CodeableConceptDt sc = EncounterUtil.createServiceCategory((String) cboitem.getValue(), cboitem.getLabel(), cboitem.getTooltiptext()); encounter = EncounterUtil.create(date, location, sc);
public void render(Component comp, Writer out) throws IOException { final SmartWriter wh = new SmartWriter(out); final Comboitem self = (Comboitem) comp; final String uuid = self.getUuid(); final String zcls = self.getZclass(); wh.write("<tr id=\"").write(uuid).write("\" z.type=\"Cmit\"") .write(self.getOuterAttrs()).write(self.getInnerAttrs()).writeln(">") .write("<td class=\"").write(zcls).write("-img\">").write(self.getImgTag()) .write("</td>\n<td class=\"").write(zcls).write("-text\">"); Out o = new Out(self.getLabel()); o.setPre(true); o.render(out); String s = self.getDescription(); if (!Strings.isBlank(s)) { wh.write("<br/>\n<span class=\"").write(zcls).write("-inner\">"); new Out(s).render(out); wh.write("</span>"); } s = self.getContent(); if (!Strings.isBlank(s)) wh.write("<span class=\"").write(zcls).write("-cnt\">").write(s).write("</span>"); //1. don't use Out to encode since content might contain HTML tags //2. Feature 1908524: no <br/> wh.writeln("</td></tr>"); } }