Sunday, January 20, 2013

How to change view criteria at run time

How to change ViewCriteria At runtime

Sometime we get requirement to change the add or remove attribute to query panel at runtime.
This post will help everybody to achieve that functionality.

Idea is just to play around the query-able attribute of viewobject at runtime. you just have to set it true /false.

    protected void setQueriable(ViewObject vo, String attributeName, boolean condition) {
         // set the attribute queryable as needed
         // getting the ELContext from faces context
         // get application from faces context
       
         AttributeDef def = vo.getAttributeDef(vo.getAttributeIndexOf(attributeName));
         boolean queryable = condition;

         // set/reset queriable only if needed
         if (def != null && def.isQueriable() != queryable) {
             AttributeDefImpl attributeDef = (AttributeDefImpl)def;
             attributeDef.setQueriable(queryable);
             attributeDef.registerDefObject();
         }
    
}

This piece of code it responsible for adding and removing attribute from  af:quereyPanel.

 
 
 
 


Find application source here ChangeCriteriaAtRuntime

6 comments:

  1. I appreciate you sharing this article. Really thank you! Much obliged.
    This is one awesome blog article. Much thanks again.


    sap online training
    software online training
    sap sd online training
    hadoop online training
    sap-crm-online-training

    ReplyDelete
  2. Pretty good post. I just came across your site and wanted to say that I’ve really enjoyed reading your posts. In any case I’ll be subscribing to your feed and I hope you will keep a good work!Cheer!


    sap online training
    software online training
    sap sd online training
    hadoop online training
    sap-crm-online-training

    ReplyDelete
  3. This is one awesome blog article. Much thanks again.
    I really enjoy the blog.Much thanks again. Really Great.


    oracle online training
    sap fico online training
    dotnet online training
    qa-qtp-software-testing-training-tutorial

    ReplyDelete
  4. Latest Government Jobs 2016

    Right place for accurate information.......... keep sharing your views...........

    ReplyDelete
  5. Latest Govt Jobs Notification 2016


    I have visited this blog first time and i got a lot of informative data from here which is quiet helpful for me indeed..............

    ReplyDelete
  6. Where is this application code ?, i am getting error ChangeCriteriaAtRuntime.rar . can you send me sanjaygouda@gmail.com

    ReplyDelete

Thanks for your valuable comment. You comment will go live soon.