The Constructs action generates code to instantiate JAXB objects. This code generation is useful in automating the generation of a series of getter and setter methods, especially when the JAXB object contains a series of nested objects. The code that is generated will not only instantiate the JAXB Object, but will also populate all the nested objects with initial values. This instantiation and population of values and objects can be done by passing a sample XML file. The Sample XML file needs to conform to the XSD/Schema used to generate the JAXB class. When sample XML file is not provided, all the nested JAXB members objects are instantiated.
Drag and drop the Constructs JAXB Object icon into the IDE editor of an existing project.
The Generate JAXB Constructs code dialog box is displayed.
Enter the JAXB class name with the package name to be instantiated/initialized. You can also use the Find button to search for the class (as shown below).
Enter a sample XML file (if available) for the initialization code to use. Update the auto generated method name if required.
Assuming the XML file conforms to the schema used in generating JAXB classes, a method will be created (as shown below).
If the sample XML file is not provided, the code generated will not populate the default values (as shown below).