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

Creating LOV in ADF Application



This week i will continue to enhance my previous post (Moving to Jdeveloper11g Your First ADF Form) and today i will cover how to create LOVs in Oracle ADF application.

Pre-requisites:
- HR Schema in Oracle database.
- Download this basic completed application and change the connection settings according to your environment.


Objective:
On this post we will create LOVs for Job, Department Id in Simple Employee based form.
Note: (Manager LOV is little tricky i will cover in next post)


Steps to follow:
For good naming convention we will rename the adf.demo.model.view package to queries
- Right click on adf.demo.model.view in Model project and choose Re-factor > Rename and rename it to adf.demo.mode.queries


Adding Departments and Jobs Entities:
Note: If you already have entities in your project then you can skip to next step

- Add Departments Entity by Right clicking on adf.demo.model.entities package in Model project and choose New Entity Object
Enter Name as "Departments" and Choose Schema object as "Departments" by pressing Browse button you can select from the list of objects as well.


- Choose All columns in attributes page and click Finish.
- Repeat the same step for Jobs entity.

Adding View Objects for Departments and Jobs LOVs :

- Right click on adf.demo.model.queries package and Choose New View Object.

- Enter name as "DepartmentsLOV" and other options as shown in the slide.
- Select the Departments Entity and Move to selected area uncheck the option Updatable.
- Select Department Name and Id Attributes to Selected area.

- Choose Departments Name in Order by section by pressing EDIT button you can select from List.
- Click Finish.
- Repeat same steps for Jobs Choose JobId and JobTitle as Attributes and JobTitle as Order by.


Creating LOVs:
 
- Double click EmployeeVO in adf.demo.model.queries section.
- Select DepartmentId attribute in the attribute page and Click "+" green button at the bottom under List of Values section.
- Click the green + button with List Data Source.
- Select DepartmentsLOV in Available Objects change the Name at the bottom to DepartmentsLOVAcesssor and Press > button to Create Accessor for LOV as shown in the slide click OK.

- Choose DepartmentId in List Attribute Return Values will populate automatically. Your Screen should similar to this.



- Go to UI Hints tab Leave the List type as Choice List (There are many type of LOVs available)
- Move Department Name from Available to Selected Area.
- Choose "Labeled Item(First of List)"  at very bottom include "No Selection.."  and set the Description as "


- Click OK
- Repeat Same Steps for JobId attribute.

Your EmployeeVO page should looks like this


Linking LOVs to JSF Page:
- Open employee.jspx page in View Controller Project
- Delete JobsId and DepartmentId attribute by selection them in Structure Window and Right click choose Delete.
- Refresh the DataControl page
- Expand the DataControl > EmployeeVO select DepartmentsId attribute and Drag and Drop it to FormLayout.
- Menu will appear select Single Selection > ADF One Choice List as shown in the slide
- Repeat the same step for JobId.
Your JSF Page should looks like this


- Right click and Choose Run

Your Page should looks like this on Runtime

Conclusion:
With Oracle ADF application development becoming fast easy and see how easy is to create LOVs in your ADF application as like in Oracle Forms.

How to Create ADF LOV with Filter or View Criteria



This week i will continue my last post about Creating LOV in ADF application and today i will create LOV on ManagerId Column which is different cause of 2 reasons

We would add following 2 business rules to the LOV

1) Manager cannot manage themselves i.e ( EmployeeId <> CurrentEmployeeId)
AND
2) Employee can be manage by other employees in the same department or in Executive Department which ID is 90.
(DepartmentId = 90 OR (DepartmentId = CurrentDepartmentId)

For this we have to create a View Criteria on our ViewObject (VO) that will filter the list based on few Bind Variables.

Steps:
Creating View Object (VO):


- Create new VO in adf.demo.model.queries package called EmpManagerLOV based on Employee entity with updateable is deselected.

- On Attribute page choose DepartmentId, EmployeeId, FirstName and LastName on Query page choose Order by as FirstName and LastName.


Adding Bind Variables to VO:

- Double click the VO EmpManagerLOV go to Query tab page in the Bind Variables section click the green + sign and Create 2 bind variables.
- Name CurrentEmployeeId Type Number Required No
- Name CurrentDepartmentId Type Number Required No





Creating View Criteria

- In View Criteria click Add Button (Green + sign)

- Enter the Criteria Name as "EmpManagerLOVCriteria" click the Add Item button along with Group and choose the settings as shown in the slide to complete the 1st Rule required (EmployeeId <> CurrentEmployeeId)



- To add 2nd Rule i.e (Department = 90 and DepartmentId = CurrentDepartmentId) Follow these steps
select the top-level node (EmpManagerLOVCriteria) and click Add Group button and select new group node and set the Conjunction as “AND”.

- Click Add Item and set the expression as “DepartmentId = 90” with a Validation of
“Required.” Operand set as “Literal” in this case.

- Select the “AND Group” node and click Add Item again. set all fields as shown in the slide.



- Click OK

- Your screen would look like as in the slide

Creating LOV:

- Double click the EmployeeVO in attributes page click on the ManagerId and In List of Values Section click Add + button

- Add a List Data Source item, and select “EmpManagerLOV.”
Change the Name to “EmpManagerLOVAccessor” and move it to the View Accessors
area.


- Select the EmpManagerLOVAccessor and press Edit on the Top

- Move the EmpManagerLOVCriteria to the Selected area.

- In the Bind Variables section double click the value section and enter both values for both Variables as

For CurrentDepartmentId  enter DepartmentId
For CurrentEmployeeId enter EmployeeId


Click OK and Rest you can follow same steps as in my last post or just follow slides.
- Set LOV Configuration as in the slide
- Go to UI Hints and set following settings
- Go to Employee.jspx page delete ManagerId field Drag and Drop ManagerId from Data Control and choose List of Values > ADF LOV Choice List


- Your Design Page would be like this

- Right click and Choose Run on Employee.jspx page  you will see something similar to this click Manager ID LOV item

- Press Search link appearing in the LOV ADF will open a pop to display all values. You can filter your values and press OK

Creating Master-detail form in Oracle ADF



Today i will show how to create simple master detail form in ADF which would help people coming from 4GL (Forms Developer) technology to ADF.

After completion of all steps the final result would be like this


Pre-requisites:
- HR Schema in Oracle database with tables Departments and Employees.
Oracle Jdeveloper 11g 11.1.1.2.0 you can download from OTN.

Creating EO, VO, VL and AM (Entity Object, View Object, ViewLink and Application Module)

- Create new Application named masterDetailApp based on ADF Fusion template.
- Create Connection named hr.
- Create EOs based on ADFBC from tables Departments, Employees (demo.model.entities) package
- Create VOs names DepmentsView and EmployeeView based on those EOs (demo.model.queries)

Create ViewLink (Viewlink is a Association or join condition between 2 View Objects) between VOs named DeptEmployeeVL.

- Right click on the package demo.model.queries and choose New View Link named it DeptEmployeeVL as shown in the Slide


- Expand DepartmentView in the source section and select DepartmentId do the same for EmployeeView in the destination and press Add button then NEXT


- Leave the default Accessors Names as shown in the slide and Press Finish



Setting Data Model:
 - Double click Application Module HrModule (demo.model.services) go to Data Model tab and choose the names of the Accessors as shown in the slide.
- Click the DepartmentsView first on the Available View Objects pan Change the View Instance name at the bottom as "Departments" and Move it to Right side in the DataModel pan.
- Select Departments at Datamodel pan then Select EmployeesView via DeptEmployeesVL  under the DepartmentsView Node in the left pan
Change the View Name Instance to DeptEmployees and View Link Instance to DeptEmployeeVL.
Move it to data model
Your Data Model page should looks like this


- Save all

- Right click the HrModule under demo.model.services  package and Choose Run.

You will see the Business component Browser which is useful to check the business logic and relation in your Application without creating any User Interface double click the DeptEmployeeVL on the Left pane Navigate through records to test your join condition is working properly as shown in the slide.


- Save all at this point you have successfully created the ViewLink between 2 VOs

Data Control View
After completing above steps your Data control page should looks like this

Note that DeptEmployees Node is Under the Departments  Node means that DeptEmployees is the Child of Departments. 

Creating JSF page for Master Detail form:
- Create a View activity called DeptEmployees.jspx in a un-bounded Taskflow adf-config in View Controller project.
- Double click View activity Choose Blank means No Templete.
- Drop PanelSplitter from the Components Palette
- Drop PanelBox then drop Panel Accordion in the First facet of the Panel-splitter set the Text Departments
- Drop another Panel-splitter in the second facet and set the Orientation property to vertical from property inspector.
- Drop Panel Accordion in the first facets of the Last Panel-splitter set Text as Employees.
- Drop Panel Accordion in second facet of the last panel-splitter set Text as Edit employee.

Your Structure layout should looks like this 


Creating Data-bound Components in Page:
- Expand the Data Controls Drag the Departments to the Departments Panelbox and choose Form  > ADF Read-only Form. Choose the fields as shown in the slide


- Select DeptEmployees Node under Departments node in the Data Controls drag to the Employees Section on the page  Choose Table > ADF read-only table select options as shown in the slide in the edit column page




- Repeat same DeptEmployees node from data control and drag to Edit Employee section in the page this time select Form > ADF Form



- Set the StyleClass Property to AFStrechWidth as shown in the slide of af:table and PanelAccordion to strech the table at Runtime of the Employees section



- Save all your work and Right click on the page Choose Run You should able to see the page similar to this.



Navigate through Departments on the left pan you should able to see the Employees related to the current department Click on any employee record on the Table at the top it should display at the bottom as well. 

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_...