In my application I recreate each ViewObject Instances at runtime with a a new ViewDef which is a copy of original ViewDef with several customizations (hints and other properties of its attributes, modifications in its where clauses. etc, Meta Data is defined in the DB).
Example:
| VO Instance Name | ViewDef (FullName) |
---|
Original | myVoInstanceName | myPackage.myVoInstanceName |
Customized (at runtime) | myVoInstanceName | myPackage.impl.randomName.myVoInstanceName |
When I drop a ViewObject from my DataControl in a Page/PageFragment, It is created a new Node with this definition (tree, gantt, calendar, ...). Each of this node has a child named <nodeDefinition DefName="myPackage.myVoInstanceName">
I find this post https://blogs.oracle.com/groundside/entry/towards_ultra_reusability_for_adf a close solution to my current problem. Simply, I could remove the DefName attribute in the NodeDefinition.
I have found in this "ADF Code Corner The Oracle JDeveloper Forum Harvest 10 / 2010", a better explanation of DefName attribute. In this PDF is explained that It is neccessary when you have a TreeTable with polymorphic ViewObjects, in other cases is optional.
I have found another errors with Gantt and Calendar component.
If you remove the DefName in a calendar Definition, simply It renders empty.
If you remove the DefName in a Gantt It fires a faces error at runtime.
To resolve this errors I have checked that If I change this DefName with my new Name (myPackage.impl.randomName.myVoInstanceName), the component use my custom VOInstance all works fine, but I don't Know how can I change this at runtime. (In this case, I have change the random name for a constant).
My next step was set the variable "myPackage.impl.randomName.myVoInstanceName" into pageDef variable and write this in the DefName attribute.
Steps
1). In a TaskFlow I have executed a MethodCall of DataControl in which I return a Map with the VOInstanceName and ViewDefFullName.
public Map getViewDefsAtRuntime() {
Map<String,String> mapVOsViewDef = new HashMap<String,String>();
ViewObject[] vos = this.getViewObjects();
for (ViewObject vo : vos) {
String voName = vo.getName();
ViewObjectImpl voImpl = (ViewObjectImpl) vo;
String viewDefName = voImpl.getDef().getFullName();
mapVOsViewDef.put(voName,viewDefName);
}
return mapVOsViewDef;
}
2). In the return value property of Method Call I have put this:
#{pageFlowScope.mapViewDefs}
3). In the Page/PageFragment I could check that the map has the correct values:
<?xml version='1.0' encoding='UTF-8'?>
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
xmlns:f="http://java.sun.com/jsf/core">
<af:panelGroupLayout id="pgl1">
<af:inputText label="All VOs Defs" id="it1" rows="10" value="#{pageFlowScope.mapViewDefs}" readOnly="true"/>
<af:inputText label="One VO Defs" id="it2" value="#{pageFlowScope.mapViewDefs['myVoName']}" readOnly="true"/>
<af:table ...>...</af:table>
</af:panelGroupLayout>
</ui:composition>
4) At this point I have try with this: (MyPageFragmentPageDef.xml)
...
<tree IterBinding="DepartmentsIterator" id="Departments">
<nodeDefinition DefName="#{pageFlowScope.mapViewDefs['Departments']}" Name="VOName0">
<AttrNames>
<Item Value="DepartmentId"/>
<Item Value="DepartmentName"/>
</AttrNames>
</nodeDefinition>
</tree>
...
But this doesn't work. The DefName doesn't support EL. How can I solve this?
PS:
I have found another option in this post:
http://adfpractice-fedor.blogspot.com.es/2013/02/dynamic-tree-binding-definition.html
But I cant recreate the binding for Calendar and Gantt and I have an issue if in the TaskFlow is executed a ExecuteWithParams in the VO before is Rendered in the Page. (a Required Not Null error is fired).
This was my first aproximation but I think that it is more dificult resolve all of my issues with it.
jDeveloper 12c (12.1.2.0)