Java/XML Converter Builder

 

In this topic ...

Specifying Inputs

Use the Java/XML Converter to transform the public fields of one or more Java objects into an XML variable. The Java/XML Converter allows you to interact with a Java API in builder calls that utilize XML information and not Java objects directly.

For example, a Linked Java Object (LJO) could call into some Java API and return a collection of Java objects. Using a Java/XML Converter builder call, you could create an XML variable that represents the collection and use this XML variable as the data source for one or more Data Page builder calls. You could then display forms that allowed the user to view or modify the properties for each Java object. The Java/XML Converter uses the "set" methods on the object to save any changes back to the object itself.  

The Java/XML Converter operates on the following:

  • Single Java objects

  • Collections of Java objects

  • An Iterator object for a collection of Java objects

 

Specifying Inputs

The Java/XML Converter builder takes the inputs described in the table below. For help on inputs common to many or all builders such as those in the Properties and HTML Attributes input groups, see "Using the Builder Call Editor."

Input name Description
Name Enter a name for this builder call. The designer tool displays this name in the builder call list.
Data Reference Use the Reference Chooser to specify a method or variable that returns one of the following:

  • A single Java object

  • A collection of Java objects

  • An iterator for a collection of Java objects.

The Java/XML Converter examines each object and creates an XML structure defining the public fields in that object.

Reference Type Use the select control to specify whether the Data Reference returns a single Java object or a collection of Java objects.

If the Data Reference returns an Iterator, specify Single Java Object for this value.

Class Name Enter the fully-qualified class name of object(s) returned by the Data Reference.
Variable

Specify the variable to which the Java/XML Converter will generate the XML representing each Java object.

Use Custom Mapping Enable this checkbox if you want to limit the fields converted to XML or if the get/set methods for one or more fields does not adhere to a getFieldName/setFieldName convention.
Mapping Data If you enable "Use Custom Mapping," the Mapping Data table allows you to remove fields from the list of those to be converted or to specify a the get or set method for one or more fields.

To prevent a field from being converted right-click on its name in the table and choose Delete Row from the popup menu.

To specify a particular get or set method for a field, enter the name of the method in the Mapping Data table's Get Method or Set Method column. This method must exist in the Java object.

Generate Schema Create a schema for the XML variable based on the mapped elements.
Top-level Tag Name Enter an XML element name to use for the top-level tag of generated XML.
Row Tag Name If you specify a collection of Java objects as the Data Reference, enter an XML element name to use for each row of generated XML when converting each object in the collection.
Auto-init XML Variable Enable this checkbox to automatically populate the XML variable with the converted XML data.
Generate Events If true, the Java/XML Converter fires events just before and after converting an object to/from XML. The Java/XML Converter builder call adds a variable to the WebApp that contains the corresponding event declarations:

  • Java/XMLConverterNameBeforeConvertFromXML

  • Java/XMLConverterNameAfterConvertFromXML

  • Java/XMLConverterNameBeforeConvertToXML

  • Java/XMLConverterNameAfterConvertToXML

Use an Event Handler builder call to handle these events.

Events are not fired for each field or element, but before or after the Java/XML Converter converts the object or structure as a whole.