开发者

IS there reflection in Oracle Forms 6 or later?

IS there reflection in Oracle Forms 6 or later?

Is it possible to enumarate labels or othe开发者_开发问答r elements?


Forms is an old and venerable programming language, and it doesn't support full-on reflection, Java style. However, it does have a complement of GET and SET functions which enable us to interrogate and manipulate a Form's metadata.

So we can step through the items of a block and get their labels using GET_ITEM_PROPERTY like this (example adapted from the documentation):

DECLARE 
  cur_itm   VARCHAR2(80); 
  cur_block VARCHAR2(80) := :System.Cursor_Block;
  cur_label VARCHAR2(120); 
BEGIN 
  cur_itm   := Get_Block_Property( cur_block, FIRST_ITEM ); 
  WHILE ( cur_itm IS NOT NULL ) LOOP 
    cur_itm := cur_block||’.’||cur_itm; 
    cur_label := Get_Item_Property( cur_itm, LABEL);
    -- do whatever you want with the label here 
    cur_itm := Get_Item_Property( cur_itm, NEXTITEM ); 
  END LOOP; 
END;

You could change the LABEL of the current item using SET_ITEM_PROPERTY.

Note: LABEL is a property which only applies to certain items (buttons, checkboxes, etc) so you might what to include a test for the item type and perhaps grab the PROMPT_TEXT instead, if that's appropriate.

There are loads of ways we can change the appearance and behaviour of a Form on the fly. The Form Builder Reference covers all the built-ins, so there's no point in recapitulating it here. Find out more.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜