本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例15: getNewSelectItem
import javax.faces.component.UISelectItem; //导入依赖的package包/类
/**
* @return
*/
public static UISelectItem getNewSelectItem() {
return getComponent(UISelectItem.class, UISelectItem.COMPONENT_TYPE,
null);
}