当前位置: 首页>>代码示例>>Java>>正文


Java UISelectItem类代码示例

本文整理汇总了Java中javax.faces.component.UISelectItem的典型用法代码示例。如果您正苦于以下问题:Java UISelectItem类的具体用法?Java UISelectItem怎么用?Java UISelectItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UISelectItem类属于javax.faces.component包,在下文中一共展示了UISelectItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSelectOneChoice

import javax.faces.component.UISelectItem; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void testSelectOneChoice() throws IOException
{
  CoreSelectOneChoice choice = new CoreSelectOneChoice();
  choice.setSimple(true);
  choice.setValue(new Integer(2));
  for (int i = 0 ; i < 10; i++)
  {
    UISelectItem selectItem  = new UISelectItem();
    selectItem.setItemLabel("Item " + i);
    selectItem.setItemValue(new Integer(i));
    choice.getChildren().add(selectItem);
  }

  UIViewRoot root = createTestTree(choice, "testSelectOneChoice");
  renderRoot(root);

  root = createTestTree(choice, "testSelectOneChoice2");
  renderRoot(root);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:21,代码来源:CoreRenderKitPerf.java

示例2: testRISelectOneMenu

import javax.faces.component.UISelectItem; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void testRISelectOneMenu() throws IOException
{
  //
  HtmlSelectOneMenu menu = new HtmlSelectOneMenu();
  menu.setValue(new Integer(2));
  for (int i = 0 ; i < 10; i++)
  {
    UISelectItem selectItem  = new UISelectItem();
    selectItem.setItemLabel("Item " + i);
    selectItem.setItemValue("" + i);
    menu.getChildren().add(selectItem);
  }

  UIViewRoot root = createTestTree(menu, "testRISelectOneMenu");
  renderRoot(root);

  root = createTestTree(menu, "testRISelectOneNavigation2");
  renderRoot(root);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:21,代码来源:CoreRenderKitPerf.java

示例3: testSelectOneRadio

import javax.faces.component.UISelectItem; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void testSelectOneRadio() throws IOException
{
  CoreSelectOneRadio radio = new CoreSelectOneRadio();
  radio.setSimple(true);
  radio.setValue(new Integer(2));
  for (int i = 0 ; i < 10; i++)
  {
    UISelectItem selectItem  = new UISelectItem();
    selectItem.setItemLabel("Item " + i);
    selectItem.setItemValue(new Integer(i));
    radio.getChildren().add(selectItem);
  }

  UIViewRoot root = createTestTree(radio, "testSelectOneRadio");
  renderRoot(root);

  root = createTestTree(radio, "testSelectOneRadio2");
  renderRoot(root);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:21,代码来源:CoreRenderKitPerf.java

示例4: testRISelectOneRadio

import javax.faces.component.UISelectItem; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void testRISelectOneRadio() throws IOException
{
  //
  HtmlSelectOneRadio radio = new HtmlSelectOneRadio();
  radio.setValue(new Integer(2));
  for (int i = 0 ; i < 10; i++)
  {
    UISelectItem selectItem  = new UISelectItem();
    selectItem.setItemLabel("Item " + i);
    selectItem.setItemValue("" + i);
    radio.getChildren().add(selectItem);
  }

  UIViewRoot root = createTestTree(radio, "testRISelectOneRadio");
  renderRoot(root);

  root = createTestTree(radio, "testRISelectOneRadio2");
  renderRoot(root);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:21,代码来源:CoreRenderKitPerf.java

示例5: findNextValidChild

import javax.faces.component.UISelectItem; //导入依赖的package包/类
/**
 * @return the next valid child for processing
 */
private Object findNextValidChild() {

	if (kids.hasNext()) {
		Object next = kids.next();
		while (kids.hasNext()
				&& !(next instanceof UISelectItem || next instanceof UISelectItems)) {
			next = kids.next();
		}
		if (next instanceof UISelectItem || next instanceof UISelectItems) {
			return next;
		}
	}
	return null;

}
 
开发者ID:fpuna-cia,项目名称:karaku,代码行数:19,代码来源:SelectItemsIterator.java

示例6: addEmptySelectItem

import javax.faces.component.UISelectItem; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void addEmptySelectItem(final UIComponent component, final Class<?> enumType, final ResourceBundle translation) {
	UISelectItem empty = new UISelectItem();
	try {
		String transKey = enumType.getName() + ".(SELECT_ONE)";
		empty.setItemLabel(translation.getString(transKey));
	} catch(Exception e) {
		try {
			empty.setItemLabel(translation.getString("(SELECT_ONE)"));
		} catch(Exception e2) {
			empty.setItemLabel(" - Select One -");
		}
	}
	empty.setItemValue("");
	component.getChildren().add(empty);
	empty.setParent(component);
}
 
开发者ID:jesse-gallagher,项目名称:XPages-Scaffolding,代码行数:18,代码来源:ComponentMap.java

示例7: populateEnumSelectItems

import javax.faces.component.UISelectItem; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void populateEnumSelectItems(final UIComponent component, final Class<?> enumType, final ResourceBundle translation) {

	Enum<?>[] constants = (Enum<?>[])enumType.getEnumConstants();
	for(Enum<?> constant : constants) {
		UISelectItem item = new UISelectItem();

		// Look for a localized label
		String label = constant.name();
		if(translation != null) {
			String transKey = enumType.getName() + "." + constant.name();
			try {
				label = translation.getString(transKey);
			} catch(Exception e) {
				// Ignore
			}
		}

		item.setItemLabel(label);

		item.setItemValue(constant);
		component.getChildren().add(item);
		item.setParent(component);
	}
}
 
开发者ID:jesse-gallagher,项目名称:XPages-Scaffolding,代码行数:26,代码来源:ComponentMap.java

示例8: findNextValidChild

import javax.faces.component.UISelectItem; //导入依赖的package包/类
/**
 * @return the next valid child for processing
 */
private Object findNextValidChild() {
	if (kids.hasNext()) {
		Object next = kids.next();
		while (kids.hasNext() && !(next instanceof UISelectItem || next instanceof UISelectItems)) {
			next = kids.next();
		}
		if (next instanceof UISelectItem || next instanceof UISelectItems) {
			return next;
		}
	}
	return null;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:16,代码来源:SelectItemsIterator.java

示例9: getDefaultSelectItem

import javax.faces.component.UISelectItem; //导入依赖的package包/类
private UISelectItem getDefaultSelectItem() {

		if (defaultSelectItem == null) {
			defaultSelectItem = KarakuComponentFactory.getNewSelectItem();
			defaultSelectItem.setItemLabel(I18nHelper
					.getMessage(DEFAULT_LABEL_TEXT));
			defaultSelectItem.setId(getId() + "_" + DEFAULT_LABEL_ID);
		}

		return defaultSelectItem;
	}
 
开发者ID:fpuna-cia,项目名称:karaku,代码行数:12,代码来源:ComboBoxField.java

示例10: toSelectItem

import javax.faces.component.UISelectItem; //导入依赖的package包/类
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;
}
 
开发者ID:TheCoder4eu,项目名称:BootsFaces-OSP,代码行数:14,代码来源:SelectItemUtils.java

示例11: renderOptions

import javax.faces.component.UISelectItem; //导入依赖的package包/类
/**
 * Parts of this class are an adapted version of
 * InputRenderer#getSelectItems() of PrimeFaces 5.1.
 *
 * @param rw
 * @param selectedOption
 * @throws IOException
 */
protected void renderOptions(FacesContext context, ResponseWriter rw, String[] selectedOption, SelectMultiMenu menu)
		throws IOException {
	Converter converter = menu.getConverter();
	List<SelectItemAndComponent> items = SelectItemUtils.collectOptions(context, menu, converter);

	for (int index = 0; index < items.size(); index++) {
		Object option = items.get(index).getSelectItem();
		if (option instanceof SelectItem) {
			renderOption(rw, (SelectItem) option, selectedOption, index);
		} else {
			renderOption(rw, (UISelectItem) option, selectedOption, index);
		}
	}
}
 
开发者ID:TheCoder4eu,项目名称:BootsFaces-OSP,代码行数:23,代码来源:SelectMultiMenuRenderer.java

示例12: encodeSelectOne

import javax.faces.component.UISelectItem; //导入依赖的package包/类
/**
 * Render the beginning of the command button to the response contained in
 * the specified FacesContext.
 *
 * @param context
 *            the context.
 * @throws IOException
 *             exception.
 */
protected void encodeSelectOne(final FacesContext context)
        throws IOException {
    getSelectOne().setRendered(!isReadonly());
    if (!isReadonly()) {
        // Remove no selection label.
        if (!getSelectOne().getChildren().isEmpty()
                && getSelectOne().getChildren().get(0) instanceof UISelectItem) {
            getSelectOne().getChildren().remove(0);
        }
        // Add no selection label.
        if (getNoSelectionLabel() != null) {
            final UISelectItem selectItem = new UISelectItem();
            selectItem.setNoSelectionOption(true);
            selectItem.setItemLabel(getNoSelectionLabel());
            getSelectOne().getChildren().add(0, selectItem);
        }
        // If empty values, hide selectOneMenu.
        if (ListUtil.isList(getSelectItems().getValue())) {
            final List<?> list = ObjectUtil.cast(getSelectItems()
                    .getValue(), List.class);
            getSelectOne().setRendered(!list.isEmpty());
        } else {
            getSelectOne().setRendered(true);
        }
    }
}
 
开发者ID:qjafcunuas,项目名称:jbromo,代码行数:36,代码来源:AbstractUIOutputSelectOne.java

示例13: getSelectItems

import javax.faces.component.UISelectItem; //导入依赖的package包/类
/**
 *
 * @param component  UIComponent
 * @param converter For UISelectItem and UIXSelectItem children of the
 *                  component, use the converter to convert itemValue Strings
 *                  when creating the javax.faces.model.SelectItem Object if
 *                  the child's value is not an instanceof SelectItem.
 * @param filteredItems to exclude SelectItemGroup components
 * @return a List of javax.faces.model.SelectItem Objects that we get or
 *         create from the component's children.
 *         OR
 *         java.util.Collections.emptyList if component has no children or
 *         the component isn't a javax.faces.component.ValueHolder. else
 */
@SuppressWarnings("unchecked")
static public List<SelectItem> getSelectItems(
  UIComponent  component,
  Converter    converter,
  boolean filteredItems)
{

  int childCount = component.getChildCount();
  if (childCount == 0)
    return Collections.emptyList();

  // Make sure we haven't accidentally stumbled outside of
  // the UIXSelectXXX world.
  if (!(component instanceof ValueHolder))
    return Collections.emptyList();

  FacesContext context = FacesContext.getCurrentInstance();
  List<SelectItem> items = null;
  for(UIComponent child : (List<UIComponent>)component.getChildren())
  {
    // f:selectItem
    if (child instanceof UISelectItem)
    {
      if (items == null)
        items = new ArrayList<SelectItem>(childCount);
      _addSelectItem(context, 
                     component, 
                     (UISelectItem) child, 
                     items, 
                     converter);
    }
    // f:selectItems
    else if (child instanceof UISelectItems)
    {
      if (items == null)
        items = new ArrayList<SelectItem>(childCount);
      addSelectItems((UISelectItems) child, items, filteredItems );
    }
    // tr:selectItem
    else if (child instanceof UIXSelectItem)
    {
      if (items == null)
        items = new ArrayList<SelectItem>(childCount);
      _addUIXSelectItem(context,
                        component,
                        (UIXSelectItem) child, 
                        items, 
                        converter);
      

      
    }
  }

  if (items == null)
    return Collections.emptyList();

  return items;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:74,代码来源:SelectItemSupport.java

示例14: getSelectItemCount

import javax.faces.component.UISelectItem; //导入依赖的package包/类
/**
 * 
 * @param component  UIComponent
 * @return item count
 */
@SuppressWarnings("unchecked")
static public int getSelectItemCount(
  UIComponent  component)
{ 
  int itemCount = 0;
  int childCount = component.getChildCount();
  if (childCount == 0)
    return itemCount;

  // Make sure we haven't accidentally stumbled outside of
  // the UIXSelectXXX world.
  if (!(component instanceof ValueHolder))
    return itemCount;

  for(UIComponent child : (List<UIComponent>)component.getChildren())
  {
    if (child instanceof UISelectItem ||
        child instanceof UIXSelectItem)
    {
      itemCount++;
    }
    // f:selectItems
    else if (child instanceof UISelectItems)
    {        
      Object value = ((UISelectItems)child).getValue();
      if (value instanceof SelectItem)
      {
        itemCount++;
      }
      else if (value instanceof Object[])
      {
        Object[] array = (Object[]) value;
        itemCount = itemCount + array.length;
      }
      else if (value instanceof Collection)
      {
        itemCount = itemCount + ((Collection) value).size();  
      }
      else if (value instanceof Map)
      {        
        itemCount = itemCount + ((Map) value).size();  
      }                        
    }
  }
  
  return itemCount;
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:53,代码来源:SelectItemSupport.java

示例15: getNewSelectItem

import javax.faces.component.UISelectItem; //导入依赖的package包/类
/**
 * @return
 */
public static UISelectItem getNewSelectItem() {

	return getComponent(UISelectItem.class, UISelectItem.COMPONENT_TYPE,
			null);
}
 
开发者ID:fpuna-cia,项目名称:karaku,代码行数:9,代码来源:KarakuComponentFactory.java


注:本文中的javax.faces.component.UISelectItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。