另一个jsf< f:selectItems> itemValue和消息包问题 [英] another jsf <f:selectItems> itemValue and message bundle question

查看:143
本文介绍了另一个jsf< f:selectItems> itemValue和消息包问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有selectitems的selectOneMenu. 如果我使用

i have a selectOneMenu with selectitems. if i use

<f:selectItem itemValue="3" itemLabel="#{hrBundle['phoneType3']}"/>

效果很好,显示了本地化标签.我在列表中有更多选项,当我使用f:selectItems时,它将停止工作. 这段代码:

it works well, displaying the localized label. i have more options inside a List and when i use f:selectItems, it stops working. this code:

<f:selectItems value="#{values}" var="item" itemLabel="#{hrBundle[item.label]}" itemValue="item.value"/>

将键("phoneType3")显示为标签,甚至

shows the key('phoneType3') as label, and even

<f:selectItems value="#{values}" var="item" itemLabel="#{hrBundle['phoneType3']}" itemValue="item.value"/>

(上面的"f:selectItem"为硬编码")显示键("phoneType3"),而不显示本地化标签.

('hardcoded' as the single f:selectItem above) displays the key ('phoneType3') instead of the localized label.

知道我在做什么错吗?

any idea what i am doing wrong?

推荐答案

这取决于捆绑文件中的密钥是什么.如果捆绑包中的密钥包含item.value的内容,请执行以下操作:

It depends on what the key in your bundle file is. If the key in your bundle ist the content of item.value, do the following:

<f:selectItems value="#{myBean.values}" 
 var="item" 
 itemLabel="#{hrBundle[item.value]}" 
 itemValue="#{item.value}"/>

我不知道这是否是您的原始代码.如果是,请注意以下几点:

I don't know, if this is your original code. If yes, notice the following:

  1. 您必须引用支持bean 在您的value属性中(如下所示) 上方:将myBean替换为您的 豆名称).
  2. itemValue属性需要一个 el表达式:itemValue= "#{item.value}"
  1. You have to reference a backing bean in your value attribute (as shown above: replace myBean with your beans name).
  2. The itemValue attribute needs an el expression as well: itemValue= "#{item.value}"

这篇关于另一个jsf&lt; f:selectItems&gt; itemValue和消息包问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆