TabPanel form validation
bpiepers Nov 10, 2011 7:58 AMHi all,
Have read a couple of topics on this issue but can't seem to find the solution for my problem.
We have a tabPanel with 6 tabs. The tabPanel is put in a form with buttons to go to the next and previous tabs (along with other buttons to save etc.). The fields on the tabs use rich:beanValidator tags and also the bean that is bound to the form has validators (@AssertTrue) that are not bound to any field. What I see is that beanValidators (whether or not bound to a field) are properly fired when clicking the "Next" button but are not invoked when clicking a tab. Here's an example:
<h:form id="relationForm" styleClass="editForm">
<rich:tabPanel switchType="ajax" id="tabPanel" selectedTab="#{registrationBean.currentTab}" styleClass="tabGeneral" >
<rich:tab label="#{msg['label.tab.general']}" id="#{registrationBean.registrationTabs[0].id}" name="#{registrationBean.registrationTabs[0]}" immediate="true" reRender="actionButtons" >
<ui:include src="relation_general.xhtml" />
<f:setPropertyActionListener target="#{registrationBean.currentTab}" value="#{registrationBean.registrationTabs[0]}" />
</rich:tab>
<!-- Bank info -->
<rich:tab label="#{msg['label.tab.bank']}" id="#{registrationBean.registrationTabs[1].id}" name="#{registrationBean.registrationTabs[1]}" reRender="actionButtons">
<ui:include src="relation_bank.xhtml" />
<f:setPropertyActionListener target="#{registrationBean.currentTab}" value="#{registrationBean.registrationTabs[1]}" />
</rich:tab>
// (other tabs)
</rich:tabPanel>
<a4j:outputPanel id="actionButtons">
<h:commandButton id="prevButton" action="#{registrationBean.previousTab}" value="#{msg['action.registration.previous']}"
rendered="#{registrationBean.showPrevButton and !registrationBean.readonly}" />
<h:commandButton id="nextbutton" action="#{registrationBean.nextTab}" value="#{msg['action.registration.next']}"
rendered="#{registrationBean.showNextButton and !registrationBean.readonly}" />
//(other buttons)
</a4j:outputPanel>
</h:form>
The code behind the registrationBean.previousTab and registrationBean.nextTab is not really interesting enough to post. It just sets the next or previous tab based on the available tabs. So again: how can I invoke the validations on the bean (bean validators) when clicking a tab (not the next or previous button)?
Thanks in advance for any help.