2 Replies Latest reply on Aug 25, 2008 5:47 PM by Cyril CCC

    Validate dataTable-dataModel fields

    Cyril CCC Newbie

      I would like to know how it is possible to validate the fields of a dataTable with a validator function because i need to verify if some information exist in my database.


      list.xhtml :


      <h:dataTable rowKeyVar="row" id="myList" var="_item" value="#{myList}">
      <rich:column>
      <f:facet name="header">Value1</f:facet>
      <h:inputText id="value1" value="#{_item.value1}"/>
      </rich:column>
      <rich:column>
      <f:facet name="header">Value2</f:facet>
      <h:inputText  validator="#{myvalidator.validateValue2}" id="value2" value="#{_item.value2}"/>
      </rich:column>                                            
      </h:dataTable>



      MyValidator.java :



      @Name("myalidator")
      public class MyValidator 
      {
      public void validateValue2(FacesContext context, UIComponent component, Object value) throws javax.faces.validator.ValidatorException 
      {
      //i want to validate value2 with value1 here
      }
      }



      Maybe i can try to get the value1 into the value2 validator function thanks to the row index... but i need help for that too