Create Master Detail Detail records in EJB using Train

This article describes the creation of master detail detail records using EJB Datacontrol.This is done using ADF Train component.

Use Case Description

Lets us consider that we have countries->locations->departments table with master->detail->detail relationship.We will create countries in first train step ,locations in next train step & departments in the last train step.

Implementation steps

Let us suppose that we have created Java EE Web Application with Entities from countries ,locations & departments table .Also add 'ADF Faces Components 11' under ViewController->project properties-> JSP Tag Libraries.

Then we will create Stateless Session Bean and and generate data control for the Stateless Session Bean.

Now create ADF Task Flow by enabling Train option in the Task flow Wizard

train1.JPG



Taskflow shows 3 views that correspond to countries,locations & departments.It also has create method activity defined that creates new record for countries & this is achieved by dropping countriesFindAll->Operations->Create method from EJB Datacontrol:

train2.JPG


Create country.jsff,location.jsff & department.jsff pages. Drop train component on all these page fragments with value "#{controllerContext.currentViewPort.taskFlowContext.trainModel}"

Open country.jsff & from datacontrol drop countriesFindAll as ADF Form without including navigation controls.Also drop persistCountries(Countries) method as ADF Button 'persistCountries' to persist the data

Once we create countries & persist the data,we would like to navigate to next train step to create locations.This navigation can be achieved by adding action property to 'persistCountries' commandButton :

<af:commandButton actionListener="#{bindings.persistCountries.execute}" text="persistCountries" 
action="{controllerContext.currentViewPort.taskFlowContext.trainModel.getNext}"
disabled="#{!bindings.persistCountries.enabled}" id="cb1"/>

Open location.jsff & drop countriesFindAll->locationsList as ADF Master Form Detail Table on the above page Fragment.

Drop countriesFindAll->locationsList->Operations->Create as ADF button .
And drop mergeLocations(Locations)method from EJB datacontrol as ADF Button 'mergeLocations' to merge the data

Again this mergeLocations button should have action="#{controllerContext.currentViewPort.taskFlowContext.trainModel.getNext}" to navigate to next train step

Open department.jsff & drop countriesFindAll->locationsList->departmentsList as ADF Master Form ,Detail Table on the above page Fragment .
Drop countriesFindAll->locationsList->departmentsList ->Operations->Create as ADF button .
And drop mergeDepartments(Departments)method from EJB datacontrol as ADF Button'mergeDepartments' to merge the data

Now we will create a train.jspx page & drop the above created ADF Task Flow as region on this page

Run this page,it shows train with 3 steps & these train steps allow us to create master->Detail->Detail records

tarinResult.JPG



Comments:

interesting. Is this done using the data from HR schema of Oracle XE? TIA

Posted by guest on February 04, 2012 at 01:29 PM IST #

Yes It is done using the data from HR schema of Oracle XE.

Posted by shantala.sankeshwar@oracle.com on February 06, 2012 at 10:58 AM IST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Tips and Tricks from Oracle's JDeveloper & ADF QA

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today