OAF Master – Detail Page
Hello,
OAF Master-Detail page will be covered in this tutorial. In order to make a master-detail OAF page, we need to use Association and View Link BC4J objects for keeping data integrity.
1. Run below sql in order to create tables, synonyms and sequences. Please pay attention to foreign key constraint between two tables. This constraint provides both data integrity and automatic generation of Association and View Link objects in JDeveloper.
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 31 32 33 34 35 36 37 38 |
create table xxntc.xx_teams ( team_id number primary key, team_name varchar2(100), budget number, establish_date date, creation_date date, created_by number, last_update_date date, last_updated_by number, last_update_login number ); create public synonym xx_teams for xxntc.xx_teams; create sequence xxntc.xx_teams_s start with 1; create table xxntc.xx_players ( player_id number primary key, team_id number, name varchar2(100), surname varchar2(100), salary number, position varchar2(100), creation_date date, created_by number, last_update_date date, last_updated_by number, last_update_login number, constraint xx_players_fk foreign key (team_id) references xxntc.xx_teams (team_id) ); create public synonym xx_players for xxntc.xx_players; create sequence xxntc.xx_players_s start with 1; |
2. Open a JDeveloper which has already prepared for initial setup. Right Click to your project and click New. Go To Business Tier-> ADF Business Componenets -> Business Components from Tables and click Ok button.
3.Organize your entity objects.
4.Organize your view objects.
5.Keep going without creating read-only view objects.
6. Create application module and add your view objects into it.
7. Final structure for BC4J model:
8. Right click to XxPlayersFkAssoc association and click edit.
9.In order to automatically set TeamId for child entity, there must be a composite relationship between master and detail entity objects. In order to do this, check composite association.
10. Create a new OAF page with following steps.
11. Define a controller object for your page.
12. Edit PageLayout Region properties:
ID | Window Title | Title | AM Definition |
---|---|---|---|
PageLayoutRN | Master-Detail Page | Master-Detail Page | xxntc.oracle.apps.per.md.server.XxMdAM |
13. Add two new region to page layout region and edit their properties with below information.
ID | Item Style | Text |
---|---|---|
MasterHdrRN | header | Teams |
ID | Item Style | Text |
---|---|---|
DetailHdrRN | header | Players |
14. Add a new region using wizard into MasterHdrRN.
15. Add a new region using wizard into DetailHdrRN .
16. Add tableActions into XxPlayersEOVO2 table region.
17. Add New Item to Region1 under table actions and edit item properties with below information.
ID | Item Style | Prompt | Action Type | Event |
---|---|---|---|---|
AddPlayer | button | Add Player | firePartialAction | addPlayer |
19. Add a new region into PageLayoutRN and edit properties with below information.
ID | Region Style |
---|---|
PageButtonBarRN | pageButtonBar |
20. Add a new item into PageButtonBarRN and edit properties.
ID | Item Style | Prompt |
---|---|---|
Apply | submitButton | Save |
21. Create and Ovewwrite create methods for entity object java files XxPlayersEO and XxTeamsEO.
22. Make the following code changes.
MasterDetailPGCO.java
1 2 3 4 5 6 7 8 9 10 |
public void processRequest(OAPageContext pageContext, OAWebBean webBean) { super.processRequest(pageContext, webBean); OAApplicationModule am = pageContext.getApplicationModule(webBean); if (!pageContext.isFormSubmission()) { am.invokeMethod("createEmptyTeam"); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean) { super.processFormRequest(pageContext, webBean); OAApplicationModule am = pageContext.getApplicationModule(webBean); if ("addPlayer".equals(pageContext.getParameter(OAWebBeanConstants.EVENT_PARAM))) { am.invokeMethod("addPlayer"); } else if (pageContext.getParameter("Apply") != null) { am.invokeMethod("commit"); } } |
XxTeamsEOImpl.java
1 2 3 4 5 6 7 8 |
public void create(AttributeList attributeList) { super.create(attributeList); OADBTransactionImpl transaction = (OADBTransactionImpl)getOADBTransaction(); Number TeamId = transaction.getSequenceValue("XXNTC.XX_TEAMS_S"); setTeamId(TeamId); } |
XxPlayersEOImpl.java
1 2 3 4 5 6 7 8 |
public void create(AttributeList attributeList) { super.create(attributeList); OADBTransactionImpl transaction = (OADBTransactionImpl)getOADBTransaction(); Number PlayerId = transaction.getSequenceValue("XXNTC.XX_PLAYERS_S"); setPlayerId(PlayerId); } |
XxMdAMImpl.java
1 2 3 4 5 6 7 8 9 10 11 |
public void createEmptyTeam() { XxTeamsEOVOImpl vo = getXxTeamsEOVO1(); if (!vo.isPreparedForExecution()) { vo.executeQuery(); } Row row = vo.createRow(); vo.insertRow(row); row.setNewRowState(Row.STATUS_INITIALIZED); } |
1 2 3 4 5 |
public void commit() { getOADBTransaction().commit(); } |
1 2 3 4 5 6 7 8 9 10 11 |
public void addPlayer() { OAViewObject vo = (OAViewObject)getXxPlayersEOVO2(); if (!vo.isPreparedForExecution()) { vo.executeQuery(); } Row row = vo.createRow(); vo.insertRow(row); row.setNewRowState(Row.STATUS_INITIALIZED); } |
23. Run the page and test it. 24. Check the results.
1 2 3 4 5 6 7 8 9 10 11 |
set linesize 200; column team_name format a20; column name format a20; column surname format a20; column position format a20; select * from xxntc.xx_teams; select * from xxntc.xx_players; |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
TEAM_ID TEAM_NAME BUDGET ESTABLISH_DATE CREATION_DATE CREATED_BY LAST_UPDATE_DATE LAST_UPDATED_BY LAST_UPDATE_LOGIN ---------- -------------------- ---------- -------------- ------------- ---------- ---------------- --------------- ----------------- 2 GALATASARAY 100000000 01/01/1905 21/09/2014 1732 21/09/2014 1732 2323035 1 row selected. PLAYER_ID TEAM_ID NAME SURNAME SALARY POSITION CREATION_DATE CREATED_BY LAST_UPDATE_DATE LAST_UPDATED_BY LAST_UPDATE_LOGIN ---------- ---------- -------------------- -------------------- ---------- -------------------- ------------- ---------- ---------------- --------------- ----------------- 2 2 ANIL ALTUNKAN 100 SC 21/09/2014 1732 21/09/2014 1732 2323035 3 2 SSS DDD 22 GK 21/09/2014 1732 21/09/2014 1732 2323035 2 rows selected. |
Hi I tried this example ,
Can you please confirm one detail for Detail Region do we need to select instance of Viewlink. Example : Master VO –> under this I have assigned view link AM , it gave instance DetailVO2.
The OA passivation framework coding standard has been violated. The view object with full name, MyMasterDetailAM.XxPlayersLEOView2, is not properly prepared for row insertion. Either setMaxFetchSize(0) or executeQuery() (or any equivalent method that ends up executing the view object query) must be called on the view object before new rows are inserted. For a detail view object in a master – detail relationship, executeQuery() (or any equivalent method that ends up executing the view object query) must be called instead of setMaxFetchSize(0) on the detail view object before new rows are inserted into the detail view object. setMaxFetchSize(0) call on the detail view object could cause a number of adverse effects.
What is this error and tell me for assigning Vo’s AM is there any specific order we have to follow .
thanks
Raghava
Hello,
You have to execute query before inserting rows. This is an OA Framework standard.
Make sure that you called this before inserting rows into child vo.
if (!vo.isPreparedForExecution()) {
vo.executeQuery();
}
Hi Raghava,
I am also getting the same error, you fixed the issue?
Hi ,
I have tried above mentioned steps, but whenever I click on AddPlayers I am receiving below error. Kindly let us know where I am missing
oracle.apps.fnd.framework.OAException: oracle.jbo.InvalidOwnerException: JBO-25030: Failed to find or invalidate owning entity: detail entity XxPpeLineEO, row key null.
Hi,
Please make sure that you have properly defined composition association between master and detail entities. Also, check XxPlayersEOImpl.java – create.
hello ,
what if i have multiple line level ,can we associate header EO to multiple line level EO??
Yes you can use multiple association.
Tanks ALot.
Dar AL , from above example vo.insertRow(row); showing error on my application , i follow the complete above steps , kindly guide me