实际应用中,我们经常需要在AM中添加自己的方法,这些方法可以以Data Control的方式暴露出来,供ADF Faces使用。
但那些使用了非ADF技术开发的应用如何使用AM中的方法呢?
这里介绍最简便的一种方法:把AM中的方法暴露成WebService。
重要步骤说明:
1. 创建应用时选择General Application,为Project1增加ADF BC Components。
2. Create Entities from Table: 选择Employee表。
3. 生成 AM Impl类。
增加如下方法:
/* 更新员工的工资 */
public void updateSalary(Number employeeId,Number salary) {
Key key = new Key(new Object[] { employeeId });
Row row = this.getEmployeesView1().getRow(key);
row.setAttribute("Salary",salary);
try {
this.getDBTransaction().commit();
} catch (Exception ex) {
ex.printstacktrace();
}
}
/* 获取员工的工作的总时间(多少个月) */
public Number emplWorkLoad(Number employeeId) {
this.getJobHistoryView1().setNamedWhereClauseParam("bv_employeeId",employeeId);
this.getJobHistoryView1().executeQuery();
if (this.getJobHistoryView1().first() != null) {
return (Number)this.getJobHistoryView1().first().getAttribute("WorkLoad");
}
return null;
}
4. 手工创建JobHistory VO,选择Read-Only through sql query。
别忘了在AM的Data Model中,手工加入JobHistoryView。
5. 修改AM的Java和Service Interface选项。
在Client Interface中加入updateSalary和emplWorkLoad方法,这两个方法将会在Data Control中显示出来。
在Service Interface中加入updateSalary和emplWorkLoad方法,这两个方法将会被发布为WebService。
6. 修改AM的Configuration选项。
因为要发布到独立的WLS上,所以默认的Configuration要选择AppModuleService,以及JDBC DataSource形式的数据库连接。
要事先在WLS Console中配置该DataSouce。
7. 访问EM,找到发布的应用,测试两个方法。 http://localhost:7001/Application7-Project1-context-root/AppModuleService?wsdl。
但那些使用了非ADF技术开发的应用如何使用AM中的方法呢?
这里介绍最简便的一种方法:把AM中的方法暴露成WebService。
重要步骤说明:
1. 创建应用时选择General Application,为Project1增加ADF BC Components。
2. Create Entities from Table: 选择Employee表。
3. 生成 AM Impl类。
增加如下方法:
/* 更新员工的工资 */
public void updateSalary(Number employeeId,Number salary) {
Key key = new Key(new Object[] { employeeId });
Row row = this.getEmployeesView1().getRow(key);
row.setAttribute("Salary",salary);
try {
this.getDBTransaction().commit();
} catch (Exception ex) {
ex.printstacktrace();
}
}
/* 获取员工的工作的总时间(多少个月) */
public Number emplWorkLoad(Number employeeId) {
this.getJobHistoryView1().setNamedWhereClauseParam("bv_employeeId",employeeId);
this.getJobHistoryView1().executeQuery();
if (this.getJobHistoryView1().first() != null) {
return (Number)this.getJobHistoryView1().first().getAttribute("WorkLoad");
}
return null;
}
4. 手工创建JobHistory VO,选择Read-Only through sql query。
别忘了在AM的Data Model中,手工加入JobHistoryView。
5. 修改AM的Java和Service Interface选项。
在Client Interface中加入updateSalary和emplWorkLoad方法,这两个方法将会在Data Control中显示出来。
在Service Interface中加入updateSalary和emplWorkLoad方法,这两个方法将会被发布为WebService。
6. 修改AM的Configuration选项。
因为要发布到独立的WLS上,所以默认的Configuration要选择AppModuleService,以及JDBC DataSource形式的数据库连接。
要事先在WLS Console中配置该DataSouce。
7. 访问EM,找到发布的应用,测试两个方法。 http://localhost:7001/Application7-Project1-context-root/AppModuleService?wsdl。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。