ADF backing Bean中常用的代码
// 刷新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中常用的代码的更多相关文章
- NC65在日常开发中常用的代码写法
标题 NC65开发相关代码 版本 1.0.1 作者 walton 说明 收集NC在日常开发中常用的代码写法,示例展示 1.查询 1.1 通过BaseDAO查询结果集并转换 //通过BaseDAO进行查 ...
- VS中常用C#代码段快速输入总结
转自:https://blog.csdn.net/a980433875/article/details/12231673 Visual Studio 中有很多代码段都可以直接简写然后按TAB快速输入编 ...
- SEO中常用HTML代码大全,及权重排序
做SEO必须要懂HTML,说的是一点都没错,不过其实是不需要全部都懂,最重点的你懂了会用,基本上都是事半功倍了.可以这么说一个不懂代码的优化人员不算是一个合格的好优化.下面就总结一下做优化,必须要懂得 ...
- JavaScript开发中常用的代码规范配置文件
一.jsconfig.json { compilerOptions: { target: 'es6', experimentalDecorators: true, allowSyntheticDefa ...
- Struts2 中常用的代码
BaseAction public class BaseAction extends ActionSupport { protected String target; public Map getRe ...
- WebApp 开发中常用的代码片段
其实这里面的多数都是 iOS 上面的代码.其他平台的就没有去验证了. HTML, 从HTML文档的开始到结束排列: <meta name=”viewport” content=”width=de ...
- MYSQL列表中常用语句代码块
查看数据表是否存在:SHOW TABLES; 显示已经打开的数据库:SELECT DATABASE(); 查看数据表结构:SHOW COLUMNS FROM ***(数据表名): 插入数据:INSER ...
- Java中常用的设计模式代码与理解
Java中常用的设计模式代码与理解 一.单例模式 1.饿汉式 (太饿了,类加载的时候就创建实例) /** * 饿汉式单例模式 */ public class HungrySingleInstance ...
- 工作中常用的js、jquery自定义扩展函数代码片段
仅记录一些我工作中常用的自定义js函数. 1.获取URL请求参数 //根据URL获取Id function GetQueryString(name) { var reg = new RegExp(&q ...
随机推荐
- jQuery动态的给页面中添加一条样式表的链接
HTML部分: <input type="button" value="单击" onclick="getbody()" /> & ...
- 对于入门Demo的看法
对于一些以前没有接触过的技术,网上一搜,了解一些介绍信息,原理以及一些代码API的大致了解,接下来应该开始一个小Demo例子. 网上现在好多的教材,多数不知是怎么写的,基本大致一个样,对于初学者没什么 ...
- 为solr增加用户验证
添加此功能主要是为了增加solr服务器的安全性,不能随便让人访问. 1. 在tomcat的F:\Tomcat 6.0.26_solr\conf\tomcat-users.xml添加用户角色并 ...
- solr的multivalued使用说明
solr的schema.xml配置文件在配置Filed的时候,有个属性: MutiValued:true if this field may containmutiple values per doc ...
- [Mysql]查看版本号的五种方式
[Mysql]查看版本号的五种方式 目录(?)[+] 查看版本信息 #1 使用命令行模式进入mysql会看到最开始的提示符 Your MySQL connection id is 3Serve ...
- 内置锁(三)synchronized的几个要注意的对象监视器
前言 经过前面的两篇文章的介绍,可以清楚知道,synchronized可以用于修饰一个方法 或者 代码块,线程要访问这些临界区代码,则要先获取对应的 对象监视器 ,从而使多个线程互斥访问临界区. ...
- node进阶之用流实现上传文件
内容: 1.文件上传基础 2.node文件处理机制 3.用流实现文件上传 1.文件上传基础 前端代码: <form action="localhost:8080/" meth ...
- Zabbix监控系统进程
参考网站: https://www.linuxidc.com/Linux/2016-11/137649.htm
- 3.Web项目中使用Log4j实例
转自:https://blog.csdn.net/luohai859/article/details/52250807 上面代码描述了Log4j的简单应用,其实使用Log4j也就是这样简单方便.当然除 ...
- Java工具类实现校验公民身份证的有效性
转自:https://www.oschina.net/code/snippet_1859292_39120 1 package com.tg.user.controller; import java. ...