Oracle ADF 11g后台常用方法(1)

1.获取am的方法

public TestAmImpl getAm(){
       FacesContext ctx = FacesContext.getCurrentInstance();
            Application app = ctx.getApplication();
            ValueBinding bind = app.createValueBinding("#{bindings}");
            DCBindingContainer dc = (DCBindingContainer)bind.getValue(ctx) ;
            DCDataControl dcc = dc.findDataControl("AppModuleDataControl");
            return (TestAmImpl)dcc.getDataProvider();

    }

2.获取vo当前行

public Row getCurrentRow(){
        ViewObject vo = getAm().findViewObject("TestVVO");
        return vo.getCurrentRow();
    }

3.设置vo中的值,并设置第一行为当前行

    public void exeVo(){
        ViewObject vo = getAm().findViewObject("TestVVO");
        vo.setWhereClause("1=1")
        vo.executeQuery();
        vo.setsetCurrentRow(vo.getRowAtRangeIndex(0));
    }

4.vo保存数据到数据库

    public void commit(){
        getAm().getTransaction().commit();
    }

5.am执行sql

    public ResultSet execute_DBFunction(String functionSql){
        Statement stmt = this.getDBTransaction().createStatement(1);
        ResultSet rs = stmt.executeQuery(functionSql);
    }

6.通过组件id获取页面组件

    FacesContext.getCurrentInstance().getViewRoot().findComponent("id");

7.刷新ppr组件

    AdfFacesContext.getCurrentInstance().addPartialTarget(UIComponent);

8.后台执行js的方法

    public void exeJsMeth(){
        FacesContext facesContext = FacesContext.getCurrentInstance(); 
        ExtendedRenderKitService service = (ExtendedRenderKitService) org.apache.myfaces.trinidad.util.Service.getRenderKitService(facesContext, ExtendedRenderKitService.class);
        service.addScript(facesContext, "jsMeth();");
    }

9.页面加载完毕后执行bean的方法

    <af:serverListener type="onloadEvent" method="#{tesstBean.test}" />
    <af:clientListener type="load" method="trrigerOnload"/>
    <af:resource type="javascript">
        function trrigerOnload(event){
            AdfCustomEvent.queue(event.getSource(),"onloadEvent",{taskId:"${param.taskId}"},false);
            return true;
        }
    </af:resource>

10.执行表达式的方法

    private void handleTreeSelection(SelectionEvent selectionEvent, String el) {
        FacesContext fctx = FacesContext.getCurrentInstance();
        ELContext elctx = fctx.getELContext();
        ExpressionFactory exprFactory = fctx.getApplication().getExpressionFactory();

        MethodExpression me =
            exprFactory.createMethodExpression(elctx, el, Object.class, new Class[] { SelectionEvent.class });
        me.invoke(elctx, new Object[] { selectionEvent });
    }
    // 另外执行表达式的方法
    public static Object invokeMethod(String expr, Class[] paramTypes, Object[] params) {
          FacesContext fc = FacesContext.getCurrentInstance();
          MethodBinding mb = fc.getApplication().createMethodBinding(expr.trim(), paramTypes);
          return mb.invoke(fc, params);
    }
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值