• ADF
    November 1, 2011

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


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:


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" 
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


Join the discussion

Comments ( 2 )
  • guest Saturday, February 4, 2012

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

  • shantala.sankeshwar@oracle.com Monday, February 6, 2012

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

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.