make ah:只有在选中复选框时才需要inputText

SDP*_*SDP 4 checkbox jsf input selected required

我有一个数据表,其中的行包含一些必需的输入文本字段.每行还有一个名为delete的复选框.我想required = "true"只在选中复选框时才有.我怎样才能做到这一点?

Bal*_*usC 8

只需让输入的required属性检查复选框的值即可.

这是一个启动示例:

<h:form>
    <h:dataTable value="#{bean.list}" var="item">
        <h:column><h:selectBooleanCheckbox binding="#{checkbox}" /></h:column>
        <h:column><h:inputText id="input" value="#{item.value}" required="#{checkbox.value == 'true'}" /></h:column>
        <h:column><h:message for="input" /></h:column>
    </h:dataTable>
    <h:commandButton value="submit" action="#{bean.submit}" />
</h:form>
Run Code Online (Sandbox Code Playgroud)

  • 说真的,我搜索的任何问题都与JSF有关.到目前为止,@ BalusC的响应无处不在.先生,尊重你.:-) (3认同)