Running your first ADF Faces application
In this recipe, we will run our application in multiple scenarios by trying the worst scenario first and enhancing it till we reach the best scenario.
How to do it…
To run your first ADF Faces application, perform the following steps:
- Locate your task flow
retrieve-employees-information
and right-click on it. - Click on Run or select it and click on Run (the green arrow icon) on the toolbar, and the page will start appearing.
If you did everything correctly, you should see a form that you can navigate through with Next, Previous, First, and Last.
However, if you check the URL, it's quite ugly. It's not quite what you have in mind, so how can it be enhanced?
The second scenario is where you run the page directly. So let's try that and see if there are any changes.
- Right-click on the
employees.jsf
page and run it. You will probably get a warning message from JDeveloper telling you that running the page itself is not recommended, which is true, but ignore it for the moment and click on Yes; let's examine the end result.The URL is much better now; it doesn't show all the
adf.task-flow
parameters in the URL that expose a bit of sensitive information about our task flow.But still, the warning from JDeveloper means that this way is also not recommended, so what is the best way to run your application?
Well, if you remember, we said that the
adfc-config
task flow and usually any unbounded task flows are generally responsible for the application's navigation model, so why don't we use it? In order to do so, all we have to do is expose theemployees.jsf
page as a View activity in that task flow. - Open the
adfc-config
task flow. - Drag-and-drop the
employees.jsf
page from the Application Pane into the body of the task flow to have it look like the following screenshot: - As you can see, the activity's name is
employees
without the.jsf
part, and this is what is going to be shown in the URL.By doing this, we added the
employees.jsf
page as a View activity inside theadfc-config
task flow, which as you know can act as an entry point since unbounded task flow has unlimited entry points. - Right-click on
adfc-config
and run it; you will now see an even more enhanced version of the URL. You will see something like the following:http://127.0.0.1:7101/ViewController/faces/employees
This is good, but
ViewController
isn't really the name of our application. So, in order to make the name reflect your application, let's rename it to what JDeveloper thinks is the name of our application. - Right-click on the
ViewController
project and click on Project Properties… at the end of the list; select Java EE Application. - Change Java EE Web Application Name and Java EE Web Context Root to something like
helloadf
and then run again; now, you can see your application with a nicely formatted URL like the following:http://127.0.0.1:7101/helloadf/faces/employees
How it works…
In this recipe, we tried three different methods to run our ADF application; however, it is preferable to always use the third method; adfc-config
is the heart of your ADF application and contains all of the project's navigation information. From the task flow, you can notice that there are no green circles behind the page, which means that if you have any other activity, then the new activity can also be called directly and it doesn't have to follow any order.
If you run your application using any one of the scenarios and this is the first time you run an application in JDeveloper's lifetime, it'll create the weblogic domain first with no managed servers and only one admin server. It'll be created under the JDEV_USER_HOME
environment variable that we created. After the domain is created successfully, the Admin Server starts, and after it does, JDeveloper starts packaging the application into a WAR (Web Archive) file. You can see this deployment profile by right-clicking and navigating to ViewController | Properties | Deployment; you will find an entry that represents the WAR packaging of this project. This project is also dependent on the Model
project, which means that packaging will include all the stuff created in the Model
Project. After the WAR file is created successfully, JDeveloper starts deploying the WAR file into the Admin Server. If the operation is successful, it will start to access the URL of the application inside the embedded Weblogic Server to show the target.
When you view the page, you can see that each input that has bindings represents a data field from the Employees
table. When you start clicking on the buttons, you can see that the row of focus is changing to the next, previous, first, or last row, and you can validate this data against the database.