Friday, March 10, 2017

Creating Simple Search form in Oracle ADF


Creating a search form in Oracle ADF is a matter of just few minutes just drag and drop the View Criteria and you are ready. Let me show you how easy it is. This post would be helpful for ADF newbies and people are coming from Oracle Forms background.

I assumed you have already setup the basic application with Emp EO, VO and Application module
from SCOTT schema in Oracle database. (if not check this post)

In this example:
- We will develop a simple search form which allows user to search employees records by entering Employee No OR by Partial Employee Name e.g Name Contains A .....'%A%'


Step Summary:
1) Define Bind Variables
2) Create View Criteria
3) Create Search Form by dragging and dropping Named View Criteria from Data Control to the Page
4) Refine the Layout

Step 1: Define Bind variables:

- Double click EMPVO in Model project go to query page.
- Expand the Bind variable accordion and click the Green button.


- Define 2 bind variable name and types as following make sure required check box is un-checked
  - EmployeeNo type as Number
  - EmployeeName type as String


Step 2: Create Named View Criteria:

- View Criteria is actually conditions on VOs which you usually define declaratively.
- Expand the View Criteria section in EMPVO page and and click the Green plus sign.

- Give a proper name to your View Criteria
- Click the ( ) Group press Add item and select values as shown in the slide make sure you have selected the bind variables EmployeeNo

- Select the ( )Group again  and Click "Add item" to add another condition and do as shown in the slide.

- Click OK and Save your Application.

Step 3 Create Search Form:

- Create a view activity on adfc-config page flow named as searchEmployees
- Create a simple stretched layout page with applied theme.
- Expand the Data Control panel and Drag and drop the Named View Criteria to the page and choose
Query > ADF Query Panel with Table as shown in the slide

- Your page would look like this

You are done with the search form at this stage right click and test the page

Refine Layout (Optional):

- At search form the labels of the bind variable in the search panel coming Empno and Ename which is not very informative to change the label we will changes the UI Hints in your entity which is EMP double click the EMPEO in the model project.
- Go to attributes page select the Empno field and set the Label under UI Hints as "Employee No" and set the display field as 5.
- Do the same for Ename as Employee name as width as 20

- To stretch the result table on runtime we will add a PanelCollection around our Table component.
- Goto the ViewController project right click the af:table component and Choose "Surround with" and select "PanelCollection" and click OK

- We just added a PanelCollection so we have to change the ResultComponentId reference in the querypanel.
- Select the querypanel component in the Structure window and set the property using the Edit and choose your af:table component

- Set the Headings of the PanelHeader as "Search Employee"

- Run the form enter Employee Number 7788 and press Search Result would be like this

- Enter 'A' in the Employee name fields and Press Search you will get similar results

No comments:

Post a Comment

Oracle Fusion - Cost Lines and Expenditure Item link in Projects

SELECT   ccd.transaction_id,ex.expenditure_item_id,cacat.serial_number FROM fusion.CST_INV_TRANSACTIONS cit,   fusion.cst_cost_distribution_...