Posting data for editable lists

APIs that take a list of elements in the way described here have different behavior based on the functionality required from the API. This different behavior must be handled by the user interface.

One way an API may handle a list of elements is to completely replace the entire list each time the API is called. This means that the user interface must pass all attributes of each item whenever the API is called. This is accomplished by using the IgnoreChangeNames() JavaScript function. Calling this function when a JSP loads ensures that each single input on the screen is posted.

For example, edit your JSP file to contain the following code:

<script language="Javascript" >
IgnoreChangeNames();
</script>

In some cases an API might expect that a specific record be passed to the API only when some attribute has changed. Since the Presentation Framework does not automatically post any value that has not been changed by the user, it is quite possible that the XML constructed by the Service Definition Framework may contain an element with only the key attributes of a specific record. This can happen because the key attributes are usually hidden input objects in the JSP placed within each row of the html table. Since they are hidden inputs, they are always posted to the API. Therefore, if the user does not change any of the attributes of a specific record in one row, only the key attributes are passed to the API. Some APIs consider this to be invalid input.

A Presentation Framework JavaScript function can be used to verify that records for which no change has been made are not posted to the API. The yfcSpecialChangeNames() function should be called when the page is unloaded.

For example, the following JSP code achieves this:

<script language=jscript>
window.document.body.attachEvent("onunload", processSaveRecordsForNotes)
</script>

The JavaScript function used in this example is defined as:

function processSaveRecordsForNotes() {
    yfcSpecialChangeNames("Notes", true);
}

In this example, the ID of the HTML table in the corresponding JSP is set to the literal Notes. The second parameter, true, must be passed only if the ID Notes consists of a new blank row. The parameter should be set to false if you want to modify an existing row.