private static <S extends SelectItem> S createSelectItem(UIComponent component, Object value, Supplier<S> supplier) { Map<String, Object> attributes = component.getAttributes(); Object itemValue = getItemValue(attributes, value); Object itemLabel = attributes.get("itemLabel"); Object itemLabelEscaped = coalesce(attributes.get("itemEscaped"), attributes.get("itemLabelEscaped")); // f:selectItem || f:selectItems Object itemDisabled = attributes.get("itemDisabled"); S selectItem = supplier.get(); selectItem.setValue(itemValue); selectItem.setLabel(String.valueOf(itemLabel != null ? itemLabel : selectItem.getValue())); selectItem.setEscape(itemLabelEscaped == null || Boolean.parseBoolean(itemLabelEscaped.toString())); selectItem.setDisabled(itemDisabled != null && Boolean.parseBoolean(itemDisabled.toString())); return selectItem; }
private static <S extends SelectItem> S createSelectItem(UIComponent component, Object value, Supplier<S> supplier) { Map<String, Object> attributes = component.getAttributes(); Object itemValue = getItemValue(attributes, value); Object itemLabel = attributes.get("itemLabel"); Object itemLabelEscaped = coalesce(attributes.get("itemEscaped"), attributes.get("itemLabelEscaped")); // f:selectItem || f:selectItems Object itemDisabled = attributes.get("itemDisabled"); S selectItem = supplier.get(); selectItem.setValue(itemValue); selectItem.setLabel(String.valueOf(itemLabel != null ? itemLabel : selectItem.getValue())); selectItem.setEscape(itemLabelEscaped == null || Boolean.parseBoolean(itemLabelEscaped.toString())); selectItem.setDisabled(itemDisabled != null && Boolean.parseBoolean(itemDisabled.toString())); return selectItem; }
private SelectItem createSelectItem(final Object value, String label, final String description, final boolean disabled) { if (label == null && value != null) { label = value.toString(); } SelectItem selectItem = new SelectItem(); if (value != null) { selectItem.setValue(value); } if (label != null) { selectItem.setLabel(label); } selectItem.setDescription(description); selectItem.setDisabled(disabled); return selectItem; }
public List<SelectItem> getAvailableRooms() { List<SelectItem> result = new ArrayList<>(); WrittenTest writtenTest = (WrittenTest) getEvaluation(); Teacher teacher = AccessControl.getPerson().getTeacher(); for (Space room : writtenTest.getAvailableRooms()) { SelectItem selectItem; selectItem = new SelectItem(room.getExternalId(), room.getName()); selectItem.setDisabled(!writtenTest.canTeacherRemoveRoom(getExecutionCourse().getExecutionPeriod(), teacher, room)); result.add(selectItem); } return result; }
/** * <p>Construct a <code>SelectItem</code> instance with the specified * property values.</p> * * @param value Value to be delivered to the model if this * item is selected by the user * @param label Label to be rendered for this item in the response * @param description Description of this item, for use in tools * @param disabled Flag indicating that this option is disabled * @param escape Flag indicating that the text of this option should be * escaped when rendered. * @since 1.2 */ public SelectItem(Object value, String label, String description, boolean disabled, boolean escape) { super(); setValue(value); setLabel(label); setDescription(description); setDisabled(disabled); setEscape(escape); }
private static SelectItem cloneSelectItem(SelectItem o) { SelectItem copy = new SelectItem(); String description = o.getDescription(); if (description != null) copy.setDescription(new String(description)); copy.setDisabled(o.isDisabled()); copy.setEscape(o.isEscape()); String label = o.getLabel(); if (label != null) copy.setLabel(new String(label)); copy.setNoSelectionOption(o.isNoSelectionOption()); copy.setValue(o.getValue()); return copy; } }
/** * <p>Construct a <code>SelectItem</code> instance with the specified * property values.</p> * * @param value Value to be delivered to the model if this * item is selected by the user * @param label Label to be rendered for this item in the response * @param description Description of this item, for use in tools * @param disabled Flag indicating that this option is disabled * @param escape Flag indicating that the text of this option should be * escaped when rendered. * @param noSelectionOption Flag indicating that the current option is a "no selection" option * @since 1.2 */ public SelectItem(Object value, String label, String description, boolean disabled, boolean escape, boolean noSelectionOption) { super(); setValue(value); setLabel(label); setDescription(description); setDisabled(disabled); setEscape(escape); setNoSelectionOption(noSelectionOption); }
/** * <p>Construct a <code>SelectItem</code> instance with the specified * property values.</p> * * @param value Value to be delivered to the model if this * item is selected by the user * @param label Label to be rendered for this item in the response * @param description Description of this item, for use in tools * @param disabled Flag indicating that this option is disabled * @param escape Flag indicating that the text of this option should be * escaped when rendered. * @param noSelectionOption Flag indicating that the current option is a "no selection" option * @since 1.2 */ public SelectItem(Object value, String label, String description, boolean disabled, boolean escape, boolean noSelectionOption) { super(); setValue(value); setLabel(label); setDescription(description); setDisabled(disabled); setEscape(escape); setNoSelectionOption(noSelectionOption); }
/** * <p>Construct a <code>SelectItem</code> instance with the specified * property values.</p> * * @param value Value to be delivered to the model if this * item is selected by the user * @param label Label to be rendered for this item in the response * @param description Description of this item, for use in tools * @param disabled Flag indicating that this option is disabled * @param escape Flag indicating that the text of this option should be * escaped when rendered. * @param noSelectionOption Flag indicating that the current option is a "no selection" option * @since 1.2 */ public SelectItem(Object value, String label, String description, boolean disabled, boolean escape, boolean noSelectionOption) { super(); setValue(value); setLabel(label); setDescription(description); setDisabled(disabled); setEscape(escape); setNoSelectionOption(noSelectionOption); }
/** * <p>Construct a <code>SelectItem</code> instance with the specified * property values.</p> * * @param value Value to be delivered to the model if this * item is selected by the user * @param label Label to be rendered for this item in the response * @param description Description of this item, for use in tools * @param disabled Flag indicating that this option is disabled * @param escape Flag indicating that the text of this option should be * escaped when rendered. * @param noSelectionOption Flag indicating that the current option is a "no selection" option * @since 1.2 */ public SelectItem(Object value, String label, String description, boolean disabled, boolean escape, boolean noSelectionOption) { super(); setValue(value); setLabel(label); setDescription(description); setDisabled(disabled); setEscape(escape); setNoSelectionOption(noSelectionOption); }
/** * <p>Construct a <code>SelectItem</code> instance with the specified * property values.</p> * * @param value Value to be delivered to the model if this * item is selected by the user * @param label Label to be rendered for this item in the response * @param description Description of this item, for use in tools * @param disabled Flag indicating that this option is disabled * @param escape Flag indicating that the text of this option should be * escaped when rendered. * @param noSelectionOption Flag indicating that the current option is a "no selection" option * @since 1.2 */ public SelectItem(Object value, String label, String description, boolean disabled, boolean escape, boolean noSelectionOption) { super(); setValue(value); setLabel(label); setDescription(description); setDisabled(disabled); setEscape(escape); setNoSelectionOption(noSelectionOption); }
/** * <p>Construct a <code>SelectItem</code> instance with the specified * property values.</p> * * @param value Value to be delivered to the model if this * item is selected by the user * @param label Label to be rendered for this item in the response * @param description Description of this item, for use in tools * @param disabled Flag indicating that this option is disabled * @param escape Flag indicating that the text of this option should be * escaped when rendered. * @param noSelectionOption Flag indicating that the current option is a "no selection" option * @since 1.2 */ public SelectItem(Object value, String label, String description, boolean disabled, boolean escape, boolean noSelectionOption) { super(); setValue(value); setLabel(label); setDescription(description); setDisabled(disabled); setEscape(escape); setNoSelectionOption(noSelectionOption); }
/** * <p>Construct a <code>SelectItem</code> instance with the specified * property values.</p> * * @param value Value to be delivered to the model if this * item is selected by the user * @param label Label to be rendered for this item in the response * @param description Description of this item, for use in tools * @param disabled Flag indicating that this option is disabled * @param escape Flag indicating that the text of this option should be * escaped when rendered. * @param noSelectionOption Flag indicating that the current option is a "no selection" option * @since 1.2 */ public SelectItem(Object value, String label, String description, boolean disabled, boolean escape, boolean noSelectionOption) { super(); setValue(value); setLabel(label); setDescription(description); setDisabled(disabled); setEscape(escape); setNoSelectionOption(noSelectionOption); }
/** * <p>Construct a <code>SelectItem</code> instance with the specified * property values.</p> * * @param value Value to be delivered to the model if this * item is selected by the user * @param label Label to be rendered for this item in the response * @param description Description of this item, for use in tools * @param disabled Flag indicating that this option is disabled * @param escape Flag indicating that the text of this option should be * escaped when rendered. * @param noSelectionOption Flag indicating that the current option is a "no selection" option * @since 1.2 */ public SelectItem(Object value, String label, String description, boolean disabled, boolean escape, boolean noSelectionOption) { super(); setValue(value); setLabel(label); setDescription(description); setDisabled(disabled); setEscape(escape); setNoSelectionOption(noSelectionOption); }
/** * <p>Construct a <code>SelectItem</code> instance with the specified * property values.</p> * * @param value Value to be delivered to the model if this * item is selected by the user * @param label Label to be rendered for this item in the response * @param description Description of this item, for use in tools * @param disabled Flag indicating that this option is disabled * @param escape Flag indicating that the text of this option should be * escaped when rendered. * @param noSelectionOption Flag indicating that the current option is a "no selection" option * @since 1.2 */ public SelectItem(Object value, String label, String description, boolean disabled, boolean escape, boolean noSelectionOption) { super(); setValue(value); setLabel(label); setDescription(description); setDisabled(disabled); setEscape(escape); setNoSelectionOption(noSelectionOption); }
public List<SelectItem> resetSelectItems(DatasetFieldType typeIn) { List<SelectItem> retList = new ArrayList<>(); if ((typeIn.isHasParent() && typeIn.getParentDatasetFieldType().isInclude()) || (!typeIn.isHasParent() && typeIn.isInclude())) { SelectItem requiredItem = new SelectItem(); requiredItem.setLabel(BundleUtil.getStringFromBundle("dataverse.item.required")); requiredItem.setValue(true); retList.add(requiredItem); SelectItem optional = new SelectItem(); optional.setLabel(BundleUtil.getStringFromBundle("dataverse.item.optional")); optional.setValue(false); retList.add(optional); } else { SelectItem hidden = new SelectItem(); hidden.setLabel(BundleUtil.getStringFromBundle("dataverse.item.hidden")); hidden.setValue(false); hidden.setDisabled(true); retList.add(hidden); } return retList; }
private static SelectItem toSelectItem(UISelectItem option) { SelectItem item = (SelectItem) option.getValue(); if (item == null) { item = new SelectItem(); item.setDescription(option.getItemDescription()); item.setDisabled(option.isItemDisabled()); item.setEscape(option.isItemEscaped()); item.setLabel(option.getItemLabel()); item.setNoSelectionOption(option.isNoSelectionOption()); item.setValue(option.getItemValue()); } return item; }
private static SelectItem toSelectItem(UISelectItem option) { SelectItem item = (SelectItem) option.getValue(); if (item == null) { item = new SelectItem(); item.setDescription(option.getItemDescription()); item.setDisabled(option.isItemDisabled()); item.setEscape(option.isItemEscaped()); item.setLabel(option.getItemLabel()); item.setNoSelectionOption(option.isNoSelectionOption()); item.setValue(option.getItemValue()); } return item; }