Friday 14 December 2012

Oracle Apex first page, Hello World Example




In this blog entry I am going to create a Hello World page in Apex.  The page will be a little more sophisticated in that a user will be able to enter their name and submit it.  The page will then say Hello to the user name.

To achieve this I'm going to complete the following steps:

  1. Create an application in Apex complete with a Page
  2. Create a region on the page
  3. Create a text entry field
  4. Create a submit button
  5. Create a display region to say Hello to the entered user name
This page will look like:




Step 1, Create a new application in Apex complete with a page


In Apex 4.2, from the Home Screen click

  • Application Builder
  • Create 
  • Check the Radio Group Database
  • Next
  • Next
  • Create Application
  • Create Application
The application is now created complete with a Page 1. 

Step 2 create a region to hold the page items.

 

Click on the home page

In tree view, right click on regions and then click

 





  • Create
  • Select the HTML radio group
  • Next
  • Select the HTML radio group
  • NEXT
  • Enter a title of Region 1 
  • Click Create Region.

Now the region is created the edit screen is displayed.

Step 3, Create a text entry field


  • Right Click on Region 1 and select Create Page Item
  • Select the radio group Text Field and click Next
  • Enter an item name of P1_ENTER_NAME then click Next
  • In the label enter the text Enter Name, then click
  • Next
  • Next
  • Create Item

     

    Step 4, Create a submit button


    • Right Click on Region 1
    • Click Create Region Button
    • Enter a name of P1_SUBMIT
    • Set the label value to Submit. 
    • Click Create Item



      Step 5, Create a display region to say Hello to the entered user name


      • Right click region 1 and select Create Page Item
      • Select Display Only, (not display image)
      • Next
      • Set item name to P1_RESULT
      • Next
      • Set label to Hello
      • Next
      • Next
      On this page we need to apply some process logic

      1. Set Source used to Always, replacing any existing value in Session State.
      2. Source Type to PL/SQL Expression
      3. In the Source value or expression enter :
           apex_util.get_session_state ('P1_ENTER_NAME')
            4. Click create Item
       
       These settings mean
      1. Always change the value of the field
      2. The source for the value of the filed will be derived from PL/SQL
      3. Set the value to the value of P1_ENTER_NAME as held in session state.

      Step 6, Run the page


      Click run on the page.  Enter a name and press the submit button.

      Summary of how the page works


      • A user enters their name into the text box (P1_ENTER_NAME).
      • When Submit is pressed the page is submitted, the values of all fields are placed in session state and the page is startes to re-render.
      • The display only field is set to the same value as P1_ENTER_NAME through the call to apex_util.get_session_state ('P1_ENTER_NAME').



      No comments:

      Post a Comment