JSF复合EL表达式

时间:2011-01-12 17:46:38

标签: jsf el

我正在尝试根据CheckBox的选择验证inputText框,如下所示。  < <h:inputText required="#{param[facesContext.externalContext.response.namespace'form:checkBoxId']}"> >

问题如你所见,组件ID是动态的,我应该能够在EL表达式中使用facesContext.externalContext.response.namespace。是否有解决方案,感谢任何建议。

感谢。

1 个答案:

答案 0 :(得分:0)

只需将UIComponent绑定到页面范围属性并访问其getValue()方法。

<h:selectBooleanCheckbox binding="#{checkbox}" />
<h:inputText required="#{not empty checkbox.value and checkbox.value}" />

至于动态性,你也可以给它一个固定的id。

<h:form id="form">
    <h:selectBooleanCheckbox id="checkbox" />
    <h:inputText required="#{not empty param['form:checkbox'] and param['form:checkbox']}" />
</h:form>
然而,当它变得冗长时,它只是丑陋。

相关问题