Sunday, August 15, 2010

ADF tree navigation to third level and Workaround for “ADF Tree Not Inside Container”

Step 1: Create view object based on Product table. Structure of this table is shown in Figure 1.



Figure: 1

Create view object "CategoryViewObj" based upon below query on above product table.



Figure: 2

Create view object "ProducerViewObj" based upon below query on above product table.



Figure: 3

Create view object "ProductViewObj" based upon below query on above product table.



Figure: 4

Step 2: Create view link between CategoryViewObj and ProducerViewObj using CategoryId and ProducerViewObj and ProductViewObj using ProducerCode



Figure: 5



Figure: 6

Step 3: Wrap all ViewObjects and ViewLinks in application module like below.

Drag "CategoryViewObj" under ProductAppModule and named it CategoryViewInstance. Drag the viewlink immediate below it and put it under CategoryViewInstance and renamed it to "ProducerInstance" and drag the view link immediate below of "ProducerViewObj" and put it under "ProducerInstance".




Figure: 7

Step 4: Create ADF tree table by dragging "CategoryViewInstance" from data control palate and add its two level of children by clicking green add button adjacent to it. We can select our own display attributes for each level like below.



Figure: 8



Figure: 9



Figure: 10

Modify nodestamp facet under ADF treetable component like below.



Figure: 11

Add columns like below



Figure: 12

While testing the page we face this error.


<RegistrationConfigurator><handleError> Server Exception during PPR, #1
java.lang.IllegalStateException: ADFv: Not inside a container.
at oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding$FacesModel.exitContainer(FacesCtrlHierBinding.java:672) at oracle.adfinternal.view.faces.model.FlattenedTreeCollectionModel.getRowIndex(FlattenedTreeCollectionModel.java:109)
at oracle.adfinternal.view.faces.renderkit.rich.TreeRendererUtils$1.getRowIndex(TreeRendererUtils.java:552)
at oracle.adfinternal.view.faces.renderkit.rich.TreeTableRenderer.handleExpand(TreeTableRenderer.java:520)



This will come because we did not set any key attribute in our view objects and ADF tree table is not able to find row index. So we need to set key attributes to our view objects like below.



Figure: 13



Figure: 14



Figure: 15

While testing we get our desired output.