Monday, May 17, 2010

ADF input forms generator (from XSD to a web page)

Requirement
There is one XSD file which has is "Define Conuntry application input data definition".
So it defines all the data you have to fill in to create a Country info. XSD defines which fileds are mandatory and which are optional.
We would like to create an internet service to allow creating/displaying a Country.

Example
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.oracle.com/pcbpel/CountryInfo"
elementFormDefault="qualified">
<element name="CountryInfo">
<complexType>
<sequence>
<element name="Country" maxOccurs="unbounded">
<complexType>
<sequence>
<element name="Name" type="string"/>
<element name="Capital" type="string"/>
<element name="Area" type="decimal"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>


Solution
1)-In JDev, Select the XSD in the Applications Navigator.
2)- Right Click the xsd file and select "Generate JAXB2.0 contet Model".
3)-It generates the required java files.
4)-Right click the relevant Java file(e.g in this case , CountryInfo.java)
5)-Select "Create Data Control" and generate the .dcx file.

Now you can use this Data Control to drag and drop to build any ADF component such as a Form Layout or a Table etc etc.

Bottom Line is somehow you need to create a DataControl out of the XSD file to use that declaratively to build an ADF UI.

Note
You can also generate the Webservice out of these XSD through JAXB and expose that to build UI, either using ADF datacontrol or any standard J2EE solution.

No comments: