The input and output of APIs in in the form of an XML document. Using XML documents enables the Presentation Frameworks to provide an XML binding mechanism where a developer can form the input meccassary to pass tp an API and populate a screen with its output.
The binding logic is based on using the name attribute of input fields to map onto an XML attribute. The actual HTML string that needs to be formed is returned by various HTML tag-specific JSP functions and JSP tags that have been provided for that purpose. The HTML that is rendered contains the name attribute set to the appropriate XML path. When data is posted to the server, the servlet provided by the Service Definition Framework captures the request and forms an XML document out of the data in the input and XML path contained in the name attribute. The XML document is then passed as input to the API that has been configured for the action being performed.
For example, you may bind an input box to the ShortDescription attribute of the getItemList() API in an Item search view.
After the JSP functions and JSP tags are resolved, the HTML is formed as follows:
Note: This example does not show all of the custom attributes returned by the JSP functions. It only shows the ones relevant to this topic.
In another example, the user enters Telephone in the input box. When the data is posted to the server, the Presentation Framework forms the following XML document based on the name and the value of the input box.
Special XML data binding considerations
The XML binding for an input field on the screen enables you to uniquely bind a field to a single attribute in the XML document.
The XML binding is used as the name of the HTML input object. A binding consists of the complete XML path and attribute name of the target attribute. Given this fact, it is not immediately obvious how to bind input boxes to XML attributes that exist in an XML list. For example, given the following XML:
<Order> <OrderLines> <OrderLine OrderLineKey="1000001" ShipNode="ShipNode1"/> <OrderLine OrderLineKey="1000002" ShipNode="ShipNode2"/> </OrderLines> </Order>
XML data binding syntax
APIs are called with the input XML that is bound in the screen, and that XML binding should match the output of the API.
XML Binding syntax
The following examples show correctly structured syntax:
The following examples show incorrectly structured syntax:
XML Binding Parameters
XML binding for multiple element names
The general rule for XML binding consists of using the full path and attribute name.
However, this may result in multiple input objects in the JSP with the same name. Input objects with the same name are posted as an array of objects and are not posted to the API.
To uniquely identify each input as part of a specific XML element, you can add a postfix that contains an underscore (“_”) plus a counter after the repeating element name.
For example, the binding of each ship node field on the list of order lines should be
If you require a screen that contains a list of order lines with ship node editable on each line, you can use a special XML binding convention to handle this scenario.
The repeating element is OrderLine. For each ship node input object, the special postfix is added for each line. The result is two unique XML bindings: When this data is posted, all XML bindings containing the same special postfix are combined into the same XML element in the API input.
To make using this special postfix XML binding easier, the loopXML JSP tag provides a JSP variable that contains a unique counter for each individual loop. This JSP variable, that is available inside the loopXML JSP tag, is the ID attribute specified in the loopXML tag plus the literal Counter. For example, use the following loopXML in your JSP:
<yfc:loopXML name="Order" binding="xml:/Order/OrderLines/@OrderLine" id="OrderLine">
This makes the OrderLineCounter JSP variable available for use inside of the input XML bindings. For example:
<input type="text" <%=yfsGetTextOptions("xml:/Order/OrderLines/OrderLine_"
+ OrderLineCounter + "/@ShipNode", "xml:/OrderLine/@ShipNode",