2 Replies Latest reply on Mar 28, 2007 11:06 AM by furic

    Perfomance tuning

    furic

      Hello
      I'm not sure this is the correct forum, but still... may be someone could help me.
      My backing bean has method getTableData to fetch data from DB according to filter values(wich are properties of the same bean)

      class MyBean{
      private String filterField1;
      private String filterField2;
      
      public List getTableData(){
       return daoObj.getData(filterField1,filterField2...);
      }
      }
      


      jsp:
       <h:input value=#{myBean.filterField1}/>
       <h:input value=#{myBean.filterField2}/>
      <h:coomandButton type="sumbit"/>
       <h:table value=#{myBean.tableData} var="entity">
       ....
      </h:table>
      


      getTableData function is accessed few times (once per each phase). I want to fetch data from DB only once , when all filter values are updated to bean. How this can be accomplished ? Do i need some kind of phase aware bean? Can i return null for earlier phases ?
      Thanks


        • 1. Re: Perfomance tuning
          mail.micke

          Maybe something like this:

          class MyBean{
           private String filterField1;
           private String filterField2;
          
           private List tableDataCache=null;
          
           public List getTableData(){
           // Perhaps a check to see if the filters have changed, and update if they have
          
           if( tableDataCache == null ){
           tableDataCache = daoObj.getData(filterField1,filterField2...);
           }
           return tableDataCache ;
           }
          }
          


          • 2. Re: Perfomance tuning
            furic

            Thanks for replay, but what if there are no filters at all?

            Is there any standard solution for this issue ?
            i think i'm not the first developer facing this problem (it's very common case), don't want to discover the wheel here...