Samstag, Juli 23, 2005

AJAX Form Services

The implementation of the AJAX Form Services, that allows an efficient implementation of forms can be found in the JavaScript include file ajaxForms.js.

Again, only one global object named ajaxForms is defined to minimize possible name conflicts. Attached to this object the following methods are available.

data = ajaxForms.getData(obj)

This method searches all INPUT, TEXTAREA and SELECT elements that are contained inside the passed object and uses their values to build up the elements of a XML document.

The obj parameter can be passed using the id of a formular or as a reference to a HTML Object.

This result of this method is a XmlDocument object.

ajaxForms.setData(obj, data)

This method transfers all values from data into the corresponding INPUT, TEXTAREA and SELECT elements of the HTML form. All HTML elements that are part of the form but have no value in data will be cleared or unchecked.

The obj parameter can be passed using the id of a formular or as a reference to a HTML Object.

The data parameter can be passed as a XML text of a XmlDocument object.

This method also calls clearErrors at the end (see below).

ajaxForms.clearData(obj)

All HTML INPUT, TEXTAREA and SELECT elements that are part of the form are cleared or unchecked.

The data parameter can be passed as a XML text of a XmlDocument object.

ajaxForms.resetData(obj)

All HTML INPUT, TEXTAREA and SELECT elements that are part of the form get their initial value that is coded inside the

The obj parameter can be passed using the id of a formular or as a reference to a HTML Object.

ajaxForms.processException(ex)

AjaxForms implements a mechanism to display exceptions that are thrown by the server nearby the fields that causes them. If exceptions are handled by ajaxForms.processException() all ArgumentException are detected.

To enable the developer how the exception text is shown SPAN elements tagged with the css-class AJAXFORMEXCEPTION can be defined inside the form. The text of the exception is then inserted into this Element and can be formatted by using a CSS rule.

<span class="AJAXFORMEXCEPTION" name="LOANVALUE"></span>

ajaxForms.clearErrors()

This method clears all exception texts inside the form.

Kommentare:

Gopinath V hat gesagt…

Hi,

Where can i find the ajaxForms.js javascript file. ?
Is there any sample codes ?
Thanks,
Gopi

MatHertel hat gesagt…

Sorry I didn't link it. I'll post soon more of this.

christian c hat gesagt…

Have you thought about ways to deal with the back button problem?

MatHertel hat gesagt…

I think that AJAX applications have less problems with the back button than tradition ASP.NET or struts based webs.
What special problem do you see ?