Groovy在ADF BC中的常见用法之一
2015-08-07 14:30
369 查看
开发运行环境:JDeveloper 11.1.2.4
1. 设置EO或VO的Attribute值
(1)在Employees EO上增加一个Attribute:AnnualSalary,Expression: (Salary != null ? Salary : 0 ) * 12。
(2)如果需要引用EntityImpl类中的自定义方法,需要加前缀:adf.object。
比如:adf.object.getDefaultSalaryForGrade()。
这里,adf.object指向的是当前EntityImpl。
2. 定义在EO的Attribute上的验证规则
(1)在Employees EO的Salary Attribute增加一个验证规则:
if (JobId == "SA_REP"){
return newValue < 1000
} else
return true
在验证规则中reference一个Attribute时,Attribute-level的验证规则首先被触发,验证该Attribute的newValue值。newValue是用户输入后改变的值,oldValue是改变之前的值。
(2)在Employees EO的Salary Attribute增加另一个验证规则,其中调用了EntityImpl类中的自定义方法:getMaxSalaryForGrade。
if (JobId == "SA_MAN"){
return newValue < source.getMaxSalaryForGrade(JobId)
} else
return true
注意,reference方法前要加前缀“source”。
3. 访问EntityImpl类的自有方法
(1)Override create方法
/**
* Add attribute defaulting logic in this method.
* @param attributeList list of attribute names/values to initialize the row
*/
protected void create(AttributeList attributeList) {
super.create(attributeList);
SequenceImpl seq = new SequenceImpl("EMPLOYEES_SEQ", getDBTransaction());
oracle.jbo.domain.Number seqNextVal = seq.getSequenceNumber();
setEmployeeId(Integer.valueOf(seqNextVal.intValue()));
}
这样修改后,EmployeeId的值将从Sequence中获取。
(2)如果你不想Override create方法,也可以直接使用Groovy表达式来获取Sequence的下一个值。
设置EmployeeId的Expression:(new oracle.jbo.server.SequenceImpl("EMPLOYEES_SEQ",adf.object.getDBTransaction())).getSequenceNumber()
注意,这里必须写全类SequenceImpl的路径名。
(3)如果你觉得(2)的方式有些不直观,可以在EntityImpl中定义一个Help方法。
public oracle.jbo.domain.Number nextVal(String sequenceName) {
SequenceImpl s = new SequenceImpl(sequenceName, getDBTransaction());
return s.getSequenceNumber();
}
然后,设置EmployeeId的Expression:adf.object.nextVal("EMPLOYEES_SEQ")。
4. 访问hints属性
(1)如果想访问LastName的label属性,可以这样写:adf.object.hints.LastName.label。
(2)如果在error message中想访问LastName的label属性,可以这样写:source.hints.LastName.label。
文章来自:
http://maping930883.blogspot.com/2013/06/adf233groovyadf-bc.html
1. 设置EO或VO的Attribute值
(1)在Employees EO上增加一个Attribute:AnnualSalary,Expression: (Salary != null ? Salary : 0 ) * 12。
(2)如果需要引用EntityImpl类中的自定义方法,需要加前缀:adf.object。
比如:adf.object.getDefaultSalaryForGrade()。
这里,adf.object指向的是当前EntityImpl。
2. 定义在EO的Attribute上的验证规则
(1)在Employees EO的Salary Attribute增加一个验证规则:
if (JobId == "SA_REP"){
return newValue < 1000
} else
return true
在验证规则中reference一个Attribute时,Attribute-level的验证规则首先被触发,验证该Attribute的newValue值。newValue是用户输入后改变的值,oldValue是改变之前的值。
(2)在Employees EO的Salary Attribute增加另一个验证规则,其中调用了EntityImpl类中的自定义方法:getMaxSalaryForGrade。
if (JobId == "SA_MAN"){
return newValue < source.getMaxSalaryForGrade(JobId)
} else
return true
注意,reference方法前要加前缀“source”。
3. 访问EntityImpl类的自有方法
(1)Override create方法
/**
* Add attribute defaulting logic in this method.
* @param attributeList list of attribute names/values to initialize the row
*/
protected void create(AttributeList attributeList) {
super.create(attributeList);
SequenceImpl seq = new SequenceImpl("EMPLOYEES_SEQ", getDBTransaction());
oracle.jbo.domain.Number seqNextVal = seq.getSequenceNumber();
setEmployeeId(Integer.valueOf(seqNextVal.intValue()));
}
这样修改后,EmployeeId的值将从Sequence中获取。
(2)如果你不想Override create方法,也可以直接使用Groovy表达式来获取Sequence的下一个值。
设置EmployeeId的Expression:(new oracle.jbo.server.SequenceImpl("EMPLOYEES_SEQ",adf.object.getDBTransaction())).getSequenceNumber()
注意,这里必须写全类SequenceImpl的路径名。
(3)如果你觉得(2)的方式有些不直观,可以在EntityImpl中定义一个Help方法。
public oracle.jbo.domain.Number nextVal(String sequenceName) {
SequenceImpl s = new SequenceImpl(sequenceName, getDBTransaction());
return s.getSequenceNumber();
}
然后,设置EmployeeId的Expression:adf.object.nextVal("EMPLOYEES_SEQ")。
4. 访问hints属性
(1)如果想访问LastName的label属性,可以这样写:adf.object.hints.LastName.label。
(2)如果在error message中想访问LastName的label属性,可以这样写:source.hints.LastName.label。
文章来自:
http://maping930883.blogspot.com/2013/06/adf233groovyadf-bc.html
相关文章推荐
- POJ 1035 Spell checker
- java传递json数据到前台jsp
- [转] When exactly does the virtual table pointer (in C++) gets set for an object?
- Mac 10.10 配置tomcat 服务器
- Kernel那些事儿之内存管理(12) --- 内核映射(中)
- 网络请求(一)
- [Splay的应用]
- Oracle to_date()函数的用法
- 关于一个时间转换小功能开发
- 截取文本里特定连续字段并去掉多余空格
- Object源码研究1——整体研究
- jwhois
- HDU 4508(湫湫系列故事——减肥记I)基础完全背包
- Data collection is easy. Decision making is hard.
- string类详解
- html中<base>标签的使用,和简介
- 算法题:二叉树的构造
- 碰撞运动js
- 苹果App转移图文详解-Transfer App
- JavaScript中callee,caller,argument的理解