08 May, 2012

Oracle Forms : Get First Navigation Item in Tab Page

One member in araboug forum asked a question about how to get first navigation item in tab page when click on the tab page.
I answered him with below dynamic function to get first navigation item at tab page and then use GO_ITEM built in procedure to navigate to item.

I posted this function in this blog to be as reference.



   
 FUNCTION GET_FIRST_ITEM_IN_TAP_PAGE (NEW_LC$TAP_NAME VARCHAR2)  
   RETURN VARCHAR2  
 IS  
   LC$BLK    VARCHAR2 (30);  
   LC$ITEM    VARCHAR2 (30);  
   LC$TAP_NAME  VARCHAR2 (30);  
 BEGIN  
   LC$BLK := GET_FORM_PROPERTY (:SYSTEM.CURRENT_FORM, FIRST_BLOCK);  
   
   <<BLK_LOOP>>  
   LOOP  
    LC$ITEM := LC$BLK || '.' || GET_BLOCK_PROPERTY (LC$BLK, FIRST_ITEM);  
   
    <<ITEM_LOOP>>  
    LOOP  
      LC$TAP_NAME := GET_ITEM_PROPERTY (LC$ITEM, ITEM_TAB_PAGE);  
   
      IF LC$TAP_NAME = NEW_LC$TAP_NAME  
      THEN  
       RETURN LC$ITEM;  
      END IF;  
   
      LC$ITEM := GET_ITEM_PROPERTY (LC$ITEM, NEXTITEM);  
      EXIT ITEM_LOOP WHEN LC$ITEM IS NULL;  
    END LOOP;  
   
    LC$BLK := GET_BLOCK_PROPERTY (LC$BLK, NEXTBLOCK);  
    EXIT BLK_LOOP WHEN LC$BLK IS NULL;  
   END LOOP;  
   
   RETURN NULL;  
 END;  



To use this function in my form I should write below code in WHEN-TAB-PAGE-CHANGED trigger at form level.
 BEGIN  
   GO_ITEM (get_first_item_in_tap_page (:SYSTEM.tab_new_page));  
 END;  

I created a demo to use this function on SCOTT schema.
You can download it from here.

Thanks
Mahmoud A. El-Sayed

2 comments:

  1. Always professional developers look for dynamic code which can be used everywhere in code and different applications.
    This post is dynamic code, everyone can use it as it is in his application.

    ReplyDelete
  2. The drawback of this post is missing orders of items in block at design time.

    ReplyDelete

ADF : Scope Variables

Oracle ADF uses many variables and each variable has a scope. There are five scopes in ADF (Application, Request, Session, View and PageFl...