【发布时间】:2015-10-27 17:08:33
【问题描述】:
我想为 xhtml 页面中的输入分配一个动态值。 ManagedBean 包含 3 个字符串属性:customField1、customField2 和 customField3
在 xhtml 页面中,我将值列表循环到 custruct 组件:
<ui:repeat value="#{listBean.customFields}" var="item" varStatus="status">
<div >
<p:outputLabel value="#{item.label}" />
<br />
<c:set var="test" value="#{'myBean.customField'.concat(status.index)}"/>
<p:inputText value="#{test}" />
</div>
</ui:repeat>
我为连接所做的操作不起作用,因为它认为整个表达式是一个字符串,因此它无法将“#{test}”与 bean 属性绑定。
您认为在 jsf 中可以做到这一点?
提前致谢!
【问题讨论】:
-
你不能只做
value="#{myBean.customField}#{status.index}" -
我试过了..它不起作用 =>javax.el.PropertyNotFoundException: page.xhtml value="#{myBean.customField}#{status.index}": 类 'com. xxx.yyy.zzz.MyBean' 没有属性 'customField'
-
customField 在您的支持 bean 中是否有公共 getter/setter?
-
支持 bean 仅包含 customField1、customField2 和 customField3 以及公共 getter 和 setter
-
请忽略 j.con 的 cmets。他显然是带着 [java] 标签(Kukeltje 理所当然地删除了它)来到这里的,只是在做盲目的猜测。在未来的 JSF 问题中,请不要使用 [java] 标签。
标签: jsf jstl managed-bean