8 Replies Latest reply on Jun 10, 2009 5:15 AM by Ilya Shaikovsky

    facing problem in <rich:datascroller>

    ashutosh deora Newbie

      i am putting up my code here
      please can anybudy tell me why it is not working or am i missing something in the code



      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html 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:rich="http://richfaces.org/rich"
       xmlns:a4j="http://richfaces.org/a4j">
      
      <head>
      <script type="text/javascript">
       function clickHidden(){
      
       document.getElementById('form_id:hiddenButton').click();
      
       }
       function clicksecondHidden(){
      
       document.getElementById('form_id:secondhiddenButton').click();
      
      }
      </script>
      </head>
      <f:view>
       <h:form id="form_id">
       <table>
       <tr>
       <td align="right"><a4j:commandButton
       action="#{SessionState.populatecityList}"
       oncomplete="clickHidden();" value="clicktry" reRender="carList" />
       <a4j:commandButton id="hiddenButton" style="display:none;"
       action="#{SessionState.arrlist}" reRender="carList"
       oncomplete="clicksecondHidden();" /> <a4j:commandButton
       id="secondhiddenButton" style="display:none;"
       action="#{SessionState.nextArrlist}" reRender="carList" /></td>
       <td align="left"><a4j:status>
       <f:facet name="start">
       <h:graphicImage value="/img/ajax-loader.gif" />
       </f:facet>
       </a4j:status></td>
       </tr>
       </table>
       <rich:spacer height="30" />
       <rich:dataTable id="carList" rows="10" columnClasses="col"
       value="#{arrayListcomplete}" var="category">
       <rich:column sortBy="#{category}">
       <f:facet name="header">
       <h:outputText value="List" />
       </f:facet>
       <h:outputText value="#{category}" />
       </rich:column>
       </rich:dataTable>
       <rich:datascroller align="left" for="carList" maxPages="20"
       page="#{SessionState.scrollerPage}" id="sc2"
       pagesVar="#{SessionState.scrollerPage}"
       value="#{SessionState.scrollerPage}" />
       </h:form>
      
      </f:view>
      </html>




      here is my bean class


      
      package sessionbean;
      
      import java.util.ArrayList;
      import java.util.List;
      
      import javax.ejb.Remove;
      import javax.ejb.Stateful;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;
      
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      
      import entity.CityNames;
      import entity.StateNames;
      
      @Stateful
      @Name("SessionState")
      public class StateSession implements StateSessioinLocal {
       @PersistenceContext
       EntityManager entityManager;
       @In(required = false)
       @Out(required = false)
       List<StateNames> stateList;
       @Out(required = false)
       List<CityNames> cityList;
      
       @In(required = false, scope = ScopeType.PAGE)
       @Out(required = false, scope = ScopeType.PAGE)
       ArrayList<String> arrayListcomplete = new ArrayList<String>();
       private int scrollerPage;
      
       public ArrayList<String> populatecityList() {
      
       arrayListcomplete = new ArrayList<String>();
       if (cityList == null) {
      
       cityList = entityManager.createQuery("select ct from CityNames ct")
       .getResultList();
       }
       for (int i = 0; i < cityList.size(); i++) {
       String cityvalue = cityList.get(i).getCityName();
       // System.out.println(cityvalue);
       arrayListcomplete.add(cityvalue);
       }
      
       if (stateList == null) {
      
       stateList = entityManager.createQuery(
       "select st from StateNames st").getResultList();
       }
       for (int i = 0; i < stateList.size(); i++) {
       String statevalue = stateList.get(i).getStateName();
       // System.out.println(statevalue);
       arrayListcomplete.add(statevalue);
      
       }
      
       return arrayListcomplete;
       }
      
       public ArrayList<String> arrlist() {
       // arrayListcomplete = new ArrayList<String>();
       try {
       System.out.println("arraysize" + arrayListcomplete.size());
       } catch (Exception exception) {
       exception.printStackTrace();
       }
      
       for (int i = 1; i < 1000; i++) {
       String addval = null;
       addval = String.valueOf(i);
       System.out.println(addval);
      
       arrayListcomplete.add(addval);
       }
      
       return arrayListcomplete;
      
       }
      
       public ArrayList<String> nextArrlist() {
       // arrayListcomplete = new ArrayList<String>();
       try {
       System.out.println("arraysize" + arrayListcomplete.size());
       } catch (Exception exception) {
       exception.printStackTrace();
       }
      
       for (int i = 1; i < 1000; i++) {
       String addval = null;
       addval = String.valueOf(i);
       System.out.println("second list " + addval);
      
       arrayListcomplete.add(addval);
       i += 1;
       }
      
       return arrayListcomplete;
      
       }
      
       public void setScrollerPage(int scrollerPage) {
       this.scrollerPage = scrollerPage;
       }
      
       public int getScrollerPage() {
       return scrollerPage;
       }
      
       @Destroy
       @Remove
       public void stateDestroy() {
       System.out.println("DESTROYED/REMOVED");
      
       }
      
      }