1 Reply Latest reply on Aug 19, 2011 2:25 AM by pradeep kumar

    dataTable lastRecord  and dataTable reRender Problem

    pradeep kumar Newbie

      Hi, all,

       

      i have a problem can any one suggest me, because i am new to seam and richfaces,

       

      The Problem is

      when i am insert a record it is fine record is sucessfully inserted, and displaying in the dataTable, in the dataTable delete record it is fine to delete a record, when i am deleting the last record of the list its not reRender the page, if i am press the refresh button the record is not displaying, actually the last record is deleting but it is remains in dataTable. and also search the record in the column attribute "filterBy" the loader bar is searching every letter when i am typing, i dont want that, its not type safe, what i mean is when i typing stop in the search field and that time the record is retrieving and how do i do that

       

       

      here is the action class

       

      @Name("mobeeUserAction")

      @Scope(ScopeType.CONVERSATION)

      public class MobeeUsersAction{

       

          @In

          private EntityManager entityManager;

       

          @In

          private FacesMessages facesMessages;

       

          @DataModel

          private List<MobeeUser> mobeeUsersList;

       

          @Logger

          private Log _log;

       

          @DataModelSelection

          @Out(required=false)

          private MobeeUser activeUsers;

       

          private List<MobeeUser> mobee_user_list = new ArrayList<MobeeUser>();

       

          @Factory("mobeeUsersList")

          public void retrieveAllUsers(){

              mobeeUsersList = entityManager.createQuery("select m from MobeeUser m order by m.firstName desc").getResultList();

          }

       

          @Begin(join=true)

          public void add(MobeeUser mobeeUser){

              entityManager.persist(mobeeUser);

              activeUsers = mobeeUser;

              facesMessages.add("#{activeUsers.firstName} your Registration is Successfull ");

              retrieveAllUsers();

          }

       

          @Begin(join=true)

          public void delete(){

       

              if(mobeeUsersList.size()==0){

                  facesMessages.add("No Users");

              }else{

                  _log.info("====Before delete list size==" + mobeeUsersList.size());

                  _log.info("======delete begin===");

                  activeUsers = entityManager.find(MobeeUser.class, activeUsers.getId());

                  entityManager.remove(activeUsers);

                  facesMessages.add("#{activeUsers.firstName} is deleted.");

                  retrieveAllUsers();

                  _log.info("======delete end=====");

                  _log.info("====After delete list size==" + mobeeUsersList.size());

              }       

          }   

      }

       

       

      and here is the xhtml file

       

       

      <!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: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:a4j="http://richfaces.org/a4j"

          xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">

       

          <ui:define name="body">

       

              <h:form id="usertListForm">

                  <rich:panel>

                      <f:facet name="header">Register List</f:facet>

                      <h:outputText value="No Register Users exists"

                          rendered="#{mobeeUsersList.rowCount==0}" />

                      <rich:datascroller align="center" for="custList" id="ds"

                          renderIfSinglePage="false"></rich:datascroller>

                      <rich:spacer width="5" height="10"></rich:spacer>

                      <rich:dataTable id="custList" var="user" width="100%"

                          value="#{mobeeUsersList}" rowKeyVar="row"

                          rendered="#{mobeeUsersList.rowCount>0}" rows="5"

                          headerClass="headerGreen1" rowClasses="odd,even">

                          <f:facet name="header">

                              <rich:columnGroup>

                                  <rich:column headerClass="headerGreen1">

                                      <h:outputText>First Name</h:outputText>

                                  </rich:column>

                                  <rich:column headerClass="headerGreen1">

                                      <h:outputText>Last Name</h:outputText>

                                  </rich:column>

                                  <rich:column headerClass="headerGreen1">

                                      <h:outputText>Email Address</h:outputText>

                                  </rich:column>

                                  <rich:column headerClass="headerGreen1">

                                      <h:outputText>Gender</h:outputText>

                                  </rich:column>

                                  <rich:column>

                                      <h:outputText value="Update" />

                                  </rich:column>

                                  <rich:column>

                                      <h:outputText value="Delete" />

                                  </rich:column>

                              </rich:columnGroup>

                          </f:facet>

       

                          <rich:column align="center" filterBy="#{user.firstName}" filterEvent="onkeyup" >                       

                              <s:link value="#{user.firstName}" action="#{mobeeUserAction.update}"

                                  view="/registerEdit.xhtml" propagation="join" />

                              <!--<h:outputText value="#{user.firstName}" />-->                       

                          </rich:column>

       

                          <rich:column align="center">

                              <h:outputText value="#{user.lastName}" />

                          </rich:column>

       

                          <rich:column align="center">

                              <h:outputText value="#{user.emailAddress}" />

                          </rich:column>

       

                          <rich:column align="center">

                              <h:outputText value="#{user.gender}" />

                          </rich:column>

       

                          <rich:column align="center">

                              <h:commandLink>

                                  <h:graphicImage value="/img/update.png" style="border: 0;" />

                              </h:commandLink>

                          </rich:column>

       

                          <rich:column align="center">

                              <a4j:commandLink action="#{mobeeUserAction.delete}"

                                  reRender="custList" ajaxSingle="true">

                                  <h:graphicImage value="/img/delete.png" style="border: 0;" />

                              </a4j:commandLink>

                          </rich:column>

                      </rich:dataTable>

                      <h:commandButton action="/register.xhtml" value="Register" />

                  </rich:panel>

       

              </h:form>

          </ui:define>

      </ui:composition>

      and i am stoping here, i can't move on can any one suggest me