4 Replies Latest reply on May 26, 2010 8:48 AM by sathish avunoori

    rerendering problem

    sathish avunoori Newbie

      hi to all,

       

      i have a problem while using <a4j:commandButton>,that is ,

       

      i have a <h:form> consisting of one <h:outpuText> field and one <rich:dataTable> and two buttons as <a4j:commadButton> for adding and deletion new row into the table . The code is as follows,

       

      <h:form styleClass="association" id="voyageCarriersChildren"> 
                             <h:outputText id="noContacts" value="There are no Contacts" rendered="#{vesselContacts.rowCount==0}"/>
                                <div  id="detailList" >
                                  <rich:dataTable    id="vesselContactListTable" var="_vesselContact"  selectedClass="selection"
                                   selectionMode="single"  width="800px"
                                   value="#{vesselContacts}" headerClass="removeheader" rendered="#{vesselContacts.rowCount>0}" >

                                     <rich:column id="contactPerson" width="190px"
                                       headerClass="head" label="#{messages['com.infyz.toms.properties.Vessel_name']}">
                                       <f:facet name="header">
                                           <h:outputText styleClass="headerText" value="#{messages['com.infyz.toms.properties.Vessel_name']}" />
                                       </f:facet>
                                       <rich:inplaceInput layout="block"
                                               value="#{_vesselContact.contactPerson}"
                                               changedHoverClass="hover" viewHoverClass="hover"
                                               viewClass="inplace" changedClass="inplace" selectOnEdit="true"
                                               editEvent="onclick">
                                           <a4j:support event="onviewactivated" reRender="contactPerson"  />
                                       </rich:inplaceInput>
                                      
                                   </rich:column >

                                     ---------------------

                                     some columns

                                     ---------------------

                              </rich:dataTable>
                            </div>
                          <rich:spacer height="15"/>
                           <div align="right">
                             <a4j:commandButton id="editVoyageReferenceMP11"
                                   action="#{vesselAction.addVesselContact}"     
                                   reRender="vesselContactListTable,voyageCarriersChildren,noContacts" 
                                   oncomplete="if (#{facesContext.maximumSeverity!=null}) #{rich:component('vesselEditWizard')}.show();"
                              value="#{messages['com.infyz.toms.label.button.tooltip.Add']} #{messages['com.infyz.toms.properties.Contact']}" />
                           &#160;
                      <a4j:commandButton bypassUpdates="true" immediate="true"                                     value="#messages['com.infyz.toms.label.button.tooltip.Cancel']}"
                  reRender="vesselContactListTable,voyageCarriersChildren,noContacts" action="#{vesselAction.cancelVesselContact}" />
                  </div>
                              
           </h:form>

      My requirement  is that , when i click on add button one new object will be added to the list of the dataTable and rerender the table with newly added object, if i click on cancel button the newly added object should be deleted from the list and datatable will be rerendered. if no objects are there in list then <h:outputText > field should be displayed with "There are no contacts " text and the datatable will be disabled.But when i clicking on the buttons either on add or on cancel the rerender of output text and table not happening.

       

       

      Can any one help me where i am doing wrong?

       

      Thanks in advance for your concern

        • 1. Re: rerendering problem
          Harut Sargsyan Apprentice

          Look at this article. I think the same problem in your case

          http://community.jboss.org/message/537833#537833

          1 of 1 people found this helpful
          • 2. Re: rerendering problem
            sathish avunoori Newbie

            hi harut sargsyan,

             

            thanks for your helpful posts,

             

            but i tried by creating parent component(jsf subview component as parent ) for output text field and datatable components and rerender that when clicking buttons,

            but it is also not working for me .

             

            what i should do to resolve this?

             

            any other suggestions please?

             

            thanks for regarding this.

            • 3. Re: rerendering problem
              Harut Sargsyan Apprentice

              what is the scope of vesselContacts bean class ? I think that it has request scope that's why 'rendering' is not working.

              Change the scope to session or add a4j:keepalive declaration for that bean and try again.

              • 4. Re: rerendering problem
                sathish avunoori Newbie

                hi Harut,

                 

                thanks for your suggestion,

                 

                my vesselContacts bean class having  session scope ,but i think that is not the problem,

                 

                at last i tried by adding a <a4j:outputPanel > as parent component for all child components(h:outputText , rich:dataTable and a4j:commandButtons) then i am rerendering that parent component, now it is working fine.

                i am inserting some sample code for future purpose ,

                 

                <a4j:outputPanel id="contactsView">
                                     <h:outputText id="noContacts" value="There are no Contacts" styleClass="noListItems" rendered="#{vesselContacts.rowCount==0}" />
                                       
                                        <div  id="detailList" >
                                        <rich:dataTable    id="vesselContactListTable" var="_vesselContact"  selectedClass="selection"
                                            selectionMode="single"  width="800px"
                                            value="#{vesselContacts}" headerClass="removeheader" rendered="#{vesselContacts.rowCount>0}" >
                                            <rich:column id="contactPerson" width="190px"
                                                headerClass="head" label="#{messages['com.infyz.toms.properties.Vessel_name']}">
                                                <f:facet name="header">
                                                    <h:outputText styleClass="headerText" value="#{messages['com.infyz.toms.properties.Vessel_name']}" />
                                                </f:facet>
                                                <rich:inplaceInput layout="block"
                                                        value="#{_vesselContact.contactPerson}"
                                                        changedHoverClass="hover" viewHoverClass="hover"
                                                        viewClass="inplace" changedClass="inplace" selectOnEdit="true"
                                                        editEvent="onclick">
                                                    <a4j:support event="onviewactivated" reRender="contactPerson"  />
                                                </rich:inplaceInput>
                                            </rich:column>
                                            <rich:column id="email" width="190px"
                                                headerClass="head" label="#{messages['com.infyz.toms.properties.Email']}">
                                                <f:facet name="header">
                                                    <h:outputText styleClass="headerText"
                                                        value="#{messages['com.infyz.toms.properties.Email']}" />
                                                </f:facet>
                                                <rich:inplaceInput layout="block" required="true"
                                                        value="#{_vesselContact.email}"  requiredMessage="* Email ::----> Value is Required."
                                                        changedHoverClass="hover" viewHoverClass="hover"
                                                        viewClass="inplace" changedClass="inplace" selectOnEdit="true"
                                                        editEvent="onclick">
                                                    <a4j:support event="onviewactivated" reRender="vesselEditWizard" bypassUpdates="true"/>
                                                </rich:inplaceInput>
                                            </rich:column>
                                          
                                           --------------------

                                           some columns

                                           -------------------------

                                       </rich:dataTable>
                                        </div>
                                       
                                        <rich:spacer height="15"/>
                                        <div align="right">
                                       
                                        <a4j:commandButton id="editVoyageReferenceMP11"
                                              action="#{vesselAction.addVesselContact}"     
                                            reRender="contactsView
                                            oncomplete="if (#{facesContext.maximumSeverity!=null}) #{rich:component('vesselEditWizard')}.show();"
                                            value="#{messages['com.infyz.toms.label.button.tooltip.Add']} #{messages['com.infyz.toms.properties.Contact']}" />
                                        &#160;
                                        <a4j:commandButton bypassUpdates="true" immediate="true" value="#{messages['com.infyz.toms.label.button.tooltip.Cancel']}"
                                            reRender="contactsView" action="#{vesselAction.cancelVesselContact}" />
                                        </div>

                </a4j:outputPanel>

                 

                thanks for your kind replays