Creating Dynamic View Object at Runtime programmatically - Oracle ADF

本文介绍如何在 Oracle ADF 中使用 SQL 语句在运行时创建动态 ViewObject。通过 ApplicationModuleImpl 的 createViewObjectFromQueryStmt 方法实现只读视图对象的创建,并提供了一个简单的示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Creating Dynamic View Object at Runtime programmatically - Oracle ADF

name="f2b9b6b93" width="1000px" height="1000px" frameborder="0" allowtransparency="true" allowfullscreen="true" scrolling="no" title="fb:like Facebook Social Plugin" src="http://www.facebook.com/plugins/like.php?action=like&app_id=359694367423525&channel=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter%2FBhKMRj1sUPu.js%3Fversion%3D41%23cb%3Df20381482%26domain%3Dwww.awasthiashish.com%26origin%3Dhttp%253A%252F%252Fwww.awasthiashish.com%252Ff302fe217c%26relation%3Dparent.parent&container_width=666&href=http%3A%2F%2Fwww.awasthiashish.com%2F2013%2F07%2Fcreating-dynamic-view-object-at-runtime.html&layout=standard&locale=en_US&sdk=joey&share=true&show_faces=true" style="position: absolute; border-style: none; width: 450px; height: 20px;">
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
frameborder="0" hspace="0" marginheight="0" marginwidth="0" scrolling="no" tabindex="0" vspace="0" width="100%" id="I0_1438744921005" name="I0_1438744921005" src="https://apis.google.com/_/widget/render/comments?usegapi=1&href=http%3A%2F%2Fwww.awasthiashish.com%2F2013%2F07%2Fcreating-dynamic-view-object-at-runtime.html&query=http%3A%2F%2Fwww.awasthiashish.com%2F2013%2F07%2Fcreating-dynamic-view-object-at-runtime.html&first_party_property=BLOGGER&legacy_comment_moderation_url=https%3A%2F%2Fwww.blogger.com%2Fmoderate-legacy-comment.g%3FblogID%3D5760168315986122884&view_type=FILTERED_POSTMOD&width=666&hl=en_GB&origin=http%3A%2F%2Fwww.awasthiashish.com&search=&hash=&gsrc=3p&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.zh_CN.IHYPh-dnqh4.O%2Fm%3D__features__%2Fam%3DAQ%2Frt%3Dj%2Fd%3D1%2Ft%3Dzcms%2Frs%3DAGLTcCNdNEXowUAdLcso7x1hlt5I3hjfrQ#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled%2Cdrefresh%2Cerefresh%2Cscroll%2Copenwindow&id=I0_1438744921005&parent=http%3A%2F%2Fwww.awasthiashish.com&pfname=&rpctoken=41356580" title="Comment on this" data-gapiattached="true" style="position: static; top: 0px; width: 666px; margin: 0px; border-style: none; left: 0px; height: 2037px;">
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值