Sunday, December 1, 2013

Refactoring DataBindings.cpx file and Having Multiple cpx files

I found some interesting facts while I was playing with DataBindings.cpx file this weekend and I'm blogging them now after a long time.
  • Renaming the default DataBindings.cpx file.
  • Having more than one DataBindings file in a project.
       As you know the DataBindings.cpx file plays a vital role in the ADF Model layer, which is used to create the BindingContext for the Web Application by ADFBindingFilter and this stores the meta info about page defintions mappings to create the Binding Container for ADF data bound pages and DataControl usages to find the appropriate AppModules and ErrorHanler config,etc.

       JDeveloper does not provide declarative facility to rename or move the DataBindings.cpx file. To rename or move the DataBindings.cpx file, just create the new one and delete the existing one. While doing this don't forgot to update the adfm.xml file which is the registry of registries and always have the id property is same as the DataBindings cpx file name otherwise you will get error message  "DataControl is not found".

For example if you are renaming the cpx file from DataBindings.cpx to MyDataBindings.cpx, update the id as follows.

DataBindings.cpx file

<?xml version="1.0" encoding="UTF-8" ?>

<Application xmlns="http://xmlns.oracle.com/adfm/application"
             version="11.1.1.61.92" id="DataBindings" SeparateXMLFiles="false"
             Package="view" ClientType="Generic">
.........................
.........................
</Application>

MyDataBindings.cpx

<?xml version="1.0" encoding="UTF-8" ?>
<Application xmlns="http://xmlns.oracle.com/adfm/application"
             version="11.1.1.61.92" id="MyDataBindings" SeparateXMLFiles="false"
             Package="view" ClientType="Generic">
.........................
.........................
</Application>

         If you want to have more than one DataBindings.cpx file in a project, then  add the entries in the adfm.xml file, because ADFBindingFilter looks for the cpx files in the adfm.xml file. Cpx file names should be unique within the project.

Sample adfm.xml for multiple cpx files.

<?xml version="1.0" encoding="UTF-8" ?>

<MetadataDirectory xmlns="http://xmlns.oracle.com/adfm/metainf"                                      
                                                             version="11.1.1.0.0">
  <DataBindingRegistry path="view/DataBind1.cpx"/>
  <DataBindingRegistry path="view/DataBind1.cpx"/>
  <DataBindingRegistry path="view1/DataBind2.cpx"/>
</MetadataDirectory>



Note:  It is best practice to have cpx file name as DataBindings.cpx and having only one cpx file if we don't have special use cases.



3 comments:

  1. i tried to experiment with multiple databindings 1. Original - DataBindings.cpx 2. MyDataBindings.cpx, with entry as reqd in adfm.xml.

    And tried to create a new page and hence pagedef. But the entry of page and pagedef appeared in DataBindings.cpx file only.

    Do we need to do any config, to inform system that all new entries shld come in new binding file.

    Thank you in advance.
    Rajan

    ReplyDelete
  2. Hi Rajan,
    I understood ur question, but I couldn't find any property or configuration parameter to set a Databindings file as deafult. As a workaround, you could cut & paste the pageDef entry in the new cpx file. I'll keep you posted if I found the solution.

    Regards,
    Felix

    ReplyDelete
  3. Is there any provision to load only one .cpx like Lazy loading something that sort?

    Regards,
    Prabeeth

    ReplyDelete