0 Replies Latest reply on Jul 31, 2008 11:48 AM by Andrey Divakov

    Ajax-form validation

    Andrey Divakov Newbie
      Hello to all!
      i'am not good write in english, so excuse for language mistakes. )))

      I have statful bean:
      @Stateful
      @Scope(ScopeType.CONVERSATION)
      @Name("superCardList")

      In this class there is an attribute:
      private Object selectEntity;

      in begin() method it defined:
      selectEntity = cardList1.getCardInfo().getBaseClass().newInstance();


      in ajax-form i have input columns to enter values:

      <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"               
                  xmlns:a4j="http://richfaces.org/a4j"               
                      template="/layout/template.xhtml">
                            
      <ui:define name="body">

      <a4j:form id="addRecord" styleClass="edit">

           <a4j:outputPanel ajaxRendered="true">
                 <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>
           </a4j:outputPanel>   
         
              <rich:panel style="width:99%; height:85%;" bodyStyle="width:99%; height:85%;">
               <f:facet name="header">Adding record in "#{superCardList.cardList1.cardInfo.desc}"</f:facet>

           <c:forEach begin="0" end="#{superCardList.cardList1.getFieldsSize()}" var="curr" step="1">                         
           <h:panelGrid columns="2">
           <s:decorate template="/layout/edit.xhtml">
           <ui:define name="label"> #{superCardList.cardList1.fields.get(curr).name}        </ui:define>                    

           <h:inputText value="#{superCardList.cardList1.fields.get(curr).getValue(superCardList.selectEntity)}"
           size="70"
           maxlength="70"
           required="#{superCardList.cardList1.fields.get(curr).notNull}"
           rendered="#{superCardList.cardList1.fields.get(curr).isGenerated()==false &amp;&amp; superCardList.cardList1.getFieldType(curr)==1}">
           </h:inputText>
                                              
           <h:inputText value="#{superCardList.cardList1.fields.get(curr).getValue(superCardList.selectEntity)}"
           size="70"
           required="#{superCardList.cardList1.fields.get(curr).notNull}"
           rendered="#{superCardList.cardList1.fields.get(curr).isGenerated()==false &amp;&amp; superCardList.cardList1.getFieldType(curr)==3}">
           </h:inputText>

           <h:inputText value="#{superCardList.cardList1.getJoinColumnValue(superCardList.cardList1.fields.get(curr),superCardList.selectEntity)}"
            size="70"
                required="#{superCardList.cardList1.fields.get(curr).notNull}"
            rendered="#{superCardList.cardList1.fields.get(curr).isJoinColumn()}">
           </h:inputText>
                                                                 <h:selectOneMenu value="#{superCardList.cardList1.fields.get(curr).getValue(superCardList.selectEntity)}"
               required="#{superCardList.cardList1.fields.get(curr).notNull}"
               rendered="#{superCardList.cardList1.fields.get(curr).isGenerated()==false &amp;&amp; superCardList.cardList1.getFieldType(curr)==2}">
                <f:selectItem itemLabel="Don't choise" itemValue="" />
                <f:selectItem itemLabel="1" itemValue="1" />
                <f:selectItem itemLabel="0" itemValue="0" />
                </h:selectOneMenu>
                                           
                <h:outputText value="Value will be generated automatically"
            size="70"
            rendered="#{superCardList.cardList1.fields.get(curr).generated}">
            </h:outputText>

           <a4j:commandButton action="#{superCardList.beginCardList2()}"
           value="Choose"
           immediate="false"
           rendered="#{superCardList.cardList1.fields.get(curr).isJoinColumn()}">
                    <a4j:actionparam name="className0" value="#{superCardList.cardList1.fields.get(curr).getJoinField().getCardInfo().getBaseClass().getName()}"/>
                  <a4j:actionparam name="firstResult0" value="0"/>
           </a4j:commandButton>
                            
           </s:decorate>                         
           </h:panelGrid>
           </c:forEach>

                  <div style="clear:both">
                  <b>
                      <span class="required">* Required fields </span>
                  </b>
                  </div>  
              </rich:panel>
           </a4j:form>


      When i push button "Choose" to choose value to field from Directory, how i understand,
      before sending from ajasx-form to server data in fields is validating and in this step raise an error:
      sourceId=addRecord:j_id188:j_id196[severity=(ERROR 2), summary=(model validation failed:/test_andru/CardAdd.xhtml @34,146 value="#{superCardList.cardList1.fields.get(curr).getValue(superCardList.selectEntity)}": Illegal Syntax for Set Operation), detail=(model validation failed:/test_andru/CardAdd.xhtml @34,146 value="#{superCardList.cardList1.fields.get(curr).getValue(superCardList.selectEntity)}": Illegal Syntax for Set Operation)]

      what is it? help me please.