ADF中调用JavaScript的方法

关键字:Oracle ADF,JavaScript

开发环境:JDeveloper 11.1.1.3.0


目前我掌握的在ADF页面中调用JavaScript的方法有以下两种:

1,使用clientListener事件,其中doEnterKeyDown是定义好的JavaScript函数,type是触发doEnterKeyDown的时机,也就是在按下键盘按键的时候。

1)ADF的输入型组件(af:inputText)中,type有:blur, click, contextMenu, dbClick, focus, keyDown, keyPress, keyUp, mouseDown, mouseOver, mouseOut, mouseUp, propertyChange, valueChange。其中blur是丢失光标,contextMenu是右键动作,focus是得到光标,propertyChange是组件的属性改变,valueChange是值变化。

2)ADF的命令型组件(af: commandButton)中,type有:action, blur, click, contextMenu, dbClick, focus, keyDown, keyPress, keyUp, mouseDown, mouseOver, mouseOut, mouseUp, propertyChange。

3)ADF的布局组件(af: panelGroupLayout)中,type有:click, contextMenu, dbClick, mouseDown, mouseOver, mouseOut, mouseUp, propertyChange。

   <af:clientListener method="doEnterKeyDown" type="keyDown"/>

2,在Managed Bean中调用

        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExtendedRenderKitService extendedRenderKitService =
            Service.getRenderKitService(facesContext,
                                        ExtendedRenderKitService.class);
        String script =
            "var com; com = AdfPage.PAGE.findComponent('" + strCompId +
            "'); com.setVisible(true);";
        extendedRenderKitService.addScript(facesContext, script);

补充:在页面碎片中,使用查找一个component与完整的JSPX页面中不同。当我们定义了dynamic region的时候,component的查找要从dynamic region开始。

1)dynamic region的定义

  <f:view>
    <af:document id="d1">
      <af:form id="f1" usesUpload="true">
        <af:pageTemplate viewId="/templates/SalesTemplate.jspx" id="pt1">
          <f:facet name="center">
            <af:region value="#{bindings.dynamicRegion1.regionModel}"
                       id="drHome"/>
          </f:facet>
    ... ...


2)查找组件

        UIComponent base = JSFUtils.findComponentInRoot("drHome");
        UIComponent selectItemPopup = JSFUtils.findComponent(base, popId);

        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExtendedRenderKitService extendedRenderKitService =
            Service.getRenderKitService(facesContext,
                                        ExtendedRenderKitService.class);

        String clientId = selectItemPopup.getClientId(facesContext);

        String script =
            "var popup;popup = AdfPage.PAGE.findComponent('" + clientId +
            "'); popup.show();";
        extendedRenderKitService.addScript(facesContext, script);






你可能感兴趣的:(ADF中调用JavaScript的方法)