ADF EMG XML DataControl - Map the Datacontrol with xml from DB

149 views
Skip to first unread message

Ashok A

unread,
May 9, 2016, 10:58:11 AM5/9/16
to ADF Enterprise Methodology Group
Hi Team, 

I have been reading this form posts to solve a generic problem.

(I am new to ADF - mostly SOA/OSB background so bare with me).

Scenario:
XML clob stored in DB column. (xml structure is known and may change with revisions)
I need to display, edit and save this xml. (display as an editable adf form) (xml structure is 3 levels --> ex: po/lines/shipments)
Elected to use XML DataControl (I am able to generate the DC using xsd and create the ADF UI editable form)

Questions:
1 - Is xml DC the best option?
2 - what is the best way to extract the xml from the DB and map it to the xml data control. (if you have links to samples, it would be helpful to this novice)

Thanks,
Ashok

Ashok A

unread,
May 16, 2016, 9:42:24 AM5/16/16
to ADF Enterprise Methodology Group
I solved this by programatically extracting the payload and set it in the pageflowscope map.
In the data control I used ELDataProvider

         <data-provider class="org.adfemg.datacontrol.xml.provider.data.ELDataProvider">
          <parameters>
            <parameter name="expression" value="#{pageFlowScope.key}"/>
          </parameters>
        </data-provider>

For saving the data, I just extracted the data programatically and setit to my UpdatableVO and commit the transaction.

        XMLDCElement resultObj = (XMLDCElement) BindingContext.getCurrent().getCurrentBindingsEntry().getOperationBinding("getXML").getResult();
               System.out.println("As String :  " + resultObj.getElementAsString());

Hope this helps anyone facing the same problem.

Wilfred van der Deijl

unread,
Jun 12, 2016, 8:14:14 AM6/12/16
to ADF Enterprise Methodology Group
Sorry to have missed your question. The suggested ELDataProvider is one solution and easiest to setup. But it does mean you have to implement the database interfacing logic in the ViewController and put the data one a scope that's intended for view layer stuff.
The most "pure" approach would be to create your own DataProvider. A number of examples are included in the XML DataControl package: https://bitbucket.org/adfxmldc/xml-datacontrol/src/94059e4722abade532d10a62b511d9b1d7e51f2f/XMLDataControl/coresrc/org/adfemg/datacontrol/xml/provider/data/?at=master

Your dataprovider has to extend from org.adfemg.datacontrol.xml.provider.data.DataProvider and implement the getRootElement to get the XML from the database This getRootElement method gets a DataRequest object with all required information like dynamic parameters. You can also get configuration information form the DataControls.dcx for things like the datasource name and SQL query or database table to access. Look at some of the other DataProviders to get an idea how that works.

Such an DatabaseDataProvider.getRootElement kan be used to create a first datacontrol to fetch XMLDB data. This is than exposed as a mutable datacontrol to the page. Once the user has changed the data and you want to store that information you would typically use a second datacontrol (or second method on the same datacontrol). That second datacontrol (operation) would require a dynamic-parameter (see https://adfxmldc.atlassian.net/wiki/display/XMLDC/Using+Dynamic+Parameters) of type org.w3c.dom.Element. You can feed this #bindings.iteratorFromFirstDataControl.currentRow.dataProvider.element. That expression gets the current row from the root iterator of the first datacontrol (which is the xml element retrieved from the database that has now been changed by the user). From that currentRow we get the dataProvider (which is an org.adfemg.datacontrol.xml.data.XMLDCElement). From that class we get the element which is the raw org.w3.dom.Element. That is fed to the second datacontrol which can save it back to the database in its getRootElement method. This is the same trick we use when working with webservice datacontrols that typically have separate methods for retrieving and storing data.
The second method to store the data might return a simple OK element or perhaps a more complex element with processing results. Invoking that "save" method can be a simple method action in a page flow diagram or a button on a page. Just drag the save-method from the datacontrol onto the page or pageflow diagram. We still need to document this pattern better at https://adfxmldc.atlassian.net/wiki/display/XMLDC/Saving+Data

If you get the XMLDB datacontrol working a pull request to contribute back to the project is always appreciated
Message has been deleted

Mahesh Reddy

unread,
Jun 27, 2017, 4:28:14 PM6/27/17
to ADF Enterprise Methodology Group
Hi,

I have same requirement as mentioned above using navigation controls getting data from dB column(club/varchar).. I am using ELdatacontrol with pageflowscope.key. In first request I am able to get the data in data control fields , but in next request with in session data not updating.. same data is reflecting again in dc but updated data reflecting in output text field(to testing I used) . Is this getXML() method will call only one time. Can any one tell me how to get updated values .. how to refresh the data control .?
Reply all
Reply to author
Forward
0 new messages