1 Reply Latest reply on Apr 27, 2012 3:19 PM by ensemien

    [richfaces 4 ] problem with rendering rich:dataTable

    ensemien

      Hello everyone !,

      i am working my project with JSF2 and richfaces 4 .

      i created facelet with  rich:datatable to display data ,but whene i delete one record , the action  delete works fine

      because the record is removed in data base,but the rich:dataTabe doesn't being rendred , and the record appear again .

      here is my : facelet :victimegestion.xhtml and my bean : victimeBean.java

       

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:a4j="http://richfaces.org/a4j"
          xmlns:rich="http://richfaces.org/rich">
      
      
      
          <ui:composition template="layout.xhtml">
      
      
                   <ui:define name="header"> 
                        <h:graphicImage value="header.png" library="images" />  
                  </ui:define>
      
              <ui:define name="title">Gestion des victimes</ui:define>
      
              <ui:define name="content">
      
                  <a4j:status onstart="#{rich:component('statPane')}.show()"
                      onstop="#{rich:component('statPane')}.hide()" />
      
      
                  <h:form id="form">
                      <rich:dataTable id="table" value="#{victimeBean.victimeList}" var="victime"
                          rows="15" rendered="true">
      
                          <rich:column>
                              <f:facet name="header">ID</f:facet>
                              <h:outputText value="#{victime.victimeId}" />
                          </rich:column>
      
                          <rich:column>
                              <f:facet name="header">Matricule</f:facet>
                              <h:outputText value="#{victime.victimeMatricule}" />
                          </rich:column>
                           <rich:column>
                              <f:facet name="header">Nom</f:facet>
                              <h :outputText value="#{victime.victimeNom}" />
                          </rich:column>
      
                            <rich:column>
                              <a4j:commandLink styleClass="no-decor"   render="table" execute="@form"
                                  oncomplete="#{rich:component('confirmPane')}.show()">
                                  <h:graphicImage value="delete.gif" alt="delete" />
                                      <f:setPropertyActionListener value="#{victime}"
                                      target="#{victimeBean.victime}" />
                              </a4j:commandLink>
                          </rich:column>
      
                      </rich:dataTable>
      
      
                      <a4j:jsFunction name="remove" action="#{victimeBean.remove}"
                          render="table" execute="@form"
                          oncomplete="#{rich:component('confirmPane')}.hide();" />
      
      
      
                      <rich:popupPanel id="statPane" autosized="true">
                          <h:graphicImage value="ai.gif" alt="ai" />
                          Please wait...
                      </rich:popupPanel>
      
      
                      <rich:popupPanel id="confirmPane" autosized="true">
                          Are you sure you want to delete the row?
                          <a4j:commandButton value="Cancel" onclick="#{rich:component('confirmPane')}.hide(); return false;"  />
                          <a4j:commandButton value="Delete" onclick="remove(); return false;"  />
                      </rich:popupPanel>
      
      
                  </h:form>
      
      
      
              </ui:define>
      
          </ui:composition>
      
      
      </ui:composition>
      

      and my bean :

       

      package ma.ocpgroup.web;
      
      import java.io.Serializable;
      import java.util.List;
      
      import javax.annotation.PostConstruct;
      import javax.faces.bean.ManagedBean;
      import javax.faces.bean.RequestScoped;
      import javax.faces.bean.ViewScoped;
      import javax.faces.context.FacesContext;
      import javax.faces.event.ActionEvent;
      import javax.faces.event.AjaxBehaviorEvent;
      import javax.servlet.http.HttpServletResponse;
      import javax.servlet.http.HttpSession;
      
      import ma.ocpgroup.domain.model.Victime;
      import ma.ocpgroup.metier.interfs.VictimeServiceInterf;
      
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.stereotype.Component;
      
      
      @javax.inject.Named
      @Component("victimeBean")
      @ManagedBean
      @ViewScoped
      
      public class VictimeBean  implements Serializable{
      
      
          /**
           * 
           */
      
          private static final long serialVersionUID = 1L;
          @Autowired
          private transient VictimeServiceInterf victimeService;
          private transient List<Victime> victimeList;
      
          private transient Victime victime= new Victime();
      
      
          @PostConstruct
          public void init()
          {  
              victimeList = victimeService.getAllVictimes();
      
          }
      
      
          public void preRenderView() {  
      
                FacesContext context = FacesContext.getCurrentInstance();
              HttpSession session = ( HttpSession ) context.getExternalContext().getSession(true);
      
               // session.setMaxInactiveInterval(1);
              }  
      
      
      
          public List<Victime> getVictimeList() {
                return victimeList;
          }
      
      
          public void setVictimeList(List<Victime> victimeList) {
              this.victimeList = victimeList;
          }
      
      
          public Victime getVictime() {
              return victime;
          }
      
      
         public void setVictime(Victime victime) {
              this.victime = victime;
          }
      
      
          public VictimeServiceInterf getVictimeService() {
              return victimeService;
          }
      
      
          public void setVictimeService(VictimeServiceInterf victimeService) {
              this.victimeService = victimeService;
          }
      
      
      
           public void remove ()
           {
      
               victimeService.removeVictime(victime);
               victime = new Victime();
           }
      
      
      
      
      }
      
      

       

      please i need your help