• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java UISelectItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: clear

import javax.faces.component.UISelectItem; //导入依赖的package包/类
public void clear() {

		List<UISelectItem> toRetain = ListHelper
				.getAsList(getDefaultSelectItem());
		getBind().getChildren().retainAll(toRetain);
	}
 
开发者ID:fpuna-cia,项目名称:karaku,代码行数:7,代码来源:ComboBoxField.java


示例17: decode

import javax.faces.component.UISelectItem; //导入依赖的package包/类
/** Receives the value from the client and sends it to the JSF bean. */
@Override
public void decode(FacesContext context, UIComponent component) {
	SelectMultiMenu menu = (SelectMultiMenu) component;
	if (menu.isDisabled() || menu.isReadonly()) {
		return;
	}
	List<String> submittedValues = new ArrayList<String>();
	String clientId = menu.getClientId().replace(":", "-");
	Map<String, String> map = context.getExternalContext().getRequestParameterMap();
	for (String key : map.keySet()) {
		if (key.startsWith(clientId + ":")) {
			submittedValues.add(map.get(key));
		}
	}
	Converter converter = menu.getConverter();
	List<SelectItemAndComponent> items = SelectItemUtils.collectOptions(context, menu, converter);


	if (!submittedValues.isEmpty()) {
		// check for manipulated input
		String result = null;
		for (String submittedOptionValue : submittedValues) {
			boolean found = false;
			for (int index = 0; index < items.size(); index++) {
				Object currentOption = items.get(index).getSelectItem();
				String currentOptionValueAsString;
				Object currentOptionValue;
				if (currentOption instanceof SelectItem) {
					currentOptionValue = ((SelectItem) currentOption).getValue();
				} else {
					currentOptionValue = ((UISelectItem) currentOption).getItemValue();
				}
				if (currentOptionValue instanceof String) {
					currentOptionValueAsString = (String) currentOptionValue;
				} else
					currentOptionValueAsString = String.valueOf(index);
				if ("".equals(currentOptionValueAsString) && submittedOptionValue.equalsIgnoreCase("on")) {
					// this is a special case which occurs when the value is
					// set to "".
					// In this case, the browser sends "on" instead of the
					// empty string.
					submittedOptionValue = "";
				}
				if (submittedOptionValue.equals(currentOptionValueAsString)) {
					if (null == result)
						result = currentOptionValueAsString;
					else
						result += "," + currentOptionValue;
					found = true;
					break;
				}
			}
			if (!found) {
				FacesMessages.error(clientId, "Invalid data",
						"Couldn't set the value of the b:selectMultiMenu because an option that wasn't defined by the JSF source code was passed.");
				menu.setSubmittedValue(result);
				menu.setValid(false);
				return;
			}
		}
		menu.setSubmittedValue(result);
		menu.setValid(true);
		new AJAXRenderer().decode(context, component, clientId);
		return;
	}

	menu.setSubmittedValue("");
	menu.setValid(true);
	new AJAXRenderer().decode(context, component, clientId);
}
 
开发者ID:TheCoder4eu,项目名称:BootsFaces-OSP,代码行数:72,代码来源:SelectMultiMenuRenderer.java


示例18: renderOption

import javax.faces.component.UISelectItem; //导入依赖的package包/类
/**
 * 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, UISelectItem selectItem, String[] selectedOption, int index)
		throws IOException {

	String itemLabel = selectItem.getItemLabel();
	final String itemDescription = selectItem.getItemDescription();
	final Object itemValue = selectItem.getItemValue();

	boolean isItemLabelBlank = itemLabel == null || itemLabel.trim().length() == 0;
	itemLabel = isItemLabelBlank ? "&nbsp;" : itemLabel;

	renderOption(rw, selectedOption, index, itemLabel, itemDescription, itemValue);
}
 
开发者ID:TheCoder4eu,项目名称:BootsFaces-OSP,代码行数:27,代码来源:SelectMultiMenuRenderer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LongDeserializer类代码示例发布时间:2022-05-22
下一篇:
Java GoalType类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap