Bean中常用方法:
1
2 3 |
//获取binding容器
BindingContainer bindings =BindingContext. getCurrent ( ). getCurrentBindingsEntry ( ) ; |
1
2 3 |
//获取Page definitions的 attribute的值
AttributeBinding attr = (AttributeBinding )bindings. getControlBinding ( "test" ) ; attr. setInputValue (”test” ) ; |
1
2 3 4 5 6 7 8 9 |
// 获取action或者方法
OperationBinding method =bindings. getOperationBinding ( "methodAction" ) ; method. execute ( ) ; Listerrors =method. getErrors ( ) ; method =bindings. getOperationBinding (”methodAction” ) ; MapparamsMap =method. getParamsMap ( ) ; paramsMap. put (”param”,”value” ) ; method. execute ( ) ; |
1
2 3 4 |
// 从ADF Tree 或者 Table中获取数据
DCBindingContainer dcBindings = (DCBindingContainer )BindingContext. getCurrent ( ). getCurrentBindingsEntry ( ) ; FacesCtrlHierBinding treeData = (FacesCtrlHierBinding )bc. getControlBinding (”tree” ) ; Row [ ]rows =treeData. getAllRowsInRange ( ) ; |
1
2 3 4 5 6 7 |
1
2 3 4 |
// 刷新iterator
bindings. refreshControl ( ) ; iterBind. executeQuery ( ) ; iterBind. refresh (DCIteratorBinding. RANGESIZE_UNLIMITED ) ; |
1
2 3 4 5 6 |
// 获取 iterator的所有行
Row [ ]rows =iterBind. getAllRowsInRange ( ) ; TestData dataRow = null ; for (Row row :rows ) { dataRow = (TestData ) ( (DCDataRow )row ). getDataProvider ( ) ; } |
1
2 3 4 5 |
//获取iterator当前行的另一种方法
FacesContext ctx =FacesContext. getCurrentInstance ( ) ; ExpressionFactory ef =ctx. getApplication ( ). getExpressionFactory ( ) ; ValueExpression ve =ef. createValueExpression (ctx. getELContext ( ), “# {bindings. testIter. currentRow. dataProvider }”, TestHead. class ) ; TestHead test = (TestHead )ve. getValue (ctx. getELContext ( ) ) ; |
1
2 3 4 5 |
// 获得一个on bean
FacesContext ctx =FacesContext. getCurrentInstance ( ) ; ExpressionFactory ef =ctx. getApplication ( ). getExpressionFactory ( ) ; ValueExpression ve =ef. createValueExpression (ctx. getELContext ( ), “# {testSessionBean }”, TestSession. class ) ; TestSession test = (TestSession )ve. getValue (ctx. getELContext ( ) ) ; |
1
2 3 4 5 6 7 8 9 |
//获取askflow的Binding
DCTaskFlowBinding tf = (DCTaskFlowBinding )dc. findExecutableBinding (”dynamicRegion1″ ) ; <code > <code lang = "java" > //获取异常并显示到页面 catch ( Exceptione ) { FacesMessage msg = newFacesMessage (FacesMessage. SEVERITY_ERROR, e. getMessage ( ), “” ) ; FacesContext. getCurrentInstance ( ). addMessage ( null, msg ) ; } |
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
// 重置控件的所有子控件
private voidresetValueInputItems (AdfFacesContext adfFacesContext, UIComponent component ) { Listitems =component. getChildren ( ) ; for (UIComponent item :items ) { resetValueInputItems (adfFacesContext,item ) ; if (item instanceofRichInputText ) { RichInputText input = (RichInputText )item ; if ( !input. isDisabled ( ) ) { input. resetValue ( ) ; adfFacesContext. addPartialTarget (input ) ; } ; } else if (item instanceofRichInputDate ) { RichInputDate input = (RichInputDate )item ; if ( !input. isDisabled ( ) ) { input. resetValue ( ) ; adfFacesContext. addPartialTarget (input ) ; } ; } } } |
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
// 重定向到另一个URL
ExternalContext ectx =FacesContext. getCurrentInstance ( ). getExternalContext ( ) ; HttpServletResponse response = (HttpServletResponse )ectx. getResponse ( ) ; Stringurl =ectx. getRequestContextPath ( ) +” /adfAuthentication ?logout =true & ;end_url =/faces /start. jspx” ; try { response. sendRedirect (url ) ; } catch ( Exceptionex ) { ex. printStackTrace ( ) ; } <code lang = "java" > // 刷新控件(PPR) AdfFacesContext. getCurrentInstance ( ). addPartialTarget (UIComponent ) ; // 查找控件 privateUIComponent getUIComponent ( Stringname ) { FacesContext facesCtx =FacesContext. getCurrentInstance ( ) ; returnfacesCtx. getViewRoot ( ). findComponent (name ) ; } |
1
2 3 4 5 6 7 8 9 10 11 |
//获取 bc application module
privateOEServiceImpl getAm ( ) { FacesContext fc =FacesContext. getCurrentInstance ( ) ; Application app =fc. getApplication ( ) ; ExpressionFactory elFactory =app. getExpressionFactory ( ) ; ELContext elContext =fc. getELContext ( ) ; ValueExpression valueExp = elFactory. createValueExpression (elContext, “# {data. OEServiceDataControl. dataProvider }”, Object. class ) ; return (OEServiceImpl )valueExp. getValue (elContext ) ; } |
1
2 3 4 5 6 7 |
1
2 3 4 5 6 7 8 |
// 获取table选中的行的另一种
for ( ObjectfacesRowKey :table. getSelectedRowKeys ( ) ) { table. setRowKey (facesRowKey ) ; Objecto =table. getRowData ( ) ; JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding )o ; Row row =rowData. getRow ( ) ; Test testRow = (Test ) ( (DCDataRow )row ). getDataProvider ( ) ; } |