05 May, 2012

ADF & OAF : Add Attribute to View Object Progmatically

You can add transient attribute to view object progmatically at run time.
You can use this transient attribute to store any temporary data for every row in view object or create generic solution in your custom framework for general purpose.

ADF
in ِADF you can use below code anywhere in ApplicationModuleImpl class
I will check existence of attribute XXAttr, If it is not exist I will add it to view object
     ViewObject vo = this.findViewObject("ViewObjectName");  
     if (vo != null) {  
       try {  
         String transientAttr = vo.findAttributeDef("XXAttr").toString();  
       } catch (Exception e) {  
         vo.addDynamicAttribute("XXAttr");  
       }  
     }  


OAF
Same like sample in ADF I will check existence of attribute XXAttr, If it is not exist I will add it to view object


    public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
        super.processRequest(pageContext, webBean);

        OAApplicationModule am = pageContext.getApplicationModule(webBean);
        OAViewObject vo = (OAViewObject)am.findViewObject("ViewObjectName");

        if (vo != null) {
            try {
                String transientAttr = 
                    vo.findAttributeDef("XXAttr").toString();
            } catch (Exception e) {
                vo.addDynamicAttribute("XXAttr");
            }
        }
    }

Thanks
Mahmoud A. El-Sayed

1 comment:

  1. Ӏ write a commеnt each time I еsρecially enjοy a aгticle on a site or if I hаvе somethіng to аdd
    tо the ԁiscuѕsion. It's caused by the sincerness communicated in the article I looked at. And on this article "ADF & OAF : Add Attribute to View Object Progmatically". I was actually excited enough to drop a commenta response :-P I actually do have a few questions for you if you do not mind. Is it only me or do some of the responses look as if they are left by brain dead visitors? :-P And, if you are writing on additional online social sites, I'd like to fοlloω everything nеω уou havе to post.
    Cοulԁ yоu make a list eѵeгy one of all
    your soсіal pages lіκе your lіnkeԁin pгοfile,
    Facebоok page оr twіtteг feed?
    Here is my web blog : online payday loans

    ReplyDelete

ADF : Scope Variables

Oracle ADF uses many variables and each variable has a scope. There are five scopes in ADF (Application, Request, Session, View and PageFl...