There is one not well advertised, but great feature in Oracle ADF framework - Custom Declarative Components development for ADF Faces Rich Client. Its really powerful thing, because it allows to build your own components based on groups of standard ADF Faces Rich Client components. There is an article on OTN written by Frank Nimphius, where he describes how you can build, deploy and use this type of components - How-to bind Custom Declarative ADF Faces Components to ADF. In my post, I will give you an example of practical usage, and will describe how Custom Declarative Components can be applied.
Download sample application - AdvancedLOVComponent.zip. This archive contains two JDeveloper 11g R1 applications. One implements Custom Declarative Component, and second is using this component. Developed component represents LOV and description field as one element. Its very common requirement coming from Oracle Forms, to give LOV component and provide description text as well. In Oracle ADF, its usually developed with two ADF Faces Rich Client components - af:inputListOfValues and af:outputText. But, why not to put those two into one and create our own LOV tag. This component will join af:inpitListOfValues and af:outputText:
There is PartialTrigger dependency declared on af:outputText from af:inputListOfValues. And af:inputListOfValues is set as AutoSubmit component. This will allow to change LOV description text value, when LOV value itself is changed.
Component is developed in generic JDeveloper 11g R1 project and supports declarative component metadata:
Main trick with those components is that we can set attribute values on runtime dynamically, from declared attributes. In my sample I'm providing five attributes, among them LOV value and model values, labels and LOV description text value:
This set of input attributes can be extended anytime, without affecting already created usages on your pages.
If we will look into component source code, we will see standard LOV and Output Text tags. Only one specific, those tags get attribute values from declared input attributes instead of bindings:
You need to deploy developed component to ADF Library in order to use it in your project:
Now we will switch to application, where we will use development component on JSPX page. Before using custom component, you need to declare custom tag library:
When custom tag library will be declared, components will be present in Component Palette window:
Drag and drop custom component to JSPX and you will see it in Structure window:
Let's see in source code - one custom tag andrejusb:ListOfValuesAdvanced implements two standard components - af:inputListOfValues and af:outputText. That's great, because it can save development time for LOV's at least twice. And it's not only about time, but about code quality and reusability:
Attribute values for custom tag are set in standard way - from bindings.
On runtime, custom tag is rendered as DepartmentId LOV and description text for specific LOV value (Control And Credit in this case):
LOV from custom tag works same as standard LOV. Let's open LOV popup and change current value:
When new value is selected in LOV, description text is updated as expected. And both elements are present on JSPX as single element: