0 Replies Latest reply on Nov 25, 2008 10:44 PM by roger_goldman2000

    Selecting the right <rich:tab> when a validation error occurs

    roger_goldman2000

      Looking for some help... I'm hoping Seam and RichFaces are able to do this out of the box, but if not, I'm hoping someone can suggest the easiest solution.


      I have a <rich:tabPanel> with several <rich:tab> elements.  Each tab contains several input fields, most of which are required (required="true" in the JSF tags).  The input fields are wrapped by <s:decorate> tags that use a template that looks something like this:



      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
           xmlns:s="http://jboss.com/products/seam/taglib"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:rich="http://richfaces.org/rich"
           xmlns:c="http://java.sun.com/jstl/core">
      
          <s:span styleClass="entry" >
              <s:label id="Label" styleClass="#{wide?'widelabel':'narrowlabel'} #{invalid?'errors':''}">
                  <ui:insert name="label"/>: 
                  <s:span id="RequiredStyle" styleClass="required" rendered="#{required}">*</s:span>
              </s:label>
              <s:div styleClass="input #{invalid?'errors':''}">
                  <s:validateAll id="ValidateAll">
                      <ui:insert/>
                  </s:validateAll>
              <s:message id="message" styleClass="error errors"/>
              </s:div>
          </s:span>
      </ui:composition>
      


      I am trying to make it so that if the user does not enter a required field in one of the tabs and clicks the action button at the bottom of the form (e.g. Save or Update), the first tab that contains errors will be displayed.


      So I could do this by using selectedTab="#{bean.selectedTab}" in the <rich:tabPanel>, but I just don't know how to get some of my own validation logic to kick in after Seam has validated all the fields in its standard way.


      Ideally, if I could get Seam to invoke one of my methods after it has completed its own validation, and I could easily determine which fields did not pass the validation checks, then I could throw in a bit of simple logic that maps the first erroneous field to the corresponding tab, and I'd be done.


      Can someone suggest how I could do these two things?  Again:




      1. Getting Seam to invoke one of my methods after Seam has completed its own validations on all fields

      2. Tapping into the results that Seam has on which fields did not pass validation.



      Many thanks in advance.


      /rag