我用對後:這樣如何保持同一選項卡上提交表單
<ui:composition template="./WEB-INF/templates/masterTemplate.xhtml">
<ui:define name="windowTitle">
#{msgs.home}
</ui:define>
<ui:define name="content">
<p:tabView id="tabView" dynamic="false">
<p:tab id="tab1" title="#{msgs.home}">
<ui:include src="/homePages/home.xhtml" />
</p:tab> <!--end of tab1 -->
<p:tab id="tab2" title="#{msgs.join}">
<ui:include src="/homePages/join.xhtml" />
</p:tab> <!--end of tab2 -->
<p:tab id="tab3" title="#{msgs.signIn}">
<ui:include src="/homePages/login.xhtml" />
</p:tab> <!--end of tab3 -->
</p:tabView>
</ui:define>
</ui:composition>
標籤視圖這是我join.xhtml頁
<h:body>
<ui:composition>
<div id="join" style="border-style:solid; border-width:5px; padding: 10px;" >
<div id="joinFormPosition" class="left">
<h:form id="joinForm">
<h:outputText id="joinMessgae" value="#{msgs.joinMessgae}" />
<span class="asterisk">*</span><span class="labels">#{msgs.signInName}: </span>
<p:inputText id="name"
value="#{joinPage.signInName}"
required="true"/>
<p:message for="name" />
...
<div id="submitButton">
<h:commandButton id="submitBtn"
value="Submit"
actionListener="#{join.saveUser}" />
</div>
</h:form>
</div> <!--end of joinFormPosition -->
</div> <!--end of join -->
</ui:composition>
</h:body>
login.xhtml
<ui:composition>
<div id="login" style="border-style:solid; border-width:5px; padding: 10px;" >
<div id="loginFormPosition" class="left">
<h:form id="loginForm">
<h:outputText value="#{msgs.signIn}" />
.....
<div id="signInButton">
<h:commandButton id="signInBtn"
value="Submit"
actionListener="#{login.signIn}"
action ="#{login.outcome}"/>
</div>
</h:form>
</div> <!--end of loginFormPosition -->
</div> <!--end of login -->
</ui:composition>
如果我在標籤連接,然後提交表單,如果任何驗證失敗,然後我切換到第一個選項卡。我想,如果我點擊提交按鈕,並且驗證是否失敗,或者我停留在同一個選項卡上。我在登錄標籤上遇到同樣的情況。如何在提交表單後留在同一個標籤頁上?
感謝
綁定不是要走的路。將activeIndex屬性與tabChange事件組合使用。 – Kukeltje