Java Code Examples for javax.faces.model.SelectItem#getLabel()

The following examples show how to use javax.faces.model.SelectItem#getLabel() . 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: DownloadFileSubmissionsBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public SelectItem[] getSiteSectionItems(){
	TotalScoresBean totalScores = (TotalScoresBean) ContextUtil.lookupBean("totalScores");
	List sectionList = totalScores.getSectionFilterSelectItems();
	int numSection = availableSectionItems.size();
	SelectItem[] target = new SelectItem[2];
	ResourceLoader rb = new ResourceLoader("org.sakaiproject.tool.assessment.bundle.EvaluationMessages");
	target[0] = new SelectItem(this.SITE, rb.getString("for_all_sections_groups"));

	if (numSection == 1) {
		SelectItem sectionItem = (SelectItem) availableSectionItems.get(0);
		target[1] = new SelectItem(this.ONE_SECTION_GROUP, sectionItem.getLabel());
	}
	else if (numSection > 1) {
		target[1] = new SelectItem(this.SELECTED_SECTIONS_GROUPS, rb.getString("for_selected_sections_groups"));
	}
	return target;
}
 
Example 2
Source File: DownloadFileSubmissionsBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public SelectItem[] getSiteSectionItems(){
	TotalScoresBean totalScores = (TotalScoresBean) ContextUtil.lookupBean("totalScores");
	List sectionList = totalScores.getSectionFilterSelectItems();
	int numSection = availableSectionItems.size();
	SelectItem[] target = new SelectItem[2];
	ResourceLoader rb = new ResourceLoader("org.sakaiproject.tool.assessment.bundle.EvaluationMessages");
	target[0] = new SelectItem(this.SITE, rb.getString("for_all_sections_groups"));

	if (numSection == 1) {
		SelectItem sectionItem = (SelectItem) availableSectionItems.get(0);
		target[1] = new SelectItem(this.ONE_SECTION_GROUP, sectionItem.getLabel());
	}
	else if (numSection > 1) {
		target[1] = new SelectItem(this.SELECTED_SECTIONS_GROUPS, rb.getString("for_selected_sections_groups"));
	}
	return target;
}
 
Example 3
Source File: OperatorOrgBean.java    From development with Apache License 2.0 5 votes vote down vote up
private String getSelectedTenantId() {
    for (SelectItem selectedTenantItem : getSelectableTenants()) {
        if (selectedTenantItem.getValue().toString().equals(selectedTenant)) {
            return selectedTenantItem.getLabel();
        }
    }
    return "";
}
 
Example 4
Source File: ConfirmPublishAssessmentListener.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private String getName(String parameter, SelectItem[] entries) {
if(parameter == null || parameter.isEmpty()) {
	return "";
}

for(SelectItem item : entries) {
	if(item.getValue().equals(parameter)) {
		return item.getLabel();
	}
}

return ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages","extended_time_name_not_found");
 }
 
Example 5
Source File: RendererUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * 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 vote down vote up
/**
 * 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: InputRichTextRenderer.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected String outputFiles(List list, MessageFormat format, boolean first) {
 StringBuffer sb = new StringBuffer();

   for (Iterator i=list.iterator();i.hasNext();) {
      Object value = i.next();

      String url;
      String label;

      if (value instanceof SelectItem) {
         SelectItem item = (SelectItem)value;
         url = item.getValue().toString();
         label = item.getLabel();
      }
      else {
         url = value.toString();
         label = value.toString();
      }

      if (!first) {
         sb.append(',');
      }
      else {
         first = false;
      }
      format.format(new Object[]{label, url}, sb, null);
   }

   return sb.toString();
}
 
Example 8
Source File: RendererUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * 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 9
Source File: InputRichTextRenderer.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected String outputFiles(List list, MessageFormat format, boolean first) {
 StringBuffer sb = new StringBuffer();

   for (Iterator i=list.iterator();i.hasNext();) {
      Object value = i.next();

      String url;
      String label;

      if (value instanceof SelectItem) {
         SelectItem item = (SelectItem)value;
         url = item.getValue().toString();
         label = item.getLabel();
      }
      else {
         url = value.toString();
         label = value.toString();
      }

      if (!first) {
         sb.append(',');
      }
      else {
         first = false;
      }
      format.format(new Object[]{label, url}, sb, null);
   }

   return sb.toString();
}
 
Example 10
Source File: RendererUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * 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 11
Source File: ConfirmPublishAssessmentListener.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private String getName(String parameter, SelectItem[] entries) {
if(parameter == null || parameter.isEmpty()) {
	return "";
}

for(SelectItem item : entries) {
	if(item.getValue().equals(parameter)) {
		return item.getLabel();
	}
}

return ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages","extended_time_name_not_found");
 }
 
Example 12
Source File: SavePublishedSettingsListener.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * helper function for getUserName / getGroupname
 * @param parameter
 * @param entries
 * @return
 */
private String getName(String parameter, SelectItem[] entries) {
	if("".equals(parameter) || entries.length == 0) {
		return "";
	}

	for(SelectItem item : entries) {
		if(item.getValue().equals(parameter)) {
			return item.getLabel();
		}
	}

	return ContextUtil.getLocalizedString("org.sakaiproject.tool.assessment.bundle.AssessmentSettingsMessages","extended_time_name_not_found");
}
 
Example 13
Source File: RendererUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * 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 14
Source File: InputRichTextRenderer.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected String outputFiles(List list, MessageFormat format, boolean first) {
 StringBuffer sb = new StringBuffer();

   for (Iterator i=list.iterator();i.hasNext();) {
      Object value = i.next();

      String url;
      String label;

      if (value instanceof SelectItem) {
         SelectItem item = (SelectItem)value;
         url = item.getValue().toString();
         label = item.getLabel();
      }
      else {
         url = value.toString();
         label = value.toString();
      }

      if (!first) {
         sb.append(',');
      }
      else {
         first = false;
      }
      format.format(new Object[]{label, url}, sb, null);
   }

   return sb.toString();
}
 
Example 15
Source File: RendererUtil.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * 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 16
Source File: InputRichTextRenderer.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected String outputFiles(List list, MessageFormat format, boolean first) {
 StringBuffer sb = new StringBuffer();

   for (Iterator i=list.iterator();i.hasNext();) {
      Object value = i.next();

      String url;
      String label;

      if (value instanceof SelectItem) {
         SelectItem item = (SelectItem)value;
         url = item.getValue().toString();
         label = item.getLabel();
      }
      else {
         url = value.toString();
         label = value.toString();
      }

      if (!first) {
         sb.append(',');
      }
      else {
         first = false;
      }
      format.format(new Object[]{label, url}, sb, null);
   }

   return sb.toString();
}
 
Example 17
Source File: DeleteCustomerPriceModelCtrl.java    From development with Apache License 2.0 5 votes vote down vote up
String getOrgName() {

        DeleteCustomerPriceModelModel m = getModel();
        String orgId = m.getSelectedOrgId();
        String result = orgId;
        List<SelectItem> customers = m.getCustomers();
        for (SelectItem si : customers) {
            if (si.getValue().equals(orgId)) {
                result = si.getLabel();
                break;
            }
        }

        return result;
    }
 
Example 18
Source File: DojoExtLinkSelectRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
@Override
protected void initDojoAttributes(FacesContext context, FacesDojoComponent dojoComponent, Map<String,String> attrs) throws IOException {
    super.initDojoAttributes(context, dojoComponent, attrs);
    if(dojoComponent instanceof UIDojoExtLinkSelect) {
        UIDojoExtLinkSelect c = (UIDojoExtLinkSelect)dojoComponent;

        // Add the different styles/classes
        DojoRendererUtil.addDojoHtmlAttributes(attrs,"listStyle",combineStyles(PROP_LISTSTYLE, c.getStyle())); // $NON-NLS-1$
        DojoRendererUtil.addDojoHtmlAttributes(attrs,"listClass",combineStyleClasses(PROP_LISTCLASS, c.getStyleClass())); // $NON-NLS-1$
        DojoRendererUtil.addDojoHtmlAttributes(attrs,"itemStyle",combineStyles(PROP_ITEMSTYLE, c.getItemStyle())); // $NON-NLS-1$
        DojoRendererUtil.addDojoHtmlAttributes(attrs,"itemClass",combineStyleClasses(PROP_ITEMCLASS, c.getItemStyleClass())); // $NON-NLS-1$
        DojoRendererUtil.addDojoHtmlAttributes(attrs,"firstItemStyle",combineStyles(PROP_FIRSTITEMSTYLE, c.getFirstItemStyle())); // $NON-NLS-1$
        DojoRendererUtil.addDojoHtmlAttributes(attrs,"firstItemClass",combineStyleClasses(PROP_FIRSTITEMCLASS, c.getFirstItemStyleClass())); // $NON-NLS-1$
        DojoRendererUtil.addDojoHtmlAttributes(attrs,"lastItemStyle",combineStyles(PROP_LASTITEMSTYLE, c.getLastItemStyle())); // $NON-NLS-1$
        DojoRendererUtil.addDojoHtmlAttributes(attrs,"lastItemClass",combineStyleClasses(PROP_LASTITEMCLASS, c.getLastItemStyleClass())); // $NON-NLS-1$
        DojoRendererUtil.addDojoHtmlAttributes(attrs,"enabledLinkStyle",(String)getProperty(PROP_ENABLEDLINKSTYLE)); // $NON-NLS-1$
        DojoRendererUtil.addDojoHtmlAttributes(attrs,"enabledLinkClass",(String)getProperty(PROP_ENABLEDLINKCLASS)); // $NON-NLS-1$
        DojoRendererUtil.addDojoHtmlAttributes(attrs,"disabledLinkStyle",(String)getProperty(PROP_DISABLEDLINKSTYLE)); // $NON-NLS-1$
        DojoRendererUtil.addDojoHtmlAttributes(attrs,"disabledLinkClass",(String)getProperty(PROP_DISABLEDLINKCLASS)); // $NON-NLS-1$
        DojoRendererUtil.addDojoHtmlAttributes(attrs,"controlDisabled", (c.isDisabled() ? "true" : "false")); // $NON-NLS-1$ $NON-NLS-2$ $NON-NLS-3$
        DojoRendererUtil.addDojoHtmlAttributes(attrs,"tabindex", (c.isDisabled() ? -1 : c.getTabIndex())); // $NON-NLS-1$
        
        // Generate the list of options as JSON
        StringBuilder b = new StringBuilder();
        JsonBuilder w = new JsonBuilder(b,true);
        w.startArray();

        IValuePickerData d = c.getDataProvider();
        if(d!=null) {
            IPickerResult r = d.readEntries(new SimplePickerOptions(0,MAX_LINKS));
            if(r!=null) {
                for( IPickerEntry e: r.getEntries() ) {
                    Object o = e.getValue();
                    if(o!=null) {
                        addJsonEntry(w,o,e.getLabel());
                    }
                }
            }
        } else {
            Converter converter = c.getConverter();
            // Call the Sun method here. Should we just rewrite it?
            for( Iterator<SelectItem> items = (Iterator<SelectItem>)Util.getSelectItems(context, c); items.hasNext(); ) {
                SelectItem curItem = items.next();
                String value = convertValue(context,c, converter, curItem.getValue());
                if(value!=null) {
                    String label = curItem.getLabel();
                    addJsonEntry(w,value,label);
                }
            }
        }
        
        w.endArray();
        DojoRendererUtil.addDojoHtmlAttributes(attrs,"valueList",b.toString()); // $NON-NLS-1$
    }
}
 
Example 19
Source File: SelectMultiMenuRenderer.java    From BootsFaces-OSP with Apache License 2.0 3 votes vote down vote up
/**
 * Renders a single &lt;option&gt; 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 20
Source File: SelectOneMenuRenderer.java    From BootsFaces-OSP with Apache License 2.0 3 votes vote down vote up
/**
 * Renders a single &lt;option&gt; 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);
}