开发者

JSF Compound EL expression

开发者 https://www.devze.com 2023-02-04 14:48 出处:网络
I am trying to validate a inputText box based on the selection of a CheckBox as shown below. < <h:inputText required=\"#{param[facesContext.externalContext.response.namespace\'form:checkBoxId\

I am trying to validate a inputText box based on the selection of a CheckBox as shown below. < <h:inputText required="#{param[facesContext.externalContext.response.namespace'form:checkBoxId']}"> >.

The issue is as you see, the component Ids are dynamic, I should be able to use facesContext.externalContext.resp开发者_开发百科onse.namespace inside the EL expression. Is there a solution to it, appreciate any suggestions.

Thanks.


Just bind the UIComponent to a page scoped property and access its getValue() method.

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

As to the dynamicness, you can also go around by just giving it a fixed id.

<h:form id="form">
    <h:selectBooleanCheckbox id="checkbox" />
    <h:inputText required="#{not empty param['form:checkbox'] and param['form:checkbox']}" />
</h:form>

It's however only ugly when it gets lengthy.

0

精彩评论

暂无评论...
验证码 换一张
取 消