Wednesday, March 21, 2012

Search Form Results to Another Page. ADF BC 11g


In this example we are going to show how to implement a search Form and how to show  the results in another page.

Download Sample Application.

The scenario is fairly simple. We want to have our search form on one page and our results on another page.

Additionally, we want to navigate immediately  to the second page.

This means that our Find button, will take us in the results page.

We have two cases:

1) Having both pages in the same task flow

2) Having the pages in different task flows (no isolated Data Control.)

For this example we are going to use the HR schema and JDeveloper We are going to use the Employees Table in this example.


Generating the Business Components is rather easy.

Just use the wizard:



 Application Module

 Application Module structure:

By now, we have a fully functional Model.

Next we are going to create the main page.
The main page will contain two Buttons:

  • SearchForm and Results to a different page in the same taskFlow
  • SearchForm and Results to a different page in different taskFlow

Here is the main page:

Next we are going to create the search Form task flow:

We are going to create a task flow called search-task-flow-definition. The search-task-flow-definition will contain one page, the search page. inside that page, we drag and drop the EmployeesView1 as a SearchForm, as shown below:

The search task flow diagram:

This is the implementation where the search and results take place in one task flow.

In the above picture, you will notice that the whole operation takes place in the same task flow.
The entry point is the search form page. Then it has the navigation, execute which will go to the execute method call that will, of course, execute the query with the appropriate parameters constructed by the search form. There are also general navigations that help the application work more smooth like search and change outcomes.  Nevermind those navigations.
The important thing here is to see the change that we did in the code.
Normally, after we dropped the iterator as a search Form, the Execute Button  has the following
ActionListener: #{bindings.Execute.execute}
In order to have the search results in another page by pressing the Execute button, we removed the actionListener and placed value to the Action property. So now the Execute button looks like the following:

So, the Execute button now, navigates to the method call, the method call is being executed and when finished, it navigates to the results page.
The results page is a simple page with a read only table. No operations are taking place in the results place.

Why did we do it like that? 
I know there are other solutions as well. But this one clears the picture better, at least to my understanding.
It has the steps more clear and more understandable. I think that with this way, many readers will  understand the status of the data and how it is kept from page to page in the same task flow.

The second case. The case where the results belong to another task flow.

Basically the principal here is the same. The only difference here is that with different task flows, we have the ability to choose, among other choices, between sharing  data controls with the calling task flow or not.  In this post we are going to keep things simple. We will accept the default values of the task flows and the data control will be shared. 
For that reason we are going to create a second task flow as shown in the screen below:

This task flow does the following:
The entry point is the Execute method call here.
Executes the iterator ( sounds funny... ) and then navigates to the results page.

So this means that this task flow will execute with any parameters values that are set in a search form.

uhh? What search form?? I do not see any search form here...


The search form is now separated to another flow..

In this example, we  will not create another task flow for the search form. We are going to have it in the unbounded task flow of this application as shown below:

As you will see, the main page is decided to be the entry point. It has two navigations, depending on the preference of the implementation to test. The first navigation (searchInOneTaskFlow) takes the user to the one task flow that has all the implementation in it.
The second navigation(resultsInDifferentTaskFlow) takes the user to the search page which is inside the unbounded task flow, where the main page is, and from that page the Execute button calls the same outcome but the navigation now takes the user to another task flow.

And that is it!

Download Sample Application.


No comments:

Post a Comment


Related Posts Plugin for WordPress, Blogger...