adf learning 4 - create employee page

11
In this example we will create a page which will allow user to create a new employee 1) Create a new page Entity object with name EmployeeEO based on the employee table. 2) Open the EmployeeEO entity class. And insert the following code snippet protected void create(AttributeList attributeList) { super.create(attributeList); SequenceImpl s = new SequenceImpl("EMPLOYEES_SEQ", getDBTransaction()); Number sVal = s.getSequenceNumber(); setEmployeeId(sVal); } Above method will fetch the value from the EMPLOYEES_SEQ sequence and assign it to the employee id attribute.

Upload: vikram-kohli

Post on 13-Nov-2014

4.642 views

Category:

Documents


1 download

DESCRIPTION

In this example we will create a page which will allow user to create a new employee

TRANSCRIPT

Page 1: ADF Learning 4 - Create Employee page

In this example we will create a page which will allow user to create a new employee

1) Create a new page Entity object with name EmployeeEO based on the employee table.

2) Open the EmployeeEO entity class. And insert the following code snippet protected void create(AttributeList attributeList) { super.create(attributeList); SequenceImpl s = new SequenceImpl("EMPLOYEES_SEQ", getDBTransaction()); Number sVal = s.getSequenceNumber(); setEmployeeId(sVal);

}

Above method will fetch the value from the EMPLOYEES_SEQ sequence and assign it to the employee id attribute.

3) User will select an existing department for the newly created employee. For these create a new view object with name DeptVO with following query

SELECT department_id,department_name FROM departments

4) User may also select the manager for the newly created employee. For these create a new view object with name ManagerVO with following query SELECT employee_id, first_name || ' ' ||last_name employee_name FROM employees.

Page 2: ADF Learning 4 - Create Employee page

5) Now create a new Employee view object EmpBasedOnEOViewObj based on the EmployeeEO entity object.

In the Step 2 of Entity Objects, select EmployeeEO from the Available panel and shuffle it to the selected panel.

In the Step 3 of Attributes, shuffle all the attributes from Available to Selected.

Click finish to complete the View Object creation.

6) Create DeptVO view object with following query:-select department_id,department_name,manager_id,location_id from DEPARTMENTS

7) Create ManagerVO view Object with following query:-

SELECT employee_id, first_name || ' ' || last_name employee_name FROM employees

8) Create a JobVO with following query :-SELECT job_id,job_title FROM jobs

9) Shuffle the above created view objects DeptVO, ManagerVO, JobVO and EmpBasedOnEOViewObj in the Application module.

10) Create a new jspx page with name CreateEmp as name.11) Set the navigation rule from EmpList to CreateEmp as “CreateEmp”.

Page 3: ADF Learning 4 - Create Employee page

12) Now got to the data control palette, expand the Application module data control and select EmpBasedOnEOViewObj1 and drop it on the panelPage. And from the pop up menu select the Forms-> ADF form option.

13) From the Edit Form fields delete employee id, job id, manager id and department id fields. And then click ok.

Page 4: ADF Learning 4 - Create Employee page

14) Now user wants to select the job for the new employee from the list of jobs. Add the job name as a list item will allow user to only select one job. Select the EmpBasedOnEOViewObj1 from the data control palette.

15) Select JobId and drop it on the af:panelForm. And from the context menu, select Single Selections > ADF Select One Listbox.

16) In the List Binding Editor, click the Add button next to the List Data Source item. Select the JobVO1.

Page 5: ADF Learning 4 - Create Employee page

17) Make sure that the Base data source as JobId and List Data source as JobId. 18) In the list set the Display attribute to JobName.

Above Steps from 11 to fifteen will display the job name as the list box on the page. And behind the scene, it will set the value of JobId in the EmpBasedOnEOViewObj1 equalant to the JobId of the selected jobName from the list box.

Page 6: ADF Learning 4 - Create Employee page

Similarly we will now create a list box for the Managers and departments.19) Select the ManagerId from the EmpBasedOnEOViewObj1 in the data control

palette and drop it on to the panelForm and select the Single Selections > ADF Select One Listbox.

20) In the List Binding Editor, click the Add button next to the List Data Source item. Select the ManagerVO1. And click on ok.

21) Make sure that the Base data source attribute to ManagerId and List source data Attribute to EmployeeId.

22) In the list set the Display attribute to EmployeeName.

23) Select the DepartmentId from the EmpBasedOnEOViewObj1 in the data control palette and drop it on to the panelForm and select the Single Selections > ADF Select One Listbox.

24) In the List Binding Editor, click the Add button next to the List Data Source item. Select the DeptVO. And click on ok.

25) Make sure that the Base data source attribute to DepartmentId and List source data Attribute to DepartmentId.

26) In the list set the Display attribute to DepartmentName and click on OK.

Page 7: ADF Learning 4 - Create Employee page

27) Now select the Commit option from the DataControl Palette and drop it on the footer inside the PanelForm Facets.

28) Select the Adf Command button from the context menu.

Page 8: ADF Learning 4 - Create Employee page

29) Open the EmployeeList page created in the Lesson 2. 30) Select the Create option under the operations folder under the

EmpBasedEOViewObj1 and drop it under the Menu2menuBar option under the PanelPage facets.

31) Select the ADF Command link option from the context menu.32) Change the Text property of the link to “Add Employee” and set the Action

property to CreateEmp.

Run your EmpList Page and click on the Add Employee link to navigate to the CreateEmp page and click commit to save the filled details in database.

Page 9: ADF Learning 4 - Create Employee page