2 Replies Latest reply: Aug 23, 2013 2:57 PM by Michael Shapira RSS

    Reset in memory filter for ViewCriteria

    Michael Shapira

      Hi. I am on Jdev 11g R2

      I have the VO which is stored in memory

           

              DrhCustomersVOImpl custVo  = (DrhCustomersVOImpl)getDrhCustomersVO1();

              custVo.setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);

              custVo.executeQuery();

       

      I want to filter this VO by using VIewCriteria

       

      Lets assume that I have a text field where I enter my filter text

      After this I call the following function

       

      public void ( String custFilter)

      {

         

              boolean isCriteriaApplied = false;
              DrhCustomersVOImpl vo = (DrhCustomersVOImpl)getDrhCustomersVO1();
              //if previously some view criteria was applied - remove it
               vo.clearViewCriterias();      
              //Define VC for in-memroy filtering

               ViewCriteria vc = vo.createViewCriteria();
               vc.setName("TreeFilter");
               //filter in memory
               vc.setCriteriaMode(ViewCriteria.CRITERIA_MODE_CACHE);
               ViewCriteriaRow vcr1 = vc.createViewCriteriaRow(); 
           
               if (!custFilter.isEmpty())
               {
                   System.out.println("Customer has values and will be applied");
                   vcr1.setAttribute("CustomerName", "LIKE "+custFilter+"%");
                   isCriteriaApplied = true;
               }
             
                                     
              if (isCriteriaApplied)
              {
                  vc.add(vcr1);
                  vo.applyViewCriteria(vc);
              }
               vo.executeQuery();

      }

       

      When I initially enter filter text I get a good result - my table is filtered by this value. Now I clear the text field. After this I expect to see that my table is being populated with  all data (as you can see I do execute vo.executeQuery() and cler the criteria), but nothing happens and I actually continue to see my table displaying  previous result (I mean if I filtered the table by word "TEST" , it continues to display the filtered row)

      In the log I see that indeed query was executed in memory without view criteria

       

      Please advice