Customizations
A Customization is extra, custom functionality that is not available in the XML DataControl, you have to program this logic yourself in Java.
So lets start with creating this Java class, in our example we will customize the Employee shown in the UI.
Right click you project and choose new to bring up the New Gallery, then select a Java Class:
Enter a name, for exampl EmployeeCust and enter a package:
After this the Customization Class is created:
We will create all our customizations in the class, but before we are moving on to that, we need to register this class in our DataControl.
Open the DataControls.dcx and go to the Source view. Here we need to tell our DataControl definition that we have a customization class.
This is done by adding an customization-provider after the data-provider in the definition node.
<customization-provider class="org.adfemg.datacontrol.xml.provider.customization.CustomizationProviderImpl"> <parameters> <list-parameter name="classes"> <value>org.adfemg.xmlsample.cust.EmployeeCust</value> </list-parameter> </parameters> </customization-provider>
Since it is possible to have multiple customization classes on one DataControl, this is a list parameter in which you can add multiple value elements with references to customization classes.
That is all you need to tell to the DataControl, so now we can move back to ou Java class and start coding our Customizations.
Warning: The XML DataControl customization-provider works on the compiled classes, not in the design-time source. Make sure that you compile your Java class after every change you make, so the DataControl will pick up the change.
Note: Both the registration of the customization-provider as well as the compiling of sources are obsolete on the trunk build of the XML Data Control. However, in the official 1.0 release, these steps are still necessary.
This will be removed from the documentation once the newer version of the Data Control is officially released.
Element Customization
Every customization is a customization for one element. We need to tell this to the Java class by adding an annotation to the class.
We add the annotation '@ElementCustomization(target = "")' after which JDeveloper should add an import to the 'org.adfemg.datacontrol.xml.annotation.ElementCustomization' class.
The annotation needs an attribute target, here we need to enter the full name to the package of the element we want to customize with this Java class.
The easiest way to get the correct information is to go to the pageDef file and copy the BeanClass from the accessorIterator.
Resulting in the following code:
package org.adfemg.xmlsample.cust; import org.adfemg.datacontrol.xml.annotation.ElementCustomization; @ElementCustomization(target = "org.adfemg.xmlsample.HrDeptEmpDC.getDeptEmps.DepartmentEmployeesResponse.Employee") public class EmployeeCust { }
Inside this class we can now start writing methods to customize the Employee element:
- Calculated Attribute
- Transient Attribute
- Attribute Validation
- Element Validation
- Post Attribute Change
- Element Created
- Operation