本文整理汇总了Java中javax.faces.model.SelectItem.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java SelectItem.getValue方法的具体用法?Java SelectItem.getValue怎么用?Java SelectItem.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.faces.model.SelectItem
的用法示例。
在下文中一共展示了SelectItem.getValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getItemValue
import javax.faces.model.SelectItem; //导入方法依赖的package包/类
/**
* Return the value to output for an item.
*/
static public Object getItemValue(
FacesContext context,
UIComponent component,
SelectItem item,
Converter converter,
boolean valuePassThru,
int index)
{
if (!valuePassThru)
{
return IntegerUtils.getString(index);
}
else
{
Object itemValue = item.getValue();
if ((itemValue != null) && (converter != null))
{
itemValue = converter.getAsString(context,
component,
itemValue);
}
return itemValue;
}
}
示例2: _convertIndexedSubmittedValue
import javax.faces.model.SelectItem; //导入方法依赖的package包/类
/**
* Call this method only when the valuePassThru attribute on the selectOne
* component is not set to true.
* This indicates that the client-side value
* is an index. We need to convert that index into its real value.
* @param component
* @param submittedValue the submittedValue. Since this method is only
* called when the valuePassThru attribute on the selectOne component is
* not true, then the submittedValue in this case is an index into a List.
* @return the Object value at that index specified in submittedValue,
* or null.
*/
private Object _convertIndexedSubmittedValue(
FacesContext context,
UIComponent component,
Object submittedValue
) throws ConverterException
{
FacesBean bean = getFacesBean(component);
Converter converter = getConverter(component, bean);
if ( converter == null)
converter = getDefaultConverter(context, component, bean);
List<SelectItem> selectItems = getSelectItems(component, converter, true);
int index = __getIndex(context, submittedValue, selectItems);
if (index < 0)
return null;
SelectItem item = selectItems.get(index);
if (item != null)
{
Object converted = item.getValue();
if (converter != null && converted != null)
{
converted = converter.getAsObject(context, component, converted.toString());
}
return converted;
}
else
{
return null;
}
}
示例3: resolveIndex
import javax.faces.model.SelectItem; //导入方法依赖的package包/类
private int resolveIndex(
SelectItem item,
Object value,
int index)
{
if(item instanceof SelectItemGroup)
{
int result;
for(SelectItem subItem : ((SelectItemGroup)item).getSelectItems())
{
result = resolveIndex( subItem, value, index++ );
if(result >= 0)
{
return result;
}
}
}
else
{
if (value == null)
{
Object itemValue = item.getValue();
// =-=AEW Treat the empty string as if it were null
if ((itemValue == null) || "".equals(itemValue))
return index;
}
else
{
if (value.equals(item.getValue()) || (value.getClass().isEnum() && item.getValue() != null && value.toString().equals( item.getValue().toString() )))
return index;
}
}
return -1;
}
示例4: toSubscriptionList
import javax.faces.model.SelectItem; //导入方法依赖的package包/类
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;
}
示例5: selectItemsRenderContent
import javax.faces.model.SelectItem; //导入方法依赖的package包/类
protected void selectItemsRenderContent(
UIXRenderingContext context,
UINode node
) throws IOException
{
UIComponent component = OptionContainerRenderer.__getUIComponent(context,
node);
if (component != null)
{
List<SelectItem> selectItems =
SelectItemSupport.getSelectItems(component,
SelectItemSupport.getConverter(
component));
// if NOTHING IS SELECTED
// we must render a blank item first, if the app developer
// didn't already add one.
// We use the noSelectionLabel's attribute value if it is available
// (It might say something like "None", for example.
// Otherwise, we just leave it blank.
// now check if nothing is selected by default.
boolean isNothingSelected = _isNothingSelected(component,
selectItems);
if (selectItems != null && !selectItems.isEmpty() && isNothingSelected)
{
// now check if the first item is already a blank item.
// if it isn't, render a blank item, using the
// noSelectionLabel attribute value as the itemLabel.
SelectItem firstItem = selectItems.get(0);
Object firstItemValue = firstItem.getValue();
if (!("".equals(firstItemValue)))
{
Object label = component.getAttributes().get(
CoreSelectOneChoice.UNSELECTED_LABEL_KEY);
String noSelectionLabel = (label != null) ? label.toString() : "";
SelectItem item = new SelectItem("", noSelectionLabel, "", false);
renderSelectItem(context, node, component, item,
"", false, false, 0);
}
}
renderSelectItemOptions(context,
node,
component,
selectItems);
}
}
示例6: encodeFilter
import javax.faces.model.SelectItem; //导入方法依赖的package包/类
@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");
}
}