Please disable your adblock and script blockers to view this page

Search this blog

Wednesday 3 July 2013

Creating Dynamic View Object at Runtime programmatically - Oracle ADF

Dynamic ViewObject refers to creating ViewObject at Runtime using SQL statement,
ApplicationModuleImpl has a method to create ViewObject using Sql statement i;e createViewObjectFromQueryStmt .

this method creates a readonly viewObject at runtime when query is processed in the method

Follow these simple steps-

  • First create a dummy ViewObject using dual  


  • Now add this ViewObject to Application Module

  • I am doing this in managed bean, get application module and call method to create dynamic ViewObject
  •          get Application Module-




        public Object resolvElDC(String data) {
            FacesContext fc = FacesContext.getCurrentInstance();
            Application app = fc.getApplication();
            ExpressionFactory elFactory = app.getExpressionFactory();
            ELContext elContext = fc.getELContext();
            ValueExpression valueExp =
                elFactory.createValueExpression(elContext, "#{data." + data + ".dataProvider}", Object.class);
            return valueExp.getValue(elContext);
        }
    
        public dynamicAMImpl getAm() {
            dynamicAMImpl am = (dynamicAMImpl)resolvElDC("dynamicAMDataControl");
            return am;
        }
    

            create dynamic ViewObject-


            ViewObject dynVo = getAm().getdynamic1();
            dynVo.remove();
            getAm().createViewObjectFromQueryStmt("dynamic1", query);
    

  • Now Run your application and see-


Download -Sample ADF Application

1 comment :

  1. Hi,
    There is a View Object which is created dynamically using the createViewObjectFromQueryStmt , In my query there might be Date columns available and i need to format those columns to different formats ( Format will be retrieved from Database based on user settings ) . This JSFF page is for reporting the data fetched from the dynamic query and it has sorting and filtering on , So this formatting of date should not affect the sorting and filtering of date columns . Since i am new to ADF i am not sure how to format these dates , It will be grateful if anyone can send me a sample project with the above scenario or else guide me on how to do this.

    ReplyDelete