// 刷新iterator
bindings.refreshControl();
iterBind.executeQuery();
iterBind.refresh(DCIteratorBinding.RANGESIZE_UNLIMITED);

  

Bean中常用方法:

//获取binding容器
BindingContainer bindings
= BindingContext.getCurrent().getCurrentBindingsEntry();

  

//获取Page definitions的 attribute的值
AttributeBinding attr = (AttributeBinding)bindings.getControlBinding("test");
attr.setInputValue(”test”);

  

// 获取action或者方法
OperationBinding method = bindings.getOperationBinding("methodAction");
method.execute();
List errors = method.getErrors(); method = bindings.getOperationBinding(”methodAction”);
Map paramsMap = method.getParamsMap();
paramsMap.put(”param”,”value”) ;
method.execute();

  

// 从ADF Tree 或者 Table中获取数据
DCBindingContainer dcBindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
FacesCtrlHierBinding treeData = (FacesCtrlHierBinding)bc.getControlBinding(”tree”);
Row[] rows = treeData.getAllRowsInRange();

  

// 从iterator 的当前行获取一个 attribute的值
DCIteratorBinding iterBind= (DCIteratorBinding)dcBindings.get(”testIterator”);
String attribute = (String)iterBind.getCurrentRow().getAttribute(”field1″);
<code>
<code lang="java">
// 获取错误
String error = iterBind.getError().getMessage();

  

// 获取 iterator的所有行
Row[] rows = iterBind.getAllRowsInRange();
TestData dataRow = null;
for (Row row : rows) {
dataRow = (TestData)((DCDataRow)row).getDataProvider();
}

  

//获取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());

  

// 获得一个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());

  

//获取askflow的Binding
DCTaskFlowBinding tf = (DCTaskFlowBinding)dc.findExecutableBinding(”dynamicRegion1″);
<code>
<code lang="java">
//获取异常并显示到页面
catch(Exception e) {
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, e.getMessage(), “”);
FacesContext.getCurrentInstance().addMessage(null, msg);
}

  

// 重置控件的所有子控件
private void resetValueInputItems(AdfFacesContext adfFacesContext,
UIComponent component){
List items = component.getChildren();
for ( UIComponent item : items ) {
resetValueInputItems(adfFacesContext,item);
if ( item instanceof RichInputText ) {
RichInputText input = (RichInputText)item;
if ( !input.isDisabled() ) {
input.resetValue() ;
adfFacesContext.addPartialTarget(input);
};
} else if ( item instanceof RichInputDate ) {
RichInputDate input = (RichInputDate)item;
if ( !input.isDisabled() ) {
input.resetValue() ;
adfFacesContext.addPartialTarget(input);
};
}
}
}

  

// 重定向到另一个URL
ExternalContext ectx = FacesContext.getCurrentInstance().getExternalContext();
HttpServletResponse response = (HttpServletResponse)ectx.getResponse();
String url = ectx.getRequestContextPath()+”/adfAuthentication?logout=true&end_url=/faces/start.jspx”;
try {
response.sendRedirect(url);
} catch (Exception ex) {
ex.printStackTrace();
}
<code lang="java">
// 刷新控件(PPR)
AdfFacesContext.getCurrentInstance().addPartialTarget(UIComponent);
// 查找控件
private UIComponent getUIComponent(String name) {
FacesContext facesCtx = FacesContext.getCurrentInstance();
return facesCtx.getViewRoot().findComponent(name) ;
}

  

//获取 bc application module
private OEServiceImpl 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);
}

  

//获取table选中的行
RowKeySet selection = resultTable.getSelectedRowKeys();
Object[] keys = selection.toArray();
List receivers = new ArrayList(keys.length);
for ( Object key : keys ) {
User user = modelFriends.get((Integer)key);
}

  

// 获取table选中的行的另一种
for (Object facesRowKey : table.getSelectedRowKeys()) {
table.setRowKey(facesRowKey);
Object o = table.getRowData();
JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)o;
Row row = rowData.getRow();
Test testRow = (Test)((DCDataRow)row).getDataProvider() ;
}

  转载自:http://www.fmw007.com/archives/82

程序员的基础教程:菜鸟程序员

ADF backing Bean中常用的代码的更多相关文章

  1. NC65在日常开发中常用的代码写法

    标题 NC65开发相关代码 版本 1.0.1 作者 walton 说明 收集NC在日常开发中常用的代码写法,示例展示 1.查询 1.1 通过BaseDAO查询结果集并转换 //通过BaseDAO进行查 ...

  2. VS中常用C#代码段快速输入总结

    转自:https://blog.csdn.net/a980433875/article/details/12231673 Visual Studio 中有很多代码段都可以直接简写然后按TAB快速输入编 ...

  3. SEO中常用HTML代码大全,及权重排序

    做SEO必须要懂HTML,说的是一点都没错,不过其实是不需要全部都懂,最重点的你懂了会用,基本上都是事半功倍了.可以这么说一个不懂代码的优化人员不算是一个合格的好优化.下面就总结一下做优化,必须要懂得 ...

  4. JavaScript开发中常用的代码规范配置文件

    一.jsconfig.json { compilerOptions: { target: 'es6', experimentalDecorators: true, allowSyntheticDefa ...

  5. Struts2 中常用的代码

    BaseAction public class BaseAction extends ActionSupport { protected String target; public Map getRe ...

  6. WebApp 开发中常用的代码片段

    其实这里面的多数都是 iOS 上面的代码.其他平台的就没有去验证了. HTML, 从HTML文档的开始到结束排列: <meta name=”viewport” content=”width=de ...

  7. MYSQL列表中常用语句代码块

    查看数据表是否存在:SHOW TABLES; 显示已经打开的数据库:SELECT DATABASE(); 查看数据表结构:SHOW COLUMNS FROM ***(数据表名): 插入数据:INSER ...

  8. Java中常用的设计模式代码与理解

    Java中常用的设计模式代码与理解 一.单例模式 1.饿汉式 (太饿了,类加载的时候就创建实例) /** * 饿汉式单例模式 */ public class HungrySingleInstance ...

  9. 工作中常用的js、jquery自定义扩展函数代码片段

    仅记录一些我工作中常用的自定义js函数. 1.获取URL请求参数 //根据URL获取Id function GetQueryString(name) { var reg = new RegExp(&q ...

随机推荐

  1. laravel 5.3 ——路由(资源,别名)

    laravel的路由定义中,其中route:resoure(),可以直接定义类似restful风格的URL 例如:Route::resource('system/role','System\RoleC ...

  2. cecium 笔记

    1.Build文件夹 整个拷贝到public文件下,便可使用 2.BingMap(必应地图) Key申请之后,到Build/Cecium/Cecium.js更改默认Key, i.defaultKey ...

  3. mysql更新(五) 完整性约束 外键的变种 三种关系 数据的增删改

    11-数据的增删改   本节重点: 插入数据 INSERT 更新数据 UPDATE 删除数据 DELETE 再来回顾一下之前我们练过的一些操作,相信大家都对插入数据.更新数据.删除数据有了全面的认识. ...

  4. 简单学习Git

    Git是什么? Git是目前世界上最先进的分布式版本控制系统(没有之一). Git有什么特点?简单来说就是:高端大气上档次! Git的发展历史 很多人都知道,Linus在1991年创建了开源的Linu ...

  5. OpenACC Julia 图形

    ▶ 书上的代码,逐步优化绘制 Julia 图形的代码 ● 无并行优化(手动优化了变量等) #include <stdio.h> #include <stdlib.h> #inc ...

  6. 数据结构之线索二叉树——C语言实现

     线索二叉树操作 (1) 线索二叉树的表示:将每个节点中为空的做指针与右指针分别用于指针节点的前驱和后续,即可得到线索二叉树. (2) 分类:先序线索二叉树,中序线索二叉树,后续线索二叉树 (3) 增 ...

  7. 15. "wm_concat"_数据库中将查询出来的多条记录中的某个字段用","拼接起来

    例子: select wm_concat(roleid) from lbmember where userid = ? 值的形式:1,2,3 下面是把1,2,3转换为1;2;3select repla ...

  8. IIS 更新EXE文件

    IIS 更新EXE文件 MIME,add,文件扩展名带不带.都可以,会自动加上.的 文件扩展名:.exe MIME类型:application/octet-stream .ini文件

  9. Linux&Unix命令

    Linux下: 系统操作 文件操作 防火墙 权限管理 压缩和解压 安装应用 用户管理 端口 PID 应用 start & shutdown 远程操作 异常 注意点: linux系统下内容大多用 ...

  10. hibernate-list

    Hibernate多表关联查询类: 1. sql查询两个或两个以上的字段,默认情况下,list中封装的是Object[],长度与所查询的字段数一致.这种方式获取的数据只能通过index下标获取. su ...