Java Code Examples for javax.faces.model.SelectItem#getValue()
The following examples show how to use
javax.faces.model.SelectItem#getValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SerializationComparatorSet.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
public String compare(SerializationCompareContext context, String message, String methodName, Object object1, Object object2) { SelectItem item1 = (SelectItem) object1; SelectItem item2 = (SelectItem) object2; message += "-> SelectItem"; String fails = ""; fails += applyComparator(context, message, ".disabled", item1.isDisabled(), item2.isDisabled()); fails += applyComparator(context, message, ".label", item1.getLabel(), item2.getLabel()); fails += applyComparator(context, message, ".description", item1.getDescription(), item2.getDescription()); Object value1 = item1.getValue(); Object value2 = item2.getValue(); fails += applyComparator(context, message + ".value", ".getClass()", null == value1 ? null : value1.getClass(), null == value2 ? null : value2.getClass()); fails += applyComparator(context, message + ".value", ".toString()", "" + value1, "" + value2); return fails; }
Example 2
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Given a List of SelectItems render the select options * * @param out * @param items * List of SelectItems * @param selected * seelcted choice * @param clientId * the id * @param styleClass * the optional style class * @param component * the component being rendered * @throws IOException */ public static void renderMenu(ResponseWriter out, List items, int selected, String clientId, String styleClass, UIComponent component) throws IOException { // // debug lines // out.writeText("startElement select", null); // if (true) return; out.startElement("select", component); out.writeAttribute("name", clientId, "id"); out.writeAttribute("id", clientId, "id"); if (styleClass != null) { out.writeAttribute("class", styleClass, "styleClass"); } Iterator iter = items.iterator(); while (iter.hasNext()) { SelectItem si = (SelectItem) iter.next(); Integer value = (Integer) si.getValue(); String label = si.getLabel(); out.startElement("option", component); out.writeAttribute("value", value, null); if (value.intValue() == selected) { out.writeAttribute("selected", "selected", null); } out.writeText(label, null); } out.endElement("select"); }
Example 3
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Given a List of SelectItems render the select options * * @param out * @param items * List of SelectItems * @param selected * seelcted choice * @param clientId * the id * @param styleClass * the optional style class * @param component * the component being rendered * @throws IOException */ public static void renderMenu(ResponseWriter out, List items, int selected, String clientId, String styleClass, UIComponent component) throws IOException { // // debug lines // out.writeText("startElement select", null); // if (true) return; out.startElement("select", component); out.writeAttribute("name", clientId, "id"); out.writeAttribute("id", clientId, "id"); if (styleClass != null) { out.writeAttribute("class", styleClass, "styleClass"); } Iterator iter = items.iterator(); while (iter.hasNext()) { SelectItem si = (SelectItem) iter.next(); Integer value = (Integer) si.getValue(); String label = si.getLabel(); out.startElement("option", component); out.writeAttribute("value", value, null); if (value.intValue() == selected) { out.writeAttribute("selected", "selected", null); } out.writeText(label, null); } out.endElement("select"); }
Example 4
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Given a List of SelectItems render the select options * * @param out * @param items * List of SelectItems * @param selected * seelcted choice * @param clientId * the id * @param styleClass * the optional style class * @param component * the component being rendered * @throws IOException */ public static void renderMenu(ResponseWriter out, List items, int selected, String clientId, String styleClass, UIComponent component) throws IOException { // // debug lines // out.writeText("startElement select", null); // if (true) return; out.startElement("select", component); out.writeAttribute("name", clientId, "id"); out.writeAttribute("id", clientId, "id"); if (styleClass != null) { out.writeAttribute("class", styleClass, "styleClass"); } Iterator iter = items.iterator(); while (iter.hasNext()) { SelectItem si = (SelectItem) iter.next(); Integer value = (Integer) si.getValue(); String label = si.getLabel(); out.startElement("option", component); out.writeAttribute("value", value, null); if (value.intValue() == selected) { out.writeAttribute("selected", "selected", null); } out.writeText(label, null); } out.endElement("select"); }
Example 5
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Given a List of SelectItems render the select options * * @param out * @param items * List of SelectItems * @param selected * seelcted choice * @param clientId * the id * @param styleClass * the optional style class * @param component * the component being rendered * @throws IOException */ public static void renderMenu(ResponseWriter out, List items, int selected, String clientId, String styleClass, UIComponent component) throws IOException { // // debug lines // out.writeText("startElement select", null); // if (true) return; out.startElement("select", component); out.writeAttribute("name", clientId, "id"); out.writeAttribute("id", clientId, "id"); if (styleClass != null) { out.writeAttribute("class", styleClass, "styleClass"); } Iterator iter = items.iterator(); while (iter.hasNext()) { SelectItem si = (SelectItem) iter.next(); Integer value = (Integer) si.getValue(); String label = si.getLabel(); out.startElement("option", component); out.writeAttribute("value", value, null); if (value.intValue() == selected) { out.writeAttribute("selected", "selected", null); } out.writeText(label, null); } out.endElement("select"); }
Example 6
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Given a List of SelectItems render the select options * * @param out * @param items * List of SelectItems * @param selected * seelcted choice * @param clientId * the id * @param styleClass * the optional style class * @param component * the component being rendered * @throws IOException */ public static void renderMenu(ResponseWriter out, List items, int selected, String clientId, String styleClass, UIComponent component) throws IOException { // // debug lines // out.writeText("startElement select", null); // if (true) return; out.startElement("select", component); out.writeAttribute("name", clientId, "id"); out.writeAttribute("id", clientId, "id"); if (styleClass != null) { out.writeAttribute("class", styleClass, "styleClass"); } Iterator iter = items.iterator(); while (iter.hasNext()) { SelectItem si = (SelectItem) iter.next(); Integer value = (Integer) si.getValue(); String label = si.getLabel(); out.startElement("option", component); out.writeAttribute("value", value, null); if (value.intValue() == selected) { out.writeAttribute("selected", "selected", null); } out.writeText(label, null); } out.endElement("select"); }
Example 7
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Given a List of SelectItems render the select options * * @param out * @param items * List of SelectItems * @param selected * seelcted choice * @param clientId * the id * @param styleClass * the optional style class * @param component * the component being rendered * @throws IOException */ public static void renderMenu(ResponseWriter out, List items, int selected, String clientId, String styleClass, UIComponent component) throws IOException { // // debug lines // out.writeText("startElement select", null); // if (true) return; out.startElement("select", component); out.writeAttribute("name", clientId, "id"); out.writeAttribute("id", clientId, "id"); if (styleClass != null) { out.writeAttribute("class", styleClass, "styleClass"); } Iterator iter = items.iterator(); while (iter.hasNext()) { SelectItem si = (SelectItem) iter.next(); Integer value = (Integer) si.getValue(); String label = si.getLabel(); out.startElement("option", component); out.writeAttribute("value", value, null); if (value.intValue() == selected) { out.writeAttribute("selected", "selected", null); } out.writeText(label, null); } out.endElement("select"); }
Example 8
Source File: DataTableRenderer.java From ctsms with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected void encodeFilter(FacesContext context, DataTable table, Column column) throws IOException { Map<String, String> params = context.getExternalContext().getRequestParameterMap(); ResponseWriter writer = context.getResponseWriter(); ValueExpression filterBy = column.getValueExpression("filterBy"); String filterField = null; if (filterBy != null) { filterField = resolveStaticField(filterBy); } String filterId = column.getClientId(context) + "_filter"; String filterValue = params.containsKey(filterId) ? params.get(filterId) : table.getFilters().get(filterField); String filterStyleClass = column.getFilterStyleClass(); if (column.getValueExpression("filterOptions") == null) { filterStyleClass = filterStyleClass == null ? DataTable.COLUMN_INPUT_FILTER_CLASS : DataTable.COLUMN_INPUT_FILTER_CLASS + " " + filterStyleClass; writer.startElement("input", null); writer.writeAttribute("id", filterId, null); writer.writeAttribute("name", filterId, null); writer.writeAttribute("class", filterStyleClass, null); writer.writeAttribute("value", filterValue, null); writer.writeAttribute("autocomplete", "off", null); if (column.getFilterStyle() != null) { writer.writeAttribute("style", column.getFilterStyle(), null); } if (column.getFilterMaxLength() != Integer.MAX_VALUE) { writer.writeAttribute("maxlength", column.getFilterMaxLength(), null); } writer.endElement("input"); } else { filterStyleClass = filterStyleClass == null ? DataTable.COLUMN_FILTER_CLASS : DataTable.COLUMN_FILTER_CLASS + " " + filterStyleClass; writer.startElement("select", null); writer.writeAttribute("id", filterId, null); writer.writeAttribute("name", filterId, null); writer.writeAttribute("class", filterStyleClass, null); SelectItem[] itemsArray = getFilterOptions(column); for (SelectItem item : itemsArray) { Object itemValue = item.getValue(); writer.startElement("option", null); writer.writeAttribute("value", item.getValue(), null); if (itemValue != null && String.valueOf(itemValue).equals(filterValue)) { writer.writeAttribute("selected", "selected", null); } writer.writeText(item.getLabel(), null); writer.endElement("option"); } writer.endElement("select"); } }
Example 9
Source File: UserSubscriptionsLazyDataModel.java From development with Apache License 2.0 | 4 votes |
List<Subscription> toSubscriptionList(List<POSubscription> poSubs) { ArrayList<Subscription> list = new ArrayList<>(); for (POSubscription poSub : poSubs) { String subscriptionId = poSub.getId(); Subscription sub = new Subscription(); sub.setId(subscriptionId); List<POServiceRole> roles = poSub.getRoles(); sub.setRolesRendered(!roles.isEmpty()); List<SelectItem> items = new ArrayList<>(); for (POServiceRole r : roles) { SelectItem si = new SelectItem(String.format("%s:%s", Long.valueOf(r.getKey()), r.getId()), r.getName()); if (r.getName().equalsIgnoreCase(UnitRoleType.USER.name())) { items.add(0, si); } else { items.add(si); } } sub.setRoles(items); if (model.getSelectedSubsIds().containsKey(subscriptionId)) { Boolean selected = model.getSelectedSubsIds().get( subscriptionId); sub.setSelected(selected); } else { sub.setSelected(poSub.isAssigned()); } String selectedRole = null; if (poSub.getUsageLicense() != null && poSub.getUsageLicense().getPoServieRole() != null) { POServiceRole poServiceRole = poSub.getUsageLicense() .getPoServieRole(); long roleKey = poServiceRole.getKey(); String roleId = poServiceRole.getId(); selectedRole = String.format("%s:%s", Long.valueOf(roleKey), roleId); sub.setLicKey(poSub.getUsageLicense().getKey()); sub.setLicVersion(poSub.getUsageLicense().getVersion()); } if (model.getChangedRoles().containsKey(subscriptionId)) { String displayedRole = model.getChangedRoles().get( subscriptionId); for (SelectItem item : items) { if (item.getLabel().equals(displayedRole)) { selectedRole = (String) item.getValue(); } } } sub.setSelectedRole(selectedRole); list.add(sub); } return list; }
Example 10
Source File: SelectMultiMenuRenderer.java From BootsFaces-OSP with Apache License 2.0 | 3 votes |
/** * Renders a single <option> tag. For some reason, * <code>SelectItem</code> and <code>UISelectItem</code> don't share a * common interface, so this method is repeated twice. * * @param rw * The response writer * @param selectItem * The current SelectItem * @param selectedOption * the currently selected option * @throws IOException * thrown if something's wrong with the response writer */ protected void renderOption(ResponseWriter rw, SelectItem selectItem, String[] selectedOption, int index) throws IOException { String itemLabel = selectItem.getLabel(); final String description = selectItem.getDescription(); final Object itemValue = selectItem.getValue(); renderOption(rw, selectedOption, index, itemLabel, description, itemValue); }
Example 11
Source File: SelectOneMenuRenderer.java From BootsFaces-OSP with Apache License 2.0 | 3 votes |
/** * Renders a single <option> tag. For some reason, <code>SelectItem</code> * and <code>UISelectItem</code> don't share a common interface, so this method * is repeated twice. * * @param rw * The response writer * @param selectItem * The current SelectItem * @throws IOException * thrown if something's wrong with the response writer */ protected void renderOption(FacesContext context, SelectOneMenu menu, ResponseWriter rw, SelectItem selectItem, int index, UIComponent itemComponent, boolean isSelected) throws IOException { String itemLabel = selectItem.getLabel(); final String description = selectItem.getDescription(); final Object itemValue = selectItem.getValue(); renderOption(context, menu, rw, index, itemLabel, description, itemValue, selectItem.isDisabled(), selectItem.isEscape(), itemComponent, isSelected); }