Integrating Javascript into xforms

13 views
Skip to first unread message

Gogo Liang

unread,
Aug 27, 2009, 11:59:15 AM8/27/09
to Ubiquity XForms Developers
Hi All:

Could anyone give me some suggestion about integrating Javascript into
xform? How many ways are there integrating Javascript into xforms and
how to integrate?

John Boyer

unread,
Aug 27, 2009, 12:40:24 PM8/27/09
to ubiquit...@googlegroups.com

Here's a start:

1) Certain normal javascript techniques just work with XForms.  For example, if you put a class attribute on an XForms form control (like an xf:input or xf:group) and then you use some javascript to change the class, the result of that change is seen on the screen.

2) There is a basic javascript function extension mechanism available that allows you to define javascript functions that can be called by XPaths used XForms, including computes (e.g. calculate, constraint, required, relevant and readonly), bindings (e.g. ref, nodeset) and other XPaths (e.g. the value attribute).  The loan-lowercase.html example in the samples directory, combined with the file format.js, show you how to do this.  It's quite easy.

3) You can set up your own event listeners for events in the XForms processing lifecycle, and then you can run your own javascript code.  That code can invoke the Ubiquity processor's functions that implement XForms actions such as setvalue, insert and delete.  You can also directly change data, then set various model flags such as the rebuild and recalculate flags, and then you can call deferredUpdate() on the model.

Cheers,
John M. Boyer, Ph.D.
STSM, Interactive Documents and Web 2.0 Applications
Chair, W3C Forms Working Group
Workplace, Portal and Collaboration Software
IBM Victoria Software Lab
E-Mail: boy...@ca.ibm.com  

Blog:
http://www.ibm.com/developerworks/blogs/page/JohnBoyer
Blog RSS feed:
http://www.ibm.com/developerworks/blogs/rss/JohnBoyer?flavor=rssdw




From: Gogo Liang <gogo.le...@gmail.com>
To: Ubiquity XForms Developers <ubiquit...@googlegroups.com>
Date: 08/27/2009 08:59 AM
Subject: Integrating Javascript into xforms


Gogo Liang

unread,
Aug 27, 2009, 9:54:35 PM8/27/09
to Ubiquity XForms Developers
Thank you, John. Your reply is quite useful for me.
Reply all
Reply to author
Forward
0 new messages