Tuesday, September 27, 2011

ADF Faces Naming Container Components

(Sorry I was not giving a complete description of the topic here. Apologize to the readers who has requested me to give a full article on this a while back).

Naming Container will not sound unfamiliar if you are developing ADF. Naming Container is a mechanism in ADF to uniquely specify an Id of a component. It's nothing but a naming space attached to its underlying children components and make them unique in the ADF Faces component hierarchy so no components have duplicate Id.

All the Naming Container Components in ADF should implement the NamingContainer Interface. Any children components under the naming container components will have to use its parent naming container id as their prefix in the fully qualified component id. If there are multiple naming container components nested, then multiple naming container prefix will be used. The prefix is separated by ":". component that is located in a naming container thus always has an id value of container id>:.

The naming container prefix is widely used in ADF whenever an Id of a component needs to be specified. For example, the following features -
  • PPR
  • Find a component from page hierarchy by Id (both in Java and JavaScript)
Partial page refresh/rendering is a great feature in ADF. Usually it requires to specify the "partialTriggers" property on the to-be-refreshed components. JDeveloper provides a declarative way to specify the component by browser the page hierarchy tree of the page you are working on, so there is no problem to enter the fully qualified id with the naming container prefix.

If there is a need you have to hardcode the Id the component and the component might be nested by multiple naming container components, you could use getClientId() method on the binding component you are interested in to print the id of the component. This way it ensures you that there is no mistake.

Here should be a complete list of ADF Faces components that implements the NamingContainer interface.

af:calendar
af:carousel
af:declarativeComponent
af:navigationPane
af:panelCollection
af:query
af:quickQuery
af:region
af:pageTemplate
af:subform
af:table
af:train
af:treeTable
af:tree
dvt:hierarchyViewer
dvt:map
dvt:pivotTable
dvt:projectGantt