OAF实现下拉菜单联动

时间:2023-03-08 22:35:12
OAF实现下拉菜单联动

当需要输入多个下拉菜单选项时,可能某些下拉菜单是有级联关系的。这时候就需要使用级联的下拉菜单来解决。下面的教程将介绍如何使用ppr制作级联下拉菜单

一、新建AM

在test.oracle.apps.cux上点击右键,选择CreateApplication Module

输入 Package:test.oracle.apps.cux.ppr.server

Name:PPRAM

下一步,直到完成

二、新建VO

在test.oracle.apps.cux.ppr.server点右键,选择Create View Object

输入 Package:test.oracle.apps.cux.ppr.server

Name:SupplierVO

下一步,一直到 Step 5 SQL Statement

在Qurey Statement中输入

SELECTvendor_id,

vendor_name

FROMap_suppliers

在test.oracle.apps.cux.ppr.server点右键,选择Create View Object

输入Package:test.oracle.apps.cux.ppr.server

Name:SupplierSiteVO

下一步,一直到 Step 5 SQL Statement

在Qurey Statement中输入

SELECTvendor_site_id,

vendor_id,

vendor_site_code

FROM ap_supplier_sites_all

三、添加VO到AM中

双击PPRAM,进入AM编辑界面

在Data Model标签页中,将SupplierVO,SupplierSiteVO添加到PPRAM下

确定

四、新建PAGE页

在test.oracle.apps.cux.ppr上点击右键New->Web Tier->OA Components->Page

确定

输入 Name:PprPG

Package:test.oracle.apps.cux.ppr.webui

确定

修改PageLayout属性

ID:PageLayoutRN

AM Definition:test.oracle.apps.cux.ppr.server.PPRAM

Window Title:Tab Page

Title:Tab Page:PPR Test

右键点键pageLayout,创建一个Region,修改属性

ID:PprTestHdr

Text:级联下拉

在Header上新建一个Region,修改属性

ID:MainRN

Region Style:labeledFieldLayout

Width:100%

在MainRN上新建两个ITEM

修改Item1的属性

ID: supplier

Item Style:messageChoice

Disable Server Side Validation :True

Action Type:firePartialAction

Prompt:供应商

Disable Client Side Validation:True

Event:changeList

Picklist View Definition:test.oracle.apps.cux.ppr.server.SupplierVO

PickList View Instance:SupplierVO1

Picklist Display Attribute:VendorName

Picklist Value Attribute:VendorId

修改Item2属性

ID: supplierSite

Item Style:messageChoice

Prompt:供应商地点

Picklist View Definition:test.oracle.apps.cux.ppr.server.SupplierSiteVO

PickList View Instance:SupplierSiteVO1

Picklist Display Attribute:VendorSiteCode

Picklist Value Attribute:VendorSiteId

运行,看一下效果

五、创建CO

在PageLayoutRN上点右键,选择 Set NewController...

Package Name:test.oracle.apps.cux.ppr.webui

Class Name:  PprCO

在processRequest中加入如下代码

public void processRequest(OAPageContext pageContext, OAWebBean webBean){

super.processRequest(pageContext, webBean);

OAApplicationModule am = pageContext.getApplicationModule(webBean);

am.invokeMethod("handleListInitEvent", null);

}

在processFormRequest中加入如下代码

public voidprocessFormRequest(OAPageContext pageContext,

OAWebBeanwebBean) {

super.processFormRequest(pageContext,webBean);

OAApplicationModule am =pageContext.getApplicationModule(webBean);

if("changeList".equals(pageContext.getParameter(EVENT_PARAM))) {

Serializable[] parameters =

{ pageContext.getParameter("supplier")};

am.invokeMethod("setCondition", parameters);

}

}

在AM中,新建方法

public void setCondition(String p_vendorId){

SupplierSiteVOImpl site =this.getSupplierSiteVO1();

String whereClause = " vendor_id=" + p_vendorId;

site.setWhereClause(whereClause);

site.executeQuery();

}

public void handleListInitEvent() {

SupplierSiteVOImpl site =this.getSupplierSiteVO1();

String whereClause = " vendor_id=" + "-1";

site.setWhereClause(whereClause);

site.executeQuery();

}

运行,看一下效果