我是JSF的新手,我遇到了一個奇怪的問題,不知道如何解決它。jsf在文本字段驗證期間的標籤導航
我有多個選項卡中的畫面,並在標籤中的一個,我有文本框,下拉菜單等 所有的文本字段和下拉菜單都需要=「真」集。
由於此驗證,當我嘗試導航到另一個選項卡而沒有輸入或選擇值時,我無法導航並顯示驗證消息(值爲必填項)。
但我有一個保存按鈕在選項卡中,驗證應該只有當我點擊保存按鈕,而不是在Tab切換/導航期間觸發。在驗證工作之間,當我點擊保存按鈕時,我所需要的是當切換到不同的選項卡時不應觸發驗證。
此驗證不允許我切換到不同的選項卡,而不是 確定爲什麼在切換選項卡時會觸發此驗證。
請問任何人都可以爲我的問題提出解決方案。
更新:這裏是我做了基於CycDemo的答案的變化:
<h:tab name="First Tab" accessKey="s">
<h:panelGroup >
<h:dataTable id="firstTable" styleClass="dataTableEx" headerClass="headerClass"
footerClass="footerClass" rowClasses="rowClass1,rowClass2"
columnClasses="columnClass1" value="#{clientProductCRUDBean.model}"
var="item" border="1" cellpadding="2" cellspacing="0" >
<!-- this for the incoming originator type dropdown field -->
<h:column>
<f:facet name="header">
<h:outputText value="firstDropDown" />
</f:facet>
<h:selectOneMenu id="firstDropDown"
required="true" requiredMessage="required field" immediate="true" >
<f:selectItem itemLabel="--Select--" itemValue="#{null}" />
<h:message for="firstDropDown" errorClass="generalErrorText"/>
</h:selectOneMenu>
</h:column>
<!-- this for the outgoing originator text field -->
<h:column >
<f:facet name="header">
<h:outputText value="firstTextField"/>
</f:facet>
<h:inputText id="firstTextField"
required="true" validatorMessage="Max Length 20" requiredMessage="required field" immediate="true" >
<f:validateLength maximum="20"/>
<h:message for="firstTextField" errorClass="generalErrorText"/>
</h:inputText>
</h:column>
<!-- this for the replace or randomise radio buttons text field -->
<!-- this for the operators selection drop down-->
</h:dataTable>
</h:panelGroup>
<h:panelGroup style="padding: 1px; margin-top: 5px;" >
<h:commandButton id="firstSaveButton" styleClass="commandButton" value="Save" />
<h:commandButton id="firstSaveCancel" styleClass="commandButton" value="Cancel" immediate="true"/>
</h:panelGroup>
<br />
</h:tab>
它仍然調用驗證。
您可以發佈的代碼? – Swarne27
對不起,我爲一家公司工作,我不能發佈代碼,但我可以保證當我從文本字段中刪除required =「true」並下拉菜單時,我可以導航到其他選項卡。可能是我可以嘗試想出一個簡單的代碼來複制這個問題。感謝您表現出興趣。 – likeToCode