11. Eugene
Fedorenko
adfprac0ce-‐fedor.blogspot.com
Ø Generate VO’s name
Ø Try to find the VO
Ø Create View Definition
Ø Create VO instance for the View Definition
public
ViewObject
createDynamicVO(String
agileEn0tyName)
{
//Generate
VO
name
for
the
given
en0ty
name
just
by
adding
VAGILE_
prefix
//The
name
for
"DIVERS"
agile
en0ty
is
generated
as
"VAGILE_DIVERS”.
JboNameU0l
class
can
be
used
String
agileVOName
=
getAgileVOName(agileEn0tyName);
ViewObject
agileVO
=
findViewObject(agileVOName);
if
(agileVO
==
null)
{
ViewDefImpl
agileViewDef
=
new
VAgileDefImpl(agileVOName,
getAgileEn0tyDefini0on(agileEn0tyName));
agileVO
=
createViewObjectForDef(agileVOName,
agileViewDef);
}
return
agileVO;
}
Dynamic
View
Object
11
12. Eugene
Fedorenko
adfprac0ce-‐fedor.blogspot.com
Ø Extend VAgile view definition
Ø Set row implementation class
Ø Create entity definition
Ø Resolve and register definition object
public
class
VAgileDefImpl
extends
ViewDefImpl
{
public
VAgileDefImpl(String
name,
VAgileEn0tyDefini0onRowImpl
agileEn0tyDefini0on)
{
super(DEF_SCOPE_SESSION,
name,
"com.cs.blog.deepdiveadf.agiledatamodel.views.VAgile");
setRowClass(VAgileRowImpl.class);
String
en0tyName
=
generateAgileEn0tyName(name);
//VAGILE_DIVERS
-‐>
VAGILE_DIVERS_ENTITY
En0tyDefImpl
en0tyDefImpl
=
new
En0tyAgileDefImpl(en0tyName,
agileEn0tyDefini0on);
addEn0tyUsage("En0ty",
en0tyDefImpl.getName(),
false,
false);
addAllEn0tyABributes("En0ty");
//Two
magic
calls
resolveDefObject();
registerDefObject();
}
Dynamic
View
DefiniOon
12
13. Eugene
Fedorenko
adfprac0ce-‐fedor.blogspot.com
Ø Set implementation class of entity instances
Ø Add agile attributes
Ø Resolve and register the definition object
public
class
En0tyAgileDefImpl
extends
En0tyDefImpl
{
public
En0tyAgileDefImpl(String
en0tyName,
VAgileEn0tyDefini0onRowImpl
agileEn0tyDefini0on)
{
super(en0tyName);
setRowClass(En0tyAgileImpl.class);
RowIterator
agileABributes
=
agileEn0tyDefini0on.getAgileABributes();
while
(agileABributes.hasNext())
{
addAgileABribute((VAgileABributesRowImpl)
agileABributes.next());
}
//Two
magic
calls
resolveDefObject();
registerDefObject();
}
Dynamic
EnOty
DefiniOon
13
15. Eugene
Fedorenko
adfprac0ce-‐fedor.blogspot.com
Ø There is a set of pre-defined validators
Ø JboLengthValidator, JboCompareValidator, JboExpressionValidator, …
Ø Extend JboAbstractValidator
Ø Invoke a constructor and specify the error message
public
sta0c
JboLengthValidator
getLengthValidator(int
maxLength)
{
JboLengthValidator
jlv
=
new
JboLengthValidator(/*inverse*/
false,
/*operType*/
JboLengthValidator.LESSTHANEQUALTO,
/*dataType*/
JboLengthValidator.CHARACTER,
/*value*/
maxLength);
//maxlength_err=Value
must
not
be
longer
than
{0}
characters
jlv.setErrorMsgId(MAX_LENGTH_ERROR);
HashMap
errvaluesMap
=
new
HashMap();
errvaluesMap.put("0",
Integer.toString(maxLength));
jlv.setErrorMsgExpressions(errvaluesMap);
return
jlv;
}
Length
Validator
Example
15
16. Eugene
Fedorenko
adfprac0ce-‐fedor.blogspot.com
Ø Create Resource Bundle Definition
Ø Implement ResourceBundleDef interface
Ø Link entity definition to the resource bundle
<ResourceBundle>
<Proper0esBundle
Proper0esFile="com.cs.blog.En0tyAgileBundle"/>
</ResourceBundle>
public
class
En0tyAgileDefImpl
extends
En0tyDefImpl
{
private
sta0c
String
RESOURCE_BUNDLE_FILE="com.cs.blog.En0tyAgileBundle";
private
void
linkToResourceBundle()
{
Proper0esBundleDef
rb
=
new
Proper0esBundleDef(this);
rb.setProper0esFile(RESOURCE_BUNDLE_FILE);
setResourceBundleDef(rb);
}
Link
to
the
Resource
Bundle
16
17. Eugene
Fedorenko
adfprac0ce-‐fedor.blogspot.com
ü Custom View Definition for an entity-based VO is created and registered
ü Custom Entity Definition is created and registered
ü Contains all necessary attributes
ü UI hints are set up
ü Validators are created
ü Resource Bundle is linked
ü View Object instance is created
ü Only standard ADF BC API is used
Check
Point
17
18. Eugene
Fedorenko
adfprac0ce-‐fedor.blogspot.com
Ø Dynamic table
Ø Dynamic binding approach
Ø EL expression in Binds attribute
Ø #{pageFlowScope.vo} != #{pageFlowScope.vo.name}
<executables>
<iterator
Binds="#{pageFlowScope.vo.name}"
DataControl="AgileDataModelServiceDataControl“
RangeSize="25"
id="VAgileIterator"/>
</executables>
<dynamic:table
value="#{bindings.VAgileIterator}"
id="t1"/>
Give
It
a
Try!
18
22. Eugene
Fedorenko
adfprac0ce-‐fedor.blogspot.com
public VAgileImpl
q Constructor
protected void executeQueryForCollection
q Retrieve and store a pointer to data from alternative data source
protected boolean hasNextForCollection
q Whether there is any data to fetch out
protected ViewRowImpl createRowFromResultSet
q Actually create and populate new VO’s row
public long getQueryHitCount
q Return an estimated count of the rows
protected void releaseUserDataForCollection
q Release and close resources
ProgrammaOcally
Populated
View
Object
22
27. Eugene
Fedorenko
adfprac0ce-‐fedor.blogspot.com
Ø Create and register lookup View Definition
Ø Create and add View Accessor
Ø Create and add List Binding Definition
Ø Set the LOV for the attribute
Dynamic
List
of
Values
27
28. Eugene
Fedorenko
adfprac0ce-‐fedor.blogspot.com
Ø Create and register lookup View Definition
Ø Create and add View Accessor
Ø Create and add List Binding Definition
Ø Set the LOV for the attribute
ViewDefImpl
vaViewDef
=
new
ViewDefImpl();
vaViewDef.setQuery(lookupSql);
vaViewDef.setFullSql(true)
String
lookupViewDefName
=
generateName(viewName,
aBr.getName());
vaViewDef.setName(lookupViewDefName);
vaViewDef.setFullName(lookupViewDefName);
vaViewDef.addViewABribute(lookupValueABrName,
lookupValueABrName,
Object.class);
vaViewDef.addViewABribute(lookupDisplayABrName,
lookupDisplayABrName,
Object.class);
((ABributeDefImpl)
vaViewDef.getABributeDef(0)).setPrimaryKey(true);
vaViewDef.resolveDefObject();
vaViewDef.registerDefObject();
Dynamic
List
of
Values
28
29. Eugene
Fedorenko
adfprac0ce-‐fedor.blogspot.com
Ø Create and register lookup View Definition
Ø Create and add View Accessor
Ø Create and add List Binding Definition
Ø Set the LOV for the attribute
ViewAccessorDef
vaccessdef
=
new
ViewAccessorDef();
vaccessdef.setName(lookupViewDefName);
vaccessdef.setViewDefFullName(lookupViewDefName);
addViewAccessorDef(vaccessdef);
Dynamic
List
of
Values
29
30. Eugene
Fedorenko
adfprac0ce-‐fedor.blogspot.com
Ø Create and register lookup View Definition
Ø Create and add View Accessor
Ø Create and add List Binding Definition
Ø Set the LOV for the attribute
ListBindingDef
lov
=
new
ListBindingDef(getDefManager(),
Defini0onObject.DEF_SCOPE_SESSION);
String
LOVName
=
generateLOVName(aBr.getName());
lov.setName(LOVName);
lov.setListVOName(viewAccessorDefName);
lov.setABrNames(new
String[]
{aBr.getName()});
lov.setListABrNames(new
String[]
{lookupValueABrName});
lov.setListDisplayABrNames(new
String[]
{lookupValueABrName,
lookupDisplayABrName});
addListBindingDef(lov);
((ABributeDefImpl)
aBr).setLOVName(LOVName);
((ABributeDefImpl)
aBr).setProperty(ABributeHints.ATTRIBUTE_CTL_TYPE,
ABributeHints.CTLTYPE_COMBOLOV);
Dynamic
List
of
Values
30
53. Eugene
Fedorenko
adfprac0ce-‐fedor.blogspot.com
Ø Create
View
Criteria
and
set
name
Ø Create
View
Criteria
Row
Ø Create
View
Criteria
Item
for
the
first
aBribute
Ø Set
where
clause
as
value
Ø Set
CRITERIA_MODE_CACHE
to
ensure
memory
filtering
Ø Add
View
Criteria
to
View
Defini0on
ViewCriteriaImpl
viewCriteria
=
(ViewCriteriaImpl)
createViewCriteria();
viewCriteria.setName(userFilter.getName());
ViewCriteriaRow
vcr
=
viewCriteria.createViewCriteriaRow();
String
firstABributeName
=
getABributeDef(0).getName();
ViewCriteriaItem
vci
=
new
ViewCriteriaItem(firstABributeName,
vcr);
vci.setValue(userFilter.getWhereclause());
vcr.addCriteriaItem(firstABributeName,
vci);
viewCriteria.add(vcr);
viewCriteria.setCriteriaMode(ViewCriteria.CRITERIA_MODE_CACHE);
putViewCriteria(viewCriteria.getName(),
viewCriteria);
Dynamic
View
Criteria
53
54. Eugene
Fedorenko
adfprac0ce-‐fedor.blogspot.com
<BC4JDataControl
id="AgileDataModelServiceDataControl"
Package="com.cs.blog.deepdiveadf.agiledatamodel"
FactoryClass="com.cs.blog.deepdiveadf.agiledatamodel.datacontrol.AgileDataControlFactory”
…
public
class
AgileDataControlFactory
extends
DataControlFactoryImpl
{
@Override
protected
String
getDataControlClassName()
{
return
AgileDataControl.class.getName();
}
}
public
class
AgileDataControl
extends
JUApplica0on
{
@Override
protected
void
applySortCriteria(DCIteratorBinding
iter,
SortCriteria[]
sortBy)
{
if
(sortBy
!=
null)
{
ViewObject
vo
=
iter.getViewObject();
JboEnvUOl.applyVOSortCriteria(vo,
sortBy,
true
/*Transient*/)
;
}
}
Memory
SorOng
54
55. Eugene
Fedorenko
adfprac0ce-‐fedor.blogspot.com
Ø Set
VO
property
PROP_ALWAYS_USE_SORT
to
true
Ø Sor0ng
is
always
performed
in
memory
public
class
VAgileImpl
extends
ViewObjectImpl
…
@Override
protected
void
create()
{
super.create()
setProperty(PROP_ALWAYS_USE_SORT,
"true");
}
…
Memory
SorOng
(11.1.1.7.0
&
12c)
55