Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Location
    Kuwait
    Posts
    38

    Smile Unanswered: Custom toolbar for developer 6i-Few tips

    Oracle Developer 6i (Forms)

    If there is another programmer who wonders how to design his/her own custom toolbar to use with Client Server applications, here are few tips:

    Always create an independent block for your toolbar items

    For example: If you are planning to provide “add record”, “delete record”, “view records” etc buttons along with your application, create a block “Toolbar” or “Mytoolbar” and add as many items you wish to provide the end user along with your application.

    Mark all items and from the property pallet, change the “Mouse navigate” property to “No” (If you fail to change this attribute your toolbar MAY not behave as you expect it to)

    “When Mouse Navigate is No, Form Builder does not perform navigation to the item when the end user activates it with the mouse. For example, a mouse click in a button or check box is not treated as a navigational event. Form Builder fires any triggers defined for the button or check box (such as When-Button-Pressed), but the input focus remains in the current item.
    When Mouse Navigate is Yes, Form Builder navigates to the item, firing any appropriate navigation and validation triggers on the way.” Oracle Forms 6i help.

    There are two methods you can call DO_KEY built-in when a toolbar button is clicked. First method is by writing WHEN-BUTTON-PRESSED trigger for independent items.

    Second method is by writing a program unit and later attaching it with the toolbar block through a WHEN-BUTTON-PRESSED trigger. This method would invoke the WHEN-BUTTON-PRESSED trigger block wise. Example coding is provided by the end of this article.

    Let us see how the first method works:
    Say you have three items with your toolbar block.
    1. ENTER_QUERY
    2. EXECUTE_QUERY
    3. CANCEL_QUERY
    Now you have to write WHEN-BUTTON-PRESSED trigger for each item.
    For the item “ENTER_QUERY” you have to call DO_KEY built-in as follows
    Code:
    DO_KEY(‘ENTER_QUERY’);
    For the item “EXECUTE_QUERY” you have to call DO_KEY built-in as follows
    Code:
    DO_KEY(‘EXECUTE_QUERY’);
    For the item “CANCEL_QUERY” you have to call DO_KEY built-in as follows
    Code:
    DO_KEY(‘EXIT_FORM’);
    Now let us see how the second method works:

    Create a new program unit (procedure) “BUTTON_PROC”. Cut and paste the following sample code inside the program unit.
    Code:
    -- This is a generic button procedure. It reads the NAME of the button and 
    -- performs a DO_KEY(item_name).
    -- Regarding QUERY-operation:
    -- if there are buttons called EXECUTE_QUERY and CANCEL_QUERY, this function shows
    -- them, when the ENTER_QUERY button is pressed and hides them, when EXECUTE_- or 
    -- CANCEL_QUERY ispressed. No error should be returned, if these buttons do not exist.
    -- To make naming of the buttons easier, EXIT, QUIT and EXIT_FORM all perform exit_form,
    -- even if the form is in ENTER-QUERY mode !!!!!!!
    -- A CANCEL_QUERY button-name cancels a currently "open" query.
    
    PROCEDURE button_proc IS
      action varchar(80);
    
      -- hide a button (for ENTER_-, EXECUTE_- or CANCEL_QUERY)
      PROCEDURE show_off(item_name VARCHAR2) IS
      BEGIN
        IF NOT Id_Null(Find_Item(item_name)) THEN
          Set_Item_Property(item_name, ENABLED,PROPERTY_FALSE);
        END IF;
      END;
    
      -- try to show a button (for the two query-states. If there is no button to show,
      -- return FALSE to the calling procedure.
      FUNCTION show_on(item_name VARCHAR2) RETURN BOOLEAN IS
      BEGIN
        IF NOT Id_Null(Find_Item(item_name)) THEN
    	    Set_Item_Property(item_name,DISPLAYED,PROPERTY_TRUE);
          Set_Item_Property(item_name,ENABLED,PROPERTY_TRUE);
          RETURN TRUE;
        ELSE
          RETURN FALSE;
        END IF;
      RETURN NULL; END;
    
    BEGIN    
      action := Get_Item_Property(NAME_IN('SYSTEM.TRIGGER_ITEM'),ITEM_NAME);
    
      IF action = 'ENTER_QUERY' THEN
        -- only hide the ENTER_QUERY button, if there are EXECUTE_QUERY and (!!) CANCEL_QUERY
        -- buttons. Otherwise an existing EXECUTE_QUERY button will be shown.
        IF show_on('EXECUTE_QUERY') AND show_on('CANCEL_QUERY') THEN
          show_off('ENTER_QUERY');
        END IF;
      END IF;
      IF action IN ('EXIT_FORM', 'EXIT','QUIT') THEN
        action := 'EXIT_FORM';
        IF NAME_IN('SYSTEM.MODE')='ENTER-QUERY' THEN
          Do_Key('EXIT_FORM');
        END IF;
      END IF;
      IF action = 'CANCEL_QUERY' THEN 
        action := 'EXIT_FORM';
      END IF;
     
      Do_Key(action);
     
     IF NAME_IN('SYSTEM.MODE') != 'ENTER-QUERY' THEN
        IF show_on('ENTER_QUERY') THEN
          show_off('EXECUTE_QUERY');
          show_off('CANCEL_QUERY');
        END IF;
      END IF;
      
      
    END;
    --Code End—
    Once the procedure created, all you have to do is to add a WHEN-BUTTON-PRESSED trigger for the block “Toolbar”.
    Just add the following inside your WHEN-BUTTON-PRESSED trigger for the block “Toolbar”

    BUTTON_PROC;

    Now whenever a user clicks one of the three buttons, the system invokes corresponding DO_KEY event.

    Please do read about DO_KEY built-in to understand the advantage and limitations prior you decide to completely depend up on this powerful built-in.

    Write me incase more clarifications required. My email id is rthampi.it@kazema.com
    If it is a door, It will open.

  2. #2
    Join Date
    Dec 2008
    Posts
    3
    hi
    i want to implement the Enter, Execute_Query functionality in my form
    but when i enter the search criteria in my text item its giving me error
    "FRM-40737: Illegal restricted procedure EXECUTE_QUERY in POST-TEXT-ITEM trigger."
    kindly help me ASAP
    thanking you in advance

  3. #3
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    It is self-explaining: EXECUTE-QUERY is a restricted procedure and can not be used in the POST-TEXT-ITEM trigger.

    By the way, what exactly are you trying to "implement"? Are you, perhaps, reinventing the wheel? ENTER / EXECUTE-QUERY is Forms built-in functionality from its ... huh, at least 3.0 version (can't tell for sure for earlier ones). So, why and how would you want to additionally "implement" it?

  4. #4
    Join Date
    Dec 2008
    Posts
    3
    Thanks Once again
    As you have mentioned. I was calling it from an all wrong trigger.
    Now its working fine as i am calling it from When_button_pressed trigger.
    No problem with the version or so

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •