关键字: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);
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> ... ...
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);