选择一个菜单项显示ItemValue而不是ItemLabel

时间:2017-08-24 10:58:13

标签: jsf

我需要本地化selectOneMenu中的项目。但是,不是采用变量的标签,而是显示项目的价值。 辅助bean包含以下内容:

private static final String[] UPGRADE = { "Standard", "Privilege", "Basic" };
private static final String[] UPGRADE_LABELS = {Resource.getMessage("lblStandard"), Resource.getMessage("lblPrivilege"), Resource.getMessage("lblBasic")};

for(int i = 0;i<UPGRADE.length;i++) {
    String value = UPGRADE[i];
    String label = UPGRADE_LABELS[i];
    item = new SelectItem(value, label);
    allLevelStatus.add(item);
}

这是xhtml部分:

<h:selectOneMenu style="width:125px; font-size:12px;" id="selectstatusTypePro"
                 value="#{startNotificationBean.levelStatus}" disabled="#{startNotificationBean.editUpdate}">
    <f:selectItem itemLabel="#{msg['lblAny']}" itemValue="Any" />
    <f:selectItems value="#{startNotificationBean.allLevelStatus}"/>
</h:selectOneMenu>

0 个答案:

没有答案