根据属性文件渲染SelectItem
我有一个 selectOneRadio 菜单,其中包含一些 selectItem。我想显示基于属性文件的选择。例如,如果商店没有信用卡读卡器,那么我不会显示信用选项。应该有一个配置/属性文件指定显示什么和不显示什么。
有办法实现吗?我假设我需要将属性文件读入支持 bean,然后拥有类似“渲染”属性的内容。但是,我刚刚尝试过,“渲染”似乎不适用于 selectItem。
<h:selectOneRadio id="selectedPaymentMethod" layout="pageDirection"
value="#{selectPaymentMethodAction.selectedPaymentMethod}">
<f:selectItem itemValue="online" itemLabel="#{paymentMsg['payment.online.lbl']}"/>
<f:selectItem itemValue="cash" itemLabel="#{paymentMsg['payment.cash.lbl']}"/>
<f:selectItem itemValue="credit" itemLabel="#{paymentMsg['payment.credit.lbl']}"/>
<f:selectItem itemValue="debit" itemLabel="#{paymentMsg['payment.debit.lbl']}"/>
</h:selectOneRadio>
I have a selectOneRadio menu with some selectItem's in them. I want to show the choices based on a property file. For example, if a store doesn't have a credit card reader, then I wouldn't show the credit option. There should be a config/properties file specifiying what is shown and what is not.
Is there a way to accomplish that? I assume I need to read the properties file into the backing bean and then have something like a 'rendered' attribute. However, I just tried and 'rendered' doesn't seem to work for selectItem.
<h:selectOneRadio id="selectedPaymentMethod" layout="pageDirection"
value="#{selectPaymentMethodAction.selectedPaymentMethod}">
<f:selectItem itemValue="online" itemLabel="#{paymentMsg['payment.online.lbl']}"/>
<f:selectItem itemValue="cash" itemLabel="#{paymentMsg['payment.cash.lbl']}"/>
<f:selectItem itemValue="credit" itemLabel="#{paymentMsg['payment.credit.lbl']}"/>
<f:selectItem itemValue="debit" itemLabel="#{paymentMsg['payment.debit.lbl']}"/>
</h:selectOneRadio>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
,您可以根据捆绑文件使用List
提供该内容。这样您就可以使用常用的 Java 代码来控制是否应添加该项目。例如
与
Use
<f:selectItems>
which you feed with aList<SelectItem>
based on the bundle file. This way you can control using usual Java code whether the item should be added or not.E.g.
with