2 Replies Latest reply on May 19, 2010 9:33 AM by jeric

    Too many requests? (rich:Calendar)

    jeric

      Hello everyone,

       

      I'm having a question about the usage of the rich:calendar component --

       

      I have a table that is filled whenever I choose another date on the calendar. This seems to work, but when I view the logging, I see the following events:

       

      • table 'getters' are called, filling the table with the old data
      • setter is called
      • table 'getters' are called again, this time with the updated data

       

      Every table getter currently fires a query to a database, and what I want to achieve is only one query, after the date is updated.

       

      I'm using the latest version of Richfaces, and JSF 2.0. The application is deployed on Tomcat 6 (We're currently migrating to jBoss though ;-))

       

      My current code looks like this:

       

       

      main.jsp

       

       

       

      <rich:panel styleClass="panel">

       

         <h:outputLabel for="calendar" value="Date:" />

        

         <a4j:outputPanel id="calendar" layout="block" >

       

            <rich:calendar value="#{mainBean.selectedDate}" popup="true"

               datePattern="yyyy-MM-dd" showApplyButton="false" cellWidth="24px" cellHeight="22px" >

              

               <a4j:support event="onchanged" reRender="curDate" />

           

            </rich:calendar>

       

         </a4j:outputPanel>

        

         <h:outputText id="curDate" value="#{mainBean.selectedDate}" />

       

      </rich:panel>

       

       

      MainBean.java (the relevant methods)

       

       

      public class MainManagedBean extends ManagedBean {


        private Date selectedDate;


        public List<DashBoardBean> getMockUpDashboard() {

          System.out.println("Getting mockup data");

          return mockUpDashboard;

        }



        public void changeSendDate(CurrentDateChangeEvent event) {

          System.out.println("ValueChangeEvent: " + event.getCurrentDate());

          FacesContext.getCurrentInstance().renderResponse();     // This doesn't seem to fix my problem    

        }


        public Date getSelectedDate() {

          return selectedDate;

        }


        public void setSelectedDate(Date selectedDate) {

          System.out.println("Date set: " + selectedDate);

          this.selectedDate = selectedDate;

        }

      }

       

       

      Richfaces related items in my web.xml:

       

           <context-param>

                <param-name>javax.faces.STATE_SAVING_METHOD</param-name>

                <param-value>client</param-value>

           </context-param>


           <context-param>

                <param-name>org.richfaces.SKIN</param-name>

                <param-value>blueSky</param-value>

           </context-param>


           <context-param>

                <param-name>org.richfaces.CONTROL_SKINNING</param-name>

                <param-value>enable</param-value>

           </context-param>


           <filter>

                <display-name>RichFaces Filter</display-name>

                <filter-name>richfaces</filter-name>

                <filter-class>org.ajax4jsf.Filter</filter-class>

           </filter>


           <filter-mapping>

                <filter-name>richfaces</filter-name>

                <servlet-name>Faces Servlet</servlet-name>

                <dispatcher>REQUEST</dispatcher>

                <dispatcher>FORWARD</dispatcher>

                <dispatcher>INCLUDE</dispatcher>

           </filter-mapping>


       

      When I change the date, this is what I see in my log:

       

      Getting mockup data

      Date set: Thu May 20 00:00:00 CEST 2010

      Getting mockup data

       

      I also tried using the following support tags, but then I only received the date that I selected *before*, besides the problem I described above...

       

      <a4j:support event="ondateselected" reRender="curDate" />

      <a4j:support event="ondateselect" reRender="curDate" />

       

      I've been searching for a long time now, so I really hope someone can help me with this.

       

      Kind regards and thanks in advance!