5 Replies Latest reply on Mar 31, 2009 7:33 AM by iimirela

    Datatable delete last row problem

    iimirela

      Hello, I seem to have a problem with the datatable. It does not delete the last row. Well actually it does, because if I navigate to another page, and come back, the table is gone.

      <rich:dataTable id="servicesTable" value="#{GestioneServiziBean.serviceList}" var="service" reRender="ds"
       rows="7" width="100%" rowKeyVar="row">
       <!-- headers -->
       <f:facet name="header">
       <rich:columnGroup>
       <rich:column >
       <h:outputText value="#{pageMessages.labelDescrizione}" styleClass="headerText" />
       </rich:column>
       <rich:column >
       <h:outputText value="#{pageMessages.labelDipendenza}" styleClass="headerText" />
       </rich:column>
       <rich:column>
       </rich:column>
       <rich:column>
       </rich:column>
       </rich:columnGroup>
       </f:facet>
      
       <!-- descrizione -->
       <rich:column filterBy="#{service.descr}" filterEvent="onkeyup">
       <rich:inplaceInput value="#{service.descr}" layout="block" viewClass="inplace" />
       </rich:column>
      
       <!-- dipendenza -->
       <rich:column styleClass="calign" filterBy="#{service.parent.descr}" filterEvent="onkeyup">
       <rich:inplaceSelect value="#{service.parent.id}"
       layout="block" viewClass="inplace" openOnEdit="true">
       <f:selectItems value="#{GestioneServiziBean.listaDipendenze}" />
       </rich:inplaceSelect>
       </rich:column>
      
       <!-- salva -->
       <rich:column styleClass="calign" width="30">
       <f:facet name="header"></f:facet>
       <a4j:commandLink action="#{GestioneServiziBean.saveService}" reRender="servicesTable">
       <h:graphicImage styleClass="icon" url="/images/conferma.png" />
       <f:setPropertyActionListener value="#{row}" target="#{GestioneServiziBean.selIndex}"/>
       </a4j:commandLink>
       </rich:column>
      
       <!-- elimina -->
       <rich:column styleClass="calign" width="30">
       <f:facet name="header"></f:facet>
       <a4j:commandLink action="#{GestioneServiziBean.deleteService}" reRender="servicesTable">
       <h:graphicImage styleClass="icon" url="/images/delete.png" />
       <f:setPropertyActionListener value="#{row}" target="#{GestioneServiziBean.selIndex}"/>
       </a4j:commandLink>
       </rich:column>
      
       <!-- pagination -->
       <f:facet name="footer">
       <rich:datascroller id="ds" renderIfSinglePage="false" />
       </f:facet>
       </rich:dataTable>


        • 1. Re: Datatable delete last row problem
          timbooo

          hi there,

          is the table or the row gone after you navigate back to your page with the table?

          well, i too have a column for deleting the selected line. but i'm doing this with an actionListener. you can get to the dataTable over the action event, get the rowdata and delete the row. works fine for me.


          tim

          • 2. Re: Datatable delete last row problem
            iimirela

            The table is gone. I somehow deleted a very important detail in the code

            rendered="#{!empty GestioneServiziBean.serviceList}"


            so when the list is empty the table is not rendered. I debuged the whole thing, the delete method is called, the collection becomes empty, it's just the table that is not reRendered.

            • 3. Re: Datatable delete last row problem
              timbooo

              well, i think your model gets updated correctly as you said. but in the render response phase, where your table should be rendered, the table won't be rendered because your list is empty. and by getting the rendered attribute value from your backing bean there will always be rendered="false".

              anyone, correct me if i'm wrong.


              tim.

              • 4. Re: Datatable delete last row problem
                ilya_shaikovsky

                 

                rendered="#{!empty GestioneServiziBean.serviceList}"
                


                you should not reRender conditionally rendered elements directly. reRender its parent.

                • 5. Re: Datatable delete last row problem
                  iimirela

                  Brilliant! Worked like a charm.

                  Spasiba.