您的位置:首页 > 其它

FORM 开发相关技巧2

2013-11-07 13:25 218 查看
13 , Dependencies item的编程

语法:

1.APP_FIELD.SET_DEPENDENT_FIELD(EVENT,:block.master_item = CONDITION,

‘block.dependent_item’);

用途:A conditionally-dependent item changes validation when the value in the master

item changes. Specify the condition rather than the master item name.

This procedure makes an item enterable or not enterable based on whether the master item

is NULL or a specified condition is TRUE, and clears the field. The dependent item can be

a text item, check box, or poplist.

You typically call this procedure in the following triggers:

? WHEN–VALIDATE–ITEM on the master field

? WHEN–VALIDATE–ITEM on the field(s) the condition is based on or in event INIT

on the dependent field

? PRE–RECORD

? POST–QUERY (required only when the dependent item is in a

multi–record block)

:block.master_item = CONDITION包括:

--APP_FIELD.SET_DEPENDENT_FIELD(EVENT,(:block.master_item IS NOT NULL),

’block.dependent_item’);用于Multiple items may depend on a single master.

--APP_FIELD.SET_DEPENDENT_FIELD(EVENT,((:block.master_item1 IS NOT NULL) AND

(:block.master_item2 IS NOT NULL)),’block.dependent_item’);

用于Two master items may share a dependent item.

--APP_FIELD.SET_DEPENDENT_FIELD(EVENT,’block.master_item,’block.dependent_item’);

用于Cascading dependence - an item can be both master and dependent.

2.APP_FIELD.SET_EXCLUSIVE_FIELD

用途Mutually exclusive items—they look like two items, but behave as one. Use

APP_FIELD.SET_EXCLUSIVE_FIELD to code.

--APP_FIELD.SET_EXCLUSIVE_FIELD(EVENT,’block.item1’,’block.item2’,’block.item3’);

Call item handler procedures in:

– WHEN-VALIDATE-ITEM for each exclusive item

– PRE-RECORD on the items’ block (Fire in Enter-Query Mode: No)

– WHEN-CREATE-RECORD on the items’ block

3.APP_FIELD.SET_INCLUSIVE_FIELD

用途Mutually Inclusive Items—one for all and all for one!

Use APP_FIELD.SET_INCLUSIVE_FIELD to code a set of items where, if any

of the items is not null, all items are required.

--APP_FIELD.SET_INCLUSIVE_FIELD(EVENT,’block.item1’,’block.item2’);

? Call item handler procedures in:

– WHEN-VALIDATE-ITEM for each inclusive item

– PRE-RECORD on the items’ block (Fire in Enter-Query Mode: No)

4.APP_FIELD.SET_REQUIRED_FIELD

用途:Conditionally Mandatory items—use APP_FIELD.SET_REQUIRED_FIELD to

require certain items only if a certain condition is met.

--APP_FIELD.SET_REQUIRED_FIELD(EVENT,(CONDITION),’block.item’);

通常在以下的trigger中调用Dependencies控制逻辑:PRE-RECORD,when-create-record,

when-validate-item,when-checkbox-changed, when-radio-changed,when-list-changed

和‘INIT’事件。PRE-RECORD和INIT是在操作数据前初始化这些逻辑,而其他是在item发生变化后验证这些逻辑,满足条件则进行后续的动作。

------------------------------------------------------------------------------

使用APP_ITEM_PROPERTY.SET_PROPERTY代替SET_ITEM_PROPERTY设置item属性

APP_ITEM_PROPERTY.SET_PROPERTY modifies the following properties:

? DISPLAYED

? ENABLED

? ENTERABLE

? ALTERABLE (item instance level)

? ALTERABLE_PLUS (item level)

? REQUIRED

注意:

在APP_ITEM_PROPERTY.SET_PROPERTY使用 item id 或者 block.item_name

语法:

item_id := Find_item(’block_name.item_name’);

app_item_property.set_property(item_id,property_name,setting);

等同于

app_item_property.set_property(’block_name.item_name’,property_name,setting);

14 , Tab Related Code

Tab-related Variables 与Tab-related相关的变量

? :SYSTEM.TAB_NEW_PAGE

– name of the tab page the user clicked on(取得用户点击后的tab 页)

? :SYSTEM.EVENT_CANVAS

– name of canvas that owns the newly-selected tab page(取得用户新点击的画布)

? :SYSTEM.TAB_PREVIOUS_PAGE

– name of the tab page that was topmost before the user

clicked on the new one(取得在用户点击新的页面前的tab页)

Dynamically Changing Tabs

? Dynamically hide tabs only at form startup.

– set_tab_page_property(...VISIBLE)

? Dynamically enabling/disabling tabs.

– set_tab_page_property(...ENABLED...)

Tab-related Trigger

? WHEN-TAB-PAGE-CHANGED

– fires only when user clicks on a tab

– cannot be fired programmatically

– can only exist at the form level

target_canvas_name VARCHAR2(30) := :system.tab_new_page;--取得当前用户点击的tab页

curr_canvas_name VARCHAR2(30) := get_item_property(:system.cursor_item,item_canvas);--返回当前画布的名称

current_tab VARCHAR2(30) := get_canvas_property('TAB_LINES_REGIONS',topmost_tab_page);

--返回在tab画布上的顶层的tab页的名字

set_canvas_property('TAB_LINES_REGIONS', topmost_tab_page, curr_canvas_name); --将当前的画布设为可交换页顶层的tab

15, Window 与Region Behavior 编程:

WINDOW的控制:(使用app_window 包来取得标准的窗口控制动作)

1.打开windows

--修改PER-FORM触发器中调用第一个form

--修改app_custo.open_window中调用windows的名字,打开窗口

(用键盘切换当前Block或用button打开窗体时,需使用APP_CUSTOM.OPEN_WINDOW函数,语法为APP_CUSTOM.OPEN_WINDOW(‘block_name’)

APP_CUSTOM.OPEN_WINDOW 中又会调用app_window.set_window_position。如果是Master-Detail Block需要建立coordination关系的,在APP_CUSTOM.OPEN_WINDOW('LINES')时,调用 APP_WINDOW.SET_COORDINATION)

--对于每一个window而言,

--用app_window.set_coordination 来设置必要的关系(

procedure APP_WINDOW.SET_COORDINATION(event varchar2,coordination varchar2,relation_name varchar2);

--其中event

The name of the trigger event (either WHEN-CHECKBOX-CHANGED,WHEN-WINDOW-CLOSED, or OPEN-WINDOW)

--coordination

IMMEDIATE or DEFERRED. Defaults to IMMEDIATE

--relation_name

Name of the relation, which is listed in the Oracle Forms Designer under the Block object in the

Relation object)

--设置窗体的位子使用app_window.set_window_position(位子包括(CASCADE, RIGHT, BELOW, OVERLAP or CENTER).)

--COORDINATION,重设

2.关闭windows

--与打开form相对,用APP_CUSTOM.CLOSE_WINDOW函数调用windows的名字关闭窗口

--对于每一个窗口,用app_window.set_coordination 来设置必要的关系

--当第一个窗口关闭时,使用APP_WINDOW.CLOSE_FIRST_WINDOW关闭form

--避免关闭查询中的windows

--将光标从一个关闭的窗口移到前一个数据库上

--用hide_window隐藏制定窗口,

3.设置window title

--用app_windows.set_title来设置context-dependent 信息

--在PRE-RECORD中调用title

-------------------------------------------------------------------------------------------------------------------

当用键盘切换当前Block或用button打开窗体时,需使用APP_CUSTOM.OPEN_WINDOW函数

可以使用下面的procedure

PROCEDURE LINES(EVENT VARCHAR2) IS

BEGIN

IF (EVENT IN ('WHEN-BUTTON-PRESSED', 'KEY-NXTBLK'))

THEN APP_CUSTOM.OPEN_WINDOW('LINES');

ELSE

FND_MESSAGE.DEBUG('Invalid event passed to orders.lines: '|| EVENT);

END IF;

END LINES;

修改APP_CUSTOM.OPEN_WINDOW函数,打开windows的规则:

1.设置windows位置;用app_window.set_window_position('你要打开的界面','打开模式--CASCADE, RIGHT, BELOW, OVERLAP or CENTER','前一个页面')

2 重置master-detail 关系(如有需要的话);如果是Master-Detail Block,则需要建立coordination关系,

APP_WINDOW.SET_COORDINATION(event varchar2,coordination varchar2,relation_name varchar2);如

APP_WINDOW.SET_COORDINATION('OPEN-WINDOW'--触发事件(包括‘WHEN–CHECKBOX–CHANGED,

WHEN–WINDOW–CLOSED, or OPEN–WINDOW)’),:control.orders_lines--需要调用coordination的数据块(IMMEDIATE or DEFERRED. Defaults to IMMEDIATE),'ORDERS_LINES'--主从关系的名字Name of the relation,);

3导航到window中的一个block。go_block('block')

4 必要时需要设置窗体属性 SET_WINDOW_PROPERTY('LINES',VISIBLE,PROPERTY_TRUE);

----------------------------------------------------

对于APP_WINDOW.SET_COORDINATION的进一步理解:(用于主从关系中)

This call sets the deferred coordination attribute of a relation to ON or

OFF based on the state of the coordination check box. The check box is

either ”DEFERRED” or ”IMMEDIATE.”For a closed window, the relation is always ”DEFERRED.”

When coordination is set to ”DEFERRED,” AutoQuery is turned on.

coordination check box选中与否决定其取值是‘IMMEDIATE’ 还是‘DEFERRED’。如果coordination check box选中的话,

即使焦点在Master window时,Detail window中数据会于Master window同步;如果coordination check box没有选中,

Detail window的内容不会于Master window同步,直到焦点落在Detail window时,系统才会执行查询更新数据。

这个过程自己试验一下会非常的清楚。

使用coordination check box 必须在其WHEN-CHECKBOX-CHANGED trigger中重置Master-Detail windows的同步关系。

------------------------------------------

设置上下文相关联的windows的标题:

动态设置相关联的窗体标题依靠APP_WINDOW.SET_TITLE函数,

注意在两类trigger中需要调用它。一类是Block-level的pre-record和on-insert trigger,

另一类是相关联字段的when-validate-item trigger

APP_WINDOW.SET_TITLE函数用法:

APP_WINDOW.SET_TITLE('ADJ_RECEIVE',ARAMETER.ORG_CODE);

其中ADJ_RECEIVE是window 的名字,用于设置window的title
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息