【发布时间】:2013-01-21 03:01:15
【问题描述】:
<h:form>
<h:selectManyMenu id="carsList"
value="#{bean.carList}"
style="width:400px; height:100px" label="List">
<f:selectItems value="#{bean.cars}" var="i"
itemLabel="#{i.code}" itemValue="#{i.Name}" />
<f:selectItem itemLabel="Other" itemValue="other"/>
<f:ajax event="change" execute="@this" render="othermodel"/>
</h:selectManyMenu>
<br></br>
<h:panelGroup id="othermodel">
<h:outputText value="Others:" style="margin-top:10px;color:red;font-weight:bold;"
rendered="#{bean.carList.contains('other')}" />
<h:inputText size="50" id="otherinput" required="true"
rendered="#{bean.carList.contains('other')}"/>
<h:message for="otherinput"></h:message>
</h:panelGroup>
<h:commandButton value="Next" action="#{bean.submitForm}"/>
</h:form>
我的 bean 是 requestScoped 并且当我的 carList 具有值 other 我能够显示 panelGrid 但是当用户没有在使用 AJAX 呈现的输入字段中输入任何值时,甚至我指定了required=true,但它没有得到验证。并且后台代码中输入文本框的值为null。
如何验证使用AJAX 呈现的输入字段,为什么我的值是空值?我正在使用 JSF 2.0
【问题讨论】:
标签: ajax jsf-2 rendering requiredfieldvalidator