An Oracle JDeveloper How To Document
Written by Jonas Jacobi
This HowTo demonstrates how to create a simple ADF UIX User Input application with Oracle JDeveloper 10g. This HowTo will show two solutions, of out of many, which solve the problem passing a value from one page to another - one solution is using a JavaBean to store a value that then can be used during the entire session, and one solution is to pass a value on the request object that will be there only for that request. For more HowTos about working with Oracle JDeveloper 10g, please, refer to the JDeveloper HowTo documents on Oracle Technology Network (OTN). For this simple application we are using ADF UIX, Struts, and Java Beans.
This session covers the following tasks:
Below is a screenshot of the page flow for this ADF UIX application. This application contains two UIX XML pages - hello.uix, MyPage.uix, one JavaBean, and two Struts actions that will be used for navigation and submitting our data.
Before we go on the path to create our views and page flow we need some where to store our work in progress.
This is the first solution to pass a string value from one page to another, and in this case the Java bean (and value) will exist during the entire session, whereas the second solution, which is covered later in this HowTo, the value only exist during the request.
This section is just going to cover how to generate a Java bean and make some small changes to it needed for this HowTo.
There are two ways to add a set method and a get method to your class. One is the manual way and the other is to use the Class Editor. In this example we will use the manual way since we are not going to add much code.
We have now created a simple Java bean that can set and get a string value. Now we need to register this bean as a Data Control for our application. This will allow us to reuse the bean and access it from the Data Control palette.
You will now be able to access the Java bean from the Data Control Palette.
The first step in our application is to create a Struts page flow
When creating a new page from the Struts diagram the default the name of the page will be the same as the page forward action, and depending on what type of technology you have set in your project there will be a list of available file types - JSP, HTML, and UIX. Alternatively you can use the Browse button to open an already existing page.
The PageLayout component could be compared to a page template that has a set of empty slots or place holders, such as the corporateBranding slot or the pageButton slot. In ADF UIX these slots go under a common name - Named children. A developer can use these slots - Named Children - to add other components such as images, tables, buttons etc... to the page. If not used they will not be rendered during runtime.
To add a pageLayout component to the page:
Note: If you do not want to see the place holders during design time you can switch them off by clicking on the button in the lower right corner of the visual editor.
In the DataControl Palette you should see a list of all available data controls in your Application Workspace. In our case we can see one data control mapping to our Java bean - MyBean - in our Model project. To be useful the input page needs a text field and a submit button to collect input from the user.
Note: If the Data Control Palette is not visible you can open the palette from the JDeveloper View menu.
To use this page to display the value entered in the previous page - MyPage.uix, we use the same data control as in the MyPage page - helloString.
This chapter will focus on wiring up our two pages, so that the end user can navigate from the Input page -
MyPage.uix - to the Display page -
Note: This illustrates two ways of navigating between pages - one shortcut which will be demonstrated in the first sample with the java bean, and one where we need to explicitly specify where to go in the UIX page.
Test your application by running it:
This time we are going to use the request object to pass a string value instead of using a java bean. Reuse some of the pieces you've already created, and add two new fields and a button to our application.
In order for us to pass the value of our salary field, and navigate to the display page, we need to raise an event, catch the event, set a property on the request and specify where to go when the event occur.
Now we need to create an event handler. At the bottom of the tree in the Structure Window there is node called
handlers. Under this node you will find all event handlers used by this page.
Note: We will be using EL expressions to specify a property - mySalary - on the request scope with a value from the MessageTextInput - salaryInput - field.
We now have to modify the hello.uix page to be able to display the value sent with the request.
Test your application by running the it: