Online Help for the ADF UIX User Input Sample Application
What does this sample show?
This sample application demonstrates how to create a simple ADF application which will use a request object and a java bean to pass
values between two ADF UIX pages. These two solutions, out of many, solve
the problem to pass a value from one page to another - the value passed using the JavaBean can be
used during the entire session and the value passed on the request object will be there only for that request. For this simple application we are using ADF UIX, Struts, and Java
Beans.
Why is this important?
This example shows how easy it is to build a simple application and pass values from and to ADF
UIX pages using the request object or java beans.
How was this sample application created?
This sample application was developed using ADF technologies including ADF UIX, which is the
view portion, ADF Model for our data bindings, JavaBeans as our business services, and Struts which handles the controller
portion.
The Struts page flow of this simple ADF UIX application
Below is a screenshot of the page flow for this ADF UIX application. This application contains
two UIX XML pages - hello.uix,
MyPage.uix - 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.
Create a new Application Workspace
- Create a new Application workspace (File -> New)

- Select the Application workspace node.
- Click OK. This will launch a dialog which will allow us to define
location, templates, and application package prefix.

- Change Application Name to - HelloApplication
- Change the Application Template to Web Application [default] and click OK. On completion you should have an application named
HelloApplication
and two projects named Model and ViewController.
Info: You can use the Manage Templates... button to change the names of your
projects and define the technology scope for each project.)

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.
This section is just going to cover how to generate a Java bean and make some
small changes to it needed for this sample.
- Right click on the Model project and select New. This will launch
the New Gallery dialog.
- In the New Gallery dialog please select the Java Class node and click OK.

- In the Create Java Class dialog enter a name for your class
- MyBean.

- Click OK. This will create a stub for your Java bean.
Adding GET and SET methods to the Java class
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.
- In the Code Editor please paste the following code after the MyBean
constructor:
public String getHelloString()
{
return helloString;
}
public void setHelloString(String newHelloString)
{
helloString = newHelloString;
}
- Declare the helloString variable. Paste
the following code above the MyBean constructor:
private String helloString;
- Your code should look like this:
package model;
public class MyBean
{
private String helloString;
public MyBean()
{
}
public String getHelloString()
{
return helloString;
}
public void setHelloString(String newHelloString)
{
helloString = "Hello " + newHelloString;
}
}
-
Save and
compile your work
Register the Java bean as a data control
Now that you have created a simple Java bean that can set and get a string value, 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.
- In the Application Navigator right click on the MyBean.java node
and select Create Data Control.

You will now be able to access the Java bean from the Data Control
Palette.
Creating a Struts page flow
The first step in our application is to create a Struts diagram to control our page flow for our two pages.
- In the ViewController project double click on the struts-config.xml
file. This will open an empty
Struts pageflow diagram.
- On your right hand there should be a Component palette available.
Note: If not then you can open the Component palette from the View menu.

- Click on the Data Page node and then on the empty Struts
page flow.
- Rename the node to
mainDP.
Note: This will be the input page.
- Repeat the step creating another Data Page and rename it to
helloDP.
Note: This will be the dispaly page.
- Click on the Forward node in the Component palette and drag
a link from mainDP to helloDP.
Your diagram should look like this:
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.
- Double click on the Data Page node - /
mainDP.
- By typing directly in the Page Name field you can define your own name for the new page and file type. For this application we are using UIX XML, so type in -
MyPage.uix- in the dropdown list.
- Click
OKto create the new page. This will open the UIX XML page in the visual editor.
Add a pageLayout component
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:
- Select the pageLayout component from the Component
Palette and drag it onto the center of the new empty page.
Your page should look like this:
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.
Add a text field and a submit button to the input page
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.
- Our Data Control has one node - helloString

Note: For each data control there is a set of components that you can use to
create your application.
- Select the helloString node under MyBeanDataControl and look
at the different options available in the dropdown list Drag and
Drop As:
- Select the component type: MessageTextInput
- Drag and drop the helloString node into the center of your page. Your page
should now contain one input text field that can be used to enter a string
value.

- Add a submitButton to your page from the Component Palette
. Make sure you have selected Forms Components in the
Component Palette.

- Your page should look like this:

Using the Property Inspector
- Click on the title of your new text field.
You should now see a dotted border around your text field and in the Structure
Window (in the lower left corner of the IDE) you should see that the
messageTextInput component is selected, and you should also see the available
properties for this component in the Property Inspector.

- In the Property Inspector change the Prompt property to - Type
text, and the Tip property to - Ex. Your name
- Change the text property of the submitButton component to -
Submit
- Make sure you save your project.
- In your Struts page flow double click on the /hello node in order to create your
display
page.
- Change the name - hello.uix - and click OK.
Add a display field to the page
We now have a page called hello.uix, and we would like to use
this page to display the value entered in the previous page - MyPage.uix. In order to achieve this we
use the same
data control as in the MyPage page - helloString.
- In the Data Control Palette select the helloString located under
the MyBeanDataControl node.
- Change the "Drag and Drop As:" type to - MessageStyledText

- Drag and drop the helloString node onto the page. Your page
should look like this:

- Save your work.
(Optional: You can change the prompt, and tip property to something more
descriptive)
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 -
hello.uix.
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.
Using the JavaBean to pass a String value
- On the
MyPage.uix page select
Submit.
- In the Property Inspector specify an event by entering a value for the event property -
success. The controller will catch this event and know that it should navigate according to the Data Page -
mainDP - edge with the name
success.
-
Save your work.
Run the application
Test your new application by running it:
- Open your Struts pageflow diagram
- Right click on the action you want to run - mainDP
- Select
Run /mainDP.
- Test you application by typing in your name in the text field and click
Submit.

- Resulting display page:

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.
Add a text field and a submit button to the input page
- Open the
MyPage.uixpage in the visual editor.
- Add a
MessageTextInput and a
submitButton to your page from the Component Palette. Make sure you have selected
Forms
Componentsin the Component Palette.
- Change the following properties of the MessageTextInput: the
name to -
salaryInput, the
prompt to -
Enter Salary, and remove the
Tip.
- Change the
text property of the submit button to -
Submit Salary.
Your page should look like this:
Creating an event to pass the string on the request
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.
- On the
MyPage.uix page select the
Submit Salary button.
- In the Property Inspector specify an event by entering a value for the
event property -
goSalary.
Creating an event handler
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.
- Right click on the handlers node in the Structure Window
- Select
Insert inside handlers.
- Select
Event.
- Give the event the same name as the event property for the
Submit Salary button -
goSalary.
- Click
OK to close the dialog.
- Right click on the new event and select
Insert inside event.
- Select UIX Servlet and in the list of available behaviors select a
set element.
- In the Property Inspector set the following properties:
Property =
mySalary
Target =
${requestScope}
Value =
${param.salaryInput}
- Right click on the
goSalary event and insert inside a
go element.
- In the
Create <go> dialog that appears set the
name property of the go behavior to the same name as the name of the link created in the Struts page flow to navigate from the MyPage.uix page to the Input Form page -
success.
- Click
OK.
-
Save your work.
Modifying the hello.uix page
We now have to modify the
hello.uix page to be able to display the value sent with the request.
Add a display field to the page
- From the Component palette, drag and drop a
MessageStyledText component onto the page. You will find the component under the
General Componentspage.
- Change the following properties on the new
MessageStyledTextcomponent:
Prompt =
Salary
Text =
${requestScope.mySalary}
- Your page should look like this:
- Save your work.
Run the application
Test your application by running the it:
- Open your Struts page flow diagram
- Right click on the action you want to run -
mainDP.
- Select
Run
- Test you application by typing in a salary in the new field and click the
Submit Salarybutton.
- Resulting display page: