ADF Business Components helps you to transform queried data into xml format. Interestingly, you can manipulate this xml content without much effort, and the same can be posted back to database as well. Please refer this topic 39.7 Reading and Writing XML in Fusion Middleware Fusion Developer's Guide to learn more.
I'm attaching a simple demo application illustrating the usage of ViewObject::readXML(...) and ViewObject::writeXML(...) APIs.
You can download the sample workspace from here. Please see CRUDXMLTestClient.java file in the sample project.
[Runs with Oracle JDeveloper 11g R1 PS2 + HR Schema]
PS: Please note that ViewObject.readXML() will create new row, if the row that you supplied in the xml has not been retrieved by calling findByKey(). New row is inserted into the view object's rowset. Its attributes are populated using the values in any attribute element children of the current row element in the XML.
If the primary key for the new row(EntityObject) is populated using DB Sequence, please remove that attribute from the xml. ADF run time will take care the rest if you have proper implementation in your XXXEntityObjectImpl class to use DB Sequence.
No comments:
Post a Comment