如何在JSF中有条件地要求元素
我的表单中有一个简单的输入文本元素 用户在该表单上有两种可能的操作:1)批准表单和2)拒绝表单。因此,表单底部有两个按钮供用户单击 如果用户单击如何在JSF中有条件地要求元素,jsf,jsf-2,Jsf,Jsf 2,我的表单中有一个简单的输入文本元素 用户在该表单上有两种可能的操作:1)批准表单和2)拒绝表单。因此,表单底部有两个按钮供用户单击 如果用户单击approve,comment输入字段应该是可选的。如果用户单击拒绝,则应需要注释输入字段 以下是表格的简单表示: <h:form> <p:inputText id="comment" required="???" .../> <p:commandButton id="approve" ... />
approve
,comment
输入字段应该是可选的。如果用户单击拒绝
,则应需要注释
输入字段
以下是表格的简单表示:
<h:form>
<p:inputText id="comment" required="???" .../>
<p:commandButton id="approve" ... />
<p:commandButton id="reject" ... />
</h:form>
试试这个
<h:form id="forma">
<p:inputText id="comment"
value="#{userView.firstname}"
title="comment"
required="#{not empty param[reject.clientId]}"/>
<p:message for="comment"/>
<p:commandButton id="approve"
binding="#{approve}"
value="approve"
process="@form"
update="@form"/>
<p:commandButton id="reject"
binding="#{reject}"
value="reject"
process="@form"
update="@form"/>
</h:form>
试试这个
<h:form id="forma">
<p:inputText id="comment"
value="#{userView.firstname}"
title="comment"
required="#{not empty param[reject.clientId]}"/>
<p:message for="comment"/>
<p:commandButton id="approve"
binding="#{approve}"
value="approve"
process="@form"
update="@form"/>
<p:commandButton id="reject"
binding="#{reject}"
value="reject"
process="@form"
update="@form"/>
</h:form>
您的问题看起来很像 修改
required
属性,如下所示:
<h:form id="form">
<p:inputText id="comment" required="#{not empty param['form:reject']}" ... />
<p:commandButton id="approve" ... />
<p:commandButton id="reject" ... />
</h:form>
您的问题看起来很像 修改
required
属性,如下所示:
<h:form id="form">
<p:inputText id="comment" required="#{not empty param['form:reject']}" ... />
<p:commandButton id="approve" ... />
<p:commandButton id="reject" ... />
</h:form>
谢谢@BalusC!我想我没有使用正确的搜索词。谢谢@BalusC!我想我没有使用正确的搜索词。