9 Replies Latest reply on Aug 6, 2007 1:05 PM by Milli Coelho

    Surrounding h:datatable with a4j:region does not work

    Milli Coelho Newbie

      Hi,

      In the below code, when I try to add a category with out giving email id I get a value required error. So I tried to surround h:datatable with a4j:region to avoid validation error on email address. But it does not do anything. No error and the category is not added either.Could someone help me? I was told to try immediate instead of a4j:region but it does not update my datamodel object since the action method gets executed right after apply request phase.

      <h:form id="registerform">
       <s:validateAll>
       <a4j:keepAlive beanName="register"/>
       <a4j:outputPanel ajaxRendered="true">
       <h:messages />
       </a4j:outputPanel>
       <h:panelGrid columns="2">
       <h:outputLabel for="emailId" value="Email Address"/>
       <h:InputText id="emailId" value="#{register.emailId}" required="true"/>
      
       <h:outputLabel for="dataPanel" value="Categories"/>
       <h:panelGroup id="dataPanel">
       <h:dataTable var="category" value="#{register.categories}">
       <h:column>
       <h:inputText value="#{category.name}" required="true"/>
       </h:column>
       <h:column>
       <a4j:commandButton action="#{register.addCategory}" image="img/plus.gif reRender="dataPanel"/>
       </h:column>
       <h:column>
       <a4j:commandButton action="#{register.removeCategory}" image="img/minus.gif reRender="dataPanel"/>
       </h:column>
       </h:dataTable>
       <h:panelGrid>
       <h:form>
      


        • 1. Re: Surrounding h:datatable with a4j:region does not work
          Sergey Smirnov Master

          Let's clarify where the "nothing" starts.
          1. Do you have region around the dataTable or panel group (it is not at your snippet) ?
          2. Does the Ajax request occurs?
          3. if so, Does the action is called?
          4. if so, what is the last phase jsf lifecycle passed?


          • 2. Re: Surrounding h:datatable with a4j:region does not work
            Milli Coelho Newbie

            Sorry I did not give enough information.

            1. I tried both around dataTable and panelGroup with the same results
            2. Yes it does and gets a response too. But I do not see panelGroup or dataTable in the response
            3. No action method is not called
            4. This is where I', clueless. I do not get any errors. I enabled facestrace and I get green in all 6 stages of JSF lifecycle. FYI, facestrace is inside outputPanel with ajaxredered=true so that it gets refreshed for every ajax request.

            "SergeySmirnov" wrote:
            Let's clarify where the "nothing" starts.
            1. Do you have region around the dataTable or panel group (it is not at your snippet) ?
            2. Does the Ajax request occurs?
            3. if so, Does the action is called?
            4. if so, what is the last phase jsf lifecycle passed?




            • 4. Re: Surrounding h:datatable with a4j:region does not work
              Sergey Smirnov Master

              Also, assign id for command button, input and dataTable itself.

              • 5. Re: Surrounding h:datatable with a4j:region does not work
                Milli Coelho Newbie

                 

                "SergeySmirnov" wrote:
                Also, assign id for command button, input and dataTable itself.


                RichFaces version is 3.0.1 and I have ids assigned to every control in the original code.

                • 6. Re: Surrounding h:datatable with a4j:region does not work
                  Sergey Smirnov Master

                   

                  "milli" wrote:
                  I have ids assigned to every control in the original code.


                  So, could you post the real code snippet?

                  • 7. Re: Surrounding h:datatable with a4j:region does not work
                    Milli Coelho Newbie

                     

                    "SergeySmirnov" wrote:
                    "milli" wrote:
                    I have ids assigned to every control in the original code.


                    So, could you post the real code snippet?

                    <h:form id="registerform">
                     <s:validateAll>
                     <a4j:keepAlive beanName="register"/>
                     <a4j:outputPanel ajaxRendered="true">
                     <h:messages />
                     </a4j:outputPanel>
                     <h:panelGrid id="registerpanel" columns="2">
                     <h:outputLabel id="emailidlabel" for="emailId" value="Email Address"/>
                     <h:panelGroup id="emailidpanel">
                     <h:InputText id="emailId" value="#{register.emailId}" required="true"/>
                     <br/><h:message for="emailId" />
                     </h:panelGroup>
                    
                     <h:outputLabel id="categoryLabel" for="dataPanel" value="Categories"/>
                     <h:panelGroup id="dataPanel">
                     <h:dataTable id="catDataTable" var="category" value="#{register.categories}">
                     <h:column>
                     <h:inputText id="catInput" value="#{category.name}" required="true"/>
                     </h:column>
                     <h:column>
                     <a4j:commandButton id="catAdd" action="#{register.addCategory}" image="img/plus.gif reRender="dataPanel"/>
                     </h:column>
                     <h:column>
                     <a4j:commandButton id="catRemove" action="#{register.removeCategory}" image="img/minus.gif reRender="dataPanel"/>
                     </h:column>
                     </h:dataTable>
                     <h:panelGrid>
                     </s:validateAll>
                     <h:form>
                    




                    • 8. Re: Surrounding h:datatable with a4j:region does not work
                      Sergey Smirnov Master

                      You said about region. I did not see the region again.

                      • 9. Re: Surrounding h:datatable with a4j:region does not work
                        Milli Coelho Newbie

                         

                        "SergeySmirnov" wrote:
                        You said about region. I did not see the region again.


                        I took it off since it did not work. I tried region in two different ways:

                        <h:form id="registerform">
                         <s:validateAll>
                         <a4j:keepAlive beanName="register"/>
                         <a4j:outputPanel ajaxRendered="true">
                         <h:messages />
                         </a4j:outputPanel>
                         <h:panelGrid id="registerpanel" columns="2">
                         <h:outputLabel id="emailidlabel" for="emailId" value="Email Address"/>
                         <h:panelGroup id="emailidpanel">
                         <h:InputText id="emailId" value="#{register.emailId}" required="true"/>
                         <br/><h:message for="emailId" />
                         </h:panelGroup>
                        
                         <h:outputLabel id="categoryLabel" for="dataPanel" value="Categories"/>
                         <a4j:region id="a4jdataRegion">
                         <h:panelGroup id="dataPanel">
                         <h:dataTable id="catDataTable" var="category" value="#{register.categories}">
                         <h:column>
                         <h:inputText id="catInput" value="#{category.name}" required="true"/>
                         </h:column>
                         <h:column>
                         <a4j:commandButton id="catAdd" action="#{register.addCategory}" image="img/plus.gif reRender="dataPanel"/>
                         </h:column>
                         <h:column>
                         <a4j:commandButton id="catRemove" action="#{register.removeCategory}" image="img/minus.gif reRender="dataPanel"/>
                         </h:column>
                         </h:dataTable>
                         </h:panelGroup>
                         </a4jregion>
                         </h:panelGrid>
                         </s:validateAll>
                         <h:form>
                        


                        <h:form id="registerform">
                         <s:validateAll>
                         <a4j:keepAlive beanName="register"/>
                         <a4j:outputPanel ajaxRendered="true">
                         <h:messages />
                         </a4j:outputPanel>
                         <h:panelGrid id="registerpanel" columns="2">
                         <h:outputLabel id="emailidlabel" for="emailId" value="Email Address"/>
                         <h:panelGroup id="emailidpanel">
                         <h:InputText id="emailId" value="#{register.emailId}" required="true"/>
                         <br/><h:message for="emailId" />
                         </h:panelGroup>
                        
                         <h:outputLabel id="categoryLabel" for="dataPanel" value="Categories"/>
                        
                         <h:panelGroup id="dataPanel">
                         <a4j:region id="a4jdataRegion">
                         <h:dataTable id="catDataTable" var="category" value="#{register.categories}">
                         <h:column>
                         <h:inputText id="catInput" value="#{category.name}" required="true"/>
                         </h:column>
                         <h:column>
                         <a4j:commandButton id="catAdd" action="#{register.addCategory}" image="img/plus.gif reRender="dataPanel"/>
                         </h:column>
                         <h:column>
                         <a4j:commandButton id="catRemove" action="#{register.removeCategory}" image="img/minus.gif reRender="dataPanel"/>
                         </h:column>
                         </h:dataTable>
                         </a4jregion>
                         </h:panelGroup>
                        
                         </h:panelGrid>
                         </s:validateAll>
                         <h:form>