0% found this document useful (0 votes)
96 views5 pages

OAF

This document discusses various ways to use view link accessors in Oracle Application Development Framework (ADF). Specifically, it describes how to: 1. Get attribute values from the master view object in the detail view object using the view link accessor name. 2. Call aggregate functions like sum on attributes in the detail view object to calculate values from the master-detail relationship. 3. Set bind variable values in the detail view object based on attribute values from the master view object by overriding a method in the detail view object.

Uploaded by

hisham_476
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views5 pages

OAF

This document discusses various ways to use view link accessors in Oracle Application Development Framework (ADF). Specifically, it describes how to: 1. Get attribute values from the master view object in the detail view object using the view link accessor name. 2. Call aggregate functions like sum on attributes in the detail view object to calculate values from the master-detail relationship. 3. Set bind variable values in the detail view object based on attribute values from the master view object by overriding a method in the detail view object.

Uploaded by

hisham_476
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

8/27/2016

UseViewLinkAccessortocallaggregatefunctions,setattributevalue,setbindvariablesvalue(OracleADF)AshishAwasthi'sBlog(Jdev/ADF)

UseViewLinkAccessortocallaggregatefunctions,setattributevalue,set
bindvariablesvalue(OracleADF)
HelloAll
Thispostisaboutvarioususageofviewlinkaccessor,whenwecreate
viewLinkbetweentwoviewObjects,destinationaccessoriscreatedby
defaultinmasterviewObject,thereischeckboxtocreatesourceaccessor
alsoatsametime
Wecanusethisviewlinkaccessorforcalculatingattribute'ssum,setting
valueofattributesetc

hereDepartmentsismasterviewObjectandEmployeesisit'sdetail,aftercreatingviewLinkyoucanseeinviewObjectxmlsourcethere
accessorispresent
InDepartmentsViewObject

<ViewLinkAccessor
Name="Employees"
ViewLink="sample.model.view.link.DeptTOEmpVL"
Type="oracle.jbo.RowIterator"
IsUpdateable="false"/>
http://www.awasthiashish.com/2014/08/useviewlinkaccessortocall.html

1/5

8/27/2016

UseViewLinkAccessortocallaggregatefunctions,setattributevalue,setbindvariablesvalue(OracleADF)AshishAwasthi'sBlog(Jdev/ADF)

InEmployeesViewObject

<ViewLinkAccessor
Name="Departments"
ViewLink="sample.model.view.link.DeptTOEmpVL"
Type="oracle.jbo.Row"
Reversed="true"
IsUpdateable="false"/>
Sowhatistheuseoftheseviewlinkaccessors?
MasteraccessorindetailviewObjectreturnscurrentRowofmasterviewObject,whenyougenerateRowImplclassfordetail
viewObject,italsohasamethodforthisaccessor

/**
*Getstheassociated<code>Row</code>usingmasterdetaillinkDepartments.
*/
publicRowgetDepartments(){
return(Row)getAttributeInternal(DEPARTMENTS);
}
/**
*SetsthemasterdetaillinkDepartmentsbetweenthisobjectand<code>value</code>.
*/
publicvoidsetDepartments(Rowvalue){
setAttributeInternal(DEPARTMENTS,value);
}
DetailaccessorinmasterviewObjectreturnsarowsetofallrowofdetailsviewObjectthatarecurrentlyreferencedbymasterrecord
/**
*Getstheassociated<code>RowIterator</code>usingmasterdetaillinkEmployees.
*/
publicRowIteratorgetEmployees(){
return(RowIterator)getAttributeInternal(EMPLOYEES);
}
NowseewhatwecandowithviewLinkAccessor

1.GetmasterattributevalueindetailviewObject
supposeihavetogetaattribute'svaluefromMasterviewObject(Departments)inaattributeofdetailviewObject(Employee)
inthisexampleiamgettingmanagerIdfromDepartmentsViewObjectsoforthisjustwriteinexpressionofEmployee'sManagerIdfield
viewLinkAccesorName.AttributeName

http://www.awasthiashish.com/2014/08/useviewlinkaccessortocall.html

2/5

8/27/2016

UseViewLinkAccessortocallaggregatefunctions,setattributevalue,setbindvariablesvalue(OracleADF)AshishAwasthi'sBlog(Jdev/ADF)

nowrunBC4JtesterandcheckcreatenewrecordinEmployeeandseemanagerIdfromDepartmentsisautopopulated

oncreatingnewrecord

2.CallaggregatefunctiontocalculatesumofanattributeofdetailviewObject
supposenowihavetocalculatetotalsalaryofaDepartment(sumofEmployeessalaryofthatdepartment)
forthispurposejustcallsumfunctiontocalculatesumofallrowsofdetailRowSet
takeatransientattributeinDepartmentsViewObjectandwriteinit'sexpression
viewLinkAccesorName.sum("AttributeName")

http://www.awasthiashish.com/2014/08/useviewlinkaccessortocall.html

3/5

8/27/2016

UseViewLinkAccessortocallaggregatefunctions,setattributevalue,setbindvariablesvalue(OracleADF)AshishAwasthi'sBlog(Jdev/ADF)

RunApplicationModuleandsee

3.SetbindvariablevalueaspermasterviewObject'sattribute(passvaluefrommasterviewObject)
Thisistrickypartaswecannotsetbindvariablevaluethroughexpressionasitdoesn'trecognizeviewlinkaccessorname.
createdaviewCriteriaandbindvariableformanagerIdinEmployeeviewObject

appliedthiscriteriatoEmployeesviewObjectinstanceinApplicationModule(JustShuttlecriteriatoselectedside)

http://www.awasthiashish.com/2014/08/useviewlinkaccessortocall.html

4/5

8/27/2016

UseViewLinkAccessortocallaggregatefunctions,setattributevalue,setbindvariablesvalue(OracleADF)AshishAwasthi'sBlog(Jdev/ADF)

nowtosetbindvariable'svaluewehavetooverrideprepareRowSetForQuerymethodinEmployeesVOImplclass

thismethodgetsthevalueofmanagerIdfromcurrentRowofmasterViewObject(Departments)andsetsinbindvariableofEmployees
viewObject

@Override
publicvoidprepareRowSetForQuery(ViewRowSetImplviewRowSetImpl){
RowSetIterator[]masterRows=viewRowSetImpl.getMasterRowSetIterators();
if(masterRows!=null&&masterRows.length>0&&masterRows[0].getCurrentRow()!=null&&
masterRows[0].getCurrentRow().getAttribute("ManagerId")!=null){
IntegermanagerId=(Integer)masterRows[0].getCurrentRow().getAttribute("ManagerId");
viewRowSetImpl.ensureVariableManager().setVariableValue("BindManagerId",managerId);
System.out.println("ManagerIDinbindVar"+managerId);
}
super.prepareRowSetForQuery(viewRowSetImpl);
}
nowrunAMandcheckit

HappyLearning

http://www.awasthiashish.com/2014/08/useviewlinkaccessortocall.html

5/5

You might also like