Friday, 14 December 2012

Oracle Apex, Creating a second Page Example



This blog entry follows on from Apex First Page,Hello World.  It builds on the page built in that blog entry. In this entry instead of displaying Hello on the page where the user has entered thier name the greeting is instead displayed on a seperate page.

The steps involved are:
  1. Create a second page in the application
  2. Create a region on the page
  3. Set up a field to receive the inputted name and set up code to populate the field
  4. Remove the display field from page 1
  5. Create a process on page 1 to branch from page one to page 2 when the submit button is pressed.

 

Step 1, Create a second page in the application 

 

  • Click Create Page
  • Select the Blank Page Radio Group
  • Next
  • Next
  • Enter name of Page 2
  • Next
  • Finish
  • Edit Page


Step 2, Create a region on the page

 

  • Right click on Regions and select  Create
  • Select the HTML radio group
  • Next
  • HTML
  • Next
  • Enter the title as Results Region
  • Create Region 

Step 3, Set up a field to receive the inputted 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


Step 4, Remove the original display field on page 1

  • Go back to page 1
  • Right click on p1_result
  • Edit
  • Delete

Step 5, Create a process to branch from page one to page 2 when the submit button is pressed

 

 


  • Under the Page Processing column
  • Expand Processing Node
  • Right Click on Branches
  • Click Create
  • Set the name to BRANCH_TO_PAGE_2
  • Next
  • Click the Popup next to Page and select Page2 (the page we’re branching to)
  • Create Branch

Step 6


Run Page 1

Summary of how the page works

  • A user enters their name into the text box (P1_ENTER_NAME) on page 1.
  • When the submit button on page 1 is pressed the branches (ie redirects ) to page 2
  • The display only field (P2_DISPLAY)  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