
IBM Forms Viewer 4


Zweite Ausgabe
Veröffentlicht im Mai 2011

© Copyright IBM Corporation 2000, 2011
Sie können eine lokale Kopie dieses Dokuments von Ihrem Browser aus speichern. Jeder Browser besitzt unterschiedliche Menüs und Menüoptionen. Ziehen Sie die Browser-Hilfe zu Rate, wenn Sie Unterstützung beim lokalen Speichern des Dokuments benötigen.
Wenn Sie zu diesem Dokument Rückmeldungen abgeben möchten, rufen Sie die Website IBM Documentation Feedback auf.
Beim IBM® Forms Viewer handelt es sich um eine Schnittstelle, in der Benutzer Formulare öffnen, ausfüllen und speichern können.
Des Weiteren ermöglicht der Viewer das Anzeigen von Formularen in einem eigenen Fenster (eigenständiger Modus) oder in Ihrem Web-Browser. In beiden Fällen sind alle Funktionen des Viewers verfügbar.
Im Folgenden sind die neuen Funktionen für den Viewer 4.0 aufgeführt.
In diesem Abschnitt werden die verfügbaren Funktionen zur behindertengerechten Bedienung in IBM Forms Viewer beschrieben.
Der Viewer unterstützt Sprachausgabeprogramme, die dem MSAA-Standard (Microsoft® Active Accessibility) entsprechen. Mithilfe dieses Standards unterstützt der Viewer das Sprachausgabeprogramm JAWS von Freedom Scientific sowie andere MSAA-kompatible Sprachausgabeprogramme, wie z. B. Window-Eyes von GW Micro und Microsoft Narrator.
Jedem einzelnen Element eines Formulars kann eine als behindertengerecht definierte, spezielle Nachricht zugeordnet werden. Wenn ein Sprachausgabeprogramm aktiviert ist, überprüft der Viewer die Elemente auf das Vorhandensein solcher Nachrichten, sobald das entsprechende Element aktiviert (hervorgehoben) wird. Der Viewer übergibt die Nachricht dann an das Sprachausgabeprogramm, das die Nachricht und einige allgemeine Informationen zu diesem Element dem Benutzer laut vorliest.
Wenn ein Formular nicht über diese als behindertengerecht definierten Nachrichten verfügt, liest das Sprachausgabeprogramm allgemeine Informationen zu den einzelnen Elementen vor. Dies ist jedoch möglicherweise für den Benutzer keine Hilfe.
Wenn ein MSAA-kompatibles Sprachausgabeprogramm ausgeführt wird, aktiviert der Viewer automatisch die Unterstützung für das Sprachausgabeprogramm.
Der erweiterte Hervorhebungsanzeiger erleichtert es dem Benutzer, festzustellen, welches Element derzeit aktiv ist. Dabei wird ein kleines, schwarzes Rechteck in der Nähe der oberen, linken Ecke des Elements angezeigt. Diese Kennzeichnung erscheint zusätzlich zum normalen Hervorhebungsanzeiger, bei dem üblicherweise ein Element umrandet wird oder der Cursor im Element platziert wird.
Die Seite mit den allgemeinen Vorgaben wird in dem Vorgabenformular geöffnet. Sie können den Viewer so konfigurieren, dass er die Farben des Betriebssystems anstelle der in dem Formular definierten Farben verwendet. Diese Funktion ist nützlich, wenn Sie für die Farben des Betriebssystems einen stärkeren Kontrast festgelegt haben.
Die Release-Informationen enthalten eine Zusammenfassung der neuen Komponenten und Verbesserungen sowie Beschreibungen bekannter Einschränkungen, Probleme und Strategien zur Lösung von Problemen
| Informationen zu diesem Release | Neue Funktionen und Verbesserungen | Neuerungen in IBM Forms Viewer |
| Informationen zu Migration, Upgrade und Konfiguration | Systemvoraussetzungen, Informationen zur Abwärtskompatibilität | Systemvoraussetzungen für Viewer |
| Bekannte Einschränkungen und Probleme sowie Strategien zur Lösung von Problemen | Fehlerbehebung | Fehlerbehebung und Unterstützung |
| Einschränkungen, Probleme und Strategien zur Lösung von Problemen | Technische Hinweise und Flash-Updates für Viewer | |
| Kontakt zur Kundenunterstützung | Kundenunterstützung | Webseite "IBM Forms Support" |
Dieser Abschnitt enthält zwei Referenzkarten, die Informationen zu Tastaturkurzbefehlen und zu Optionen für die behindertengerechte Bedienung enthalten.
Auf dieser Referenzkarte finden Sie eine Liste der Viewer-Tastaturbefehle, die zum Navigieren in einem Formular ohne Verwendung einer Maus verwendet werden.
| Tabulatortaste | Wechselt die Hervorhebung im Formular von Element zu Element in Vorwärtsrichtung. |
| Umschalttaste+Tabulatortaste | Wechselt die Hervorhebung im Formular von Element zu Element in Rückwärtsrichtung. |
| Eingabetaste | Aktiviert eine Schaltfläche oder ein Feld im Formular. |
| Leertaste | Wählt ein Kontrollkästchen oder ein Optionsfeld aus oder zeigt den Inhalt einer Dropdown-Liste an. In einer geöffneten Dropdown-Liste wird durch Drücken der Leertaste die hervorgehobene Option ausgewählt und die Liste geschlossen. |
| Pfeiltasten | Durch Drücken der Links- und Rechtspfeiltaste wird der Cursor zwischen Buchstaben in einem Feld verschoben. In einer Dropdown-Liste wird durch Drücken der Abwärtspfeiltaste der Inhalt der Liste angezeigt. Verwenden Sie die Aufwärts- und die Abwärtspfeiltaste, um durch die Liste der Optionen zu blättern. |
| Alt+F1 | Öffnet die Viewer-Hilfe. |
| Alt+F7 | Überprüft die Rechtschreibung des ausgewählten Elements. |
| Alt+F12 | Öffnet das Fenster "Vorgaben". |
| Alt+Leertaste | Öffnet das Kontextmenü, in dem die Größe des Viewer-Fensters geändert oder in dem das Fenster geschlossen werden kann. |
| Strg+A | Wählt den gesamten Inhalt eines Textfelds aus. |
| Strg+B | Aktiviert oder inaktiviert die Fettschreibung in einem Rich-Text-Feld. |
| Strg+C | Kopiert aus einem Textfeld. |
| Strg+F | Öffnet den Schriftartdialog in einem Rich-Text-Feld. |
| Strg+G | Öffnet den Absatzdialog in einem Rich-Text-Feld. |
| Strg+H | Schaltet den Viewer-Hilfemodus ein und aus, in dem kontextabhängige Hilfenachrichten im Formular angezeigt werden. |
| Strg+I | Aktiviert und inaktiviert die Kursivschreibung in einem Rich-Text-Feld. |
| Strg+M | Verschickt das Formular per E-Mail. |
| Strg+O | Öffnet das Formular. |
| Strg+P | Druckt das Formular. |
| Strg+S | Speichert das Formular. |
| Strg+U | Aktiviert und inaktiviert die Unterstreichung in einem Rich-Text-Feld. |
| Strg+V | Fügt den Inhalt der Zwischenablage in ein Textfeld ein. |
| Strg+Umschalttaste+S | Speichern unter. |
| Strg+Umschalttaste+Plustaste (+) | Vergrößert den Zoom. |
| Strg+Umschalttaste+Minustaste (-) | Verringert den Zoom. |
Diese Referenzkarte enthält Beschreibungen der Viewer-Vorgaben, die geändert werden können.
| WWW-Browser-Konfiguration | |
| Online | Der Computer ist mit einem Netz verbunden und schickt Formulare ab, wenn auf "Abschicken" geklickt wird. |
| Online mit Sicherung | Der Computer ist mit einem Netz verbunden und speichert eine Sicherungskopie des zuletzt abgeschickten Formulars. |
| Offline | Der Computer hat keine Verbindung zu einem Netz. Eine Aufforderung zum Speichern wird angezeigt, wenn auf "Abschicken" geklickt wird. |
| Konfiguration von Funktionen für behindertengerechte Bedienung | |
| Erweiterten Hervorhebungsanzeiger verwenden | Ein kleines, schwarzes Quadrat wird neben der oberen linken Ecke des Elements, das derzeit hervorgehoben ist, angezeigt. Dieses Quadrat wird zusätzlich zu den normalen Hervorhebungsanzeigern angezeigt. So ist es leichter, zu sehen, welches Element hervorgehoben ist. |
| Farben des Betriebssystems verwenden | Der Viewer verwendet die Betriebssystemfarben, wie z. B. einen starken Kontrast, wenn ein Formular gezeichnet wird, und nicht die in dem Formular selbst angegebenen Farben. |
| Eingabeprüfungsoptionen | |
| Während der Eingabe auf Fehler prüfen | Der Viewer nimmt eine Fehlerprüfung vor und unterstreicht Fehler beim Eingeben von Wörtern. |
| Datumsformat | Diese Einstellung legt fest, wie der Viewer numerische Daten interpretiert. Zum Beispiel kann die Angabe "02/03/2009" als 3. Februar 2009 oder als 2. März 2009 interpretiert werden. Durch Festlegen des Datumsformats wird sichergestellt, dass der Viewer möglicherweise verwirrende Daten richtig identifiziert. |
| Tabulatoroptionen – Wenn die Tabulatortaste zweimal gedrückt wird, wird die Hervorhebung von einem Element mit ungültigen Informationen oder fehlenden erforderlichen Informationen verschoben. Die Hervorhebung kann unabhängig von den ausgewählten Tabulatoroptionen mithilfe der Maus gewechselt werden. | |
| Wechsel mit Tabulator aus leeren obligatorischen Elementen stoppen | Ist diese Option aktiviert, kann die Hervorhebung von ungültigen Eingabeelementen nicht mit der Tabulatortaste nicht gewechselt werden. |
| Wechsel mit Tabulator aus leeren obligatorischen Elementen stoppen | Ist diese Option aktiviert, kann die Hervorhebung von leeren obligatorischen Elementen nicht mit der Tabulatortaste gewechselt werden. |
| Smartfill - Smartfill zeichnet häufig verwendete Informationen auf und fügt sie dann automatisch in für Smartfill aktivierte Formulare ein. | |
| Smartfill aktivieren | Ist diese Option aktiviert, fordert Smartfill Benutzer auf, anwendbare Daten zu speichern. In einem für Smartfill aktivierten Formular wird der Benutzer gefragt, ob die Daten zum Ausfüllen von Formularen verwendet werden sollen. |
| Konvertierungsoptionen | |
| Optionsfelder als Kontrollkästchen drucken | Druckt Optionsfelder als Kontrollkästchen. Dadurch wird in dem gedruckten Formular visuelle Konsistenz hergestellt. Alle Optionen werden einheitlich als Kontrollkästchen dargestellt. |
| Optionsfelder ohne Werte drucken | Druckt alle Optionsfelder in einer Gruppe als leere Optionen. |
| Schiebeleisten für Felder drucken | Druckt die Schiebeleisten, wie sie neben Textfeldern angezeigt werden. |
| Felder mit einer Zeile als Zeilen drucken | Druckt eine leere Zeile anstelle eines einzeiligen Felds als leeres Rechteck. |
| Rahmen um Formularseite drucken | Rahmt das Formular visuell ein, indem ein Rahmen um das Formular herum gedruckt wird. |
| Seitenlayoutstandard | |
| Auf eine Seite einpassen (vergrößern oder verkleinern) | Druckt die Formularseite auf eine einzige Papierseite. Durch diese Option wird das Formular so vergrößert oder verkleinert, dass es auf eine einzige Seite passt, wobei die Seite möglichst gut ausgenutzt wird. |
| Auf eine Seite verkleinern | Druckt die Formularseite auf eine einzige Papierseite. Diese Option verkleinert das Formular so, dass es auf eine einzelne Seite passt. Wenn das Formular bereits auf eine einzige Seite passt, wird es nicht skaliert. |
| Nebeneinander (eine Richtung) | Druckt das Formular in Richtung der längeren Seite auf mehrere Druckseiten (horizontal oder vertikal). Diese Option verkleinert oder vergrößert das Formular so, dass die kürzere Seite auf eine einzelne Druckseite passt, falls erforderlich. |
| Nebeneinander (zwei Richtungen) | Druckt das Formular in beide Richtungen auf mehrere Druckseiten (horizontal und vertikal). Diese Option druckt das Formular in ihrer tatsächlichen Größe. |
| Weitere Optionen | |
| Jede Seite des Formulars als einzelnen Druckjob drucken | Druckt die einzelnen Formularseiten als einzelne Druckjobs und fasst die Seiten des Formulars nicht zu einem einzigen Druckjob zusammen. Wählen Sie diese Option nur aus, wenn der Drucker nicht über genügend Speicher zum Drucken eines großen Formulars verfügt. |
| Schwarzweißdruck (Bilder ausgenommen) | Druckt das Formular schwarzweiß. Wählen Sie diese Option aus, wenn der Drucker die Farben des Formulars nicht gut farbig drucken kann. Typische Fehlersymptome in einem solchen Fall sind schwarze Kästchen anstelle von Text, fehlender Text sowie weiß umrandeter Text bei transparenten Kennzeichnungen. |
| Optionen für Formulardarstellung | |
| Rahmen um alle Formularelemente anzeigen | Zieht eine Begrenzungslinie um die Kanten aller sichtbaren Formularelemente. Diese Option sollte nur aktiviert werden, wenn das Layout eines Formulars entworfen wird. |
| Kontrollkästchen mit "X" verwenden | Kontrollkästchen werden standardmäßig als dreidimensionale Kästchen mit einem roten Häkchen dargestellt, wenn sie ausgewählt sind. Wenn diese Option ausgewählt ist, werden Kontrollkästchen stattdessen als zweidimensionale Kästchen mit einem schwarzen "X" dargestellt, wenn sie ausgewählt sind. |
| Felder beim Zoomen verschieben | Bietet durch Hinzufügen von Schiebeleisten zu vergrößerten Feldern Zugriff auf den vollständigen Text. Dadurch wird nicht beeinflusst, wie viel Text in das Feld eingegeben werden kann. Beachten Sie, dass diese Einstellung durch einzelne Formulare überschrieben werden kann. |
| Viewer-Sprache | |
| Ländereinstellung | Legt fest, welche Sprache vom Viewer verwendet wird. Diese Funktion übersetzt keine Formulare, stellt aber sicher, dass alle Elemente des Viewers in der ausgewählten Sprache angezeigt werden. |
| Sicherheitsoptionen | |
| Identitätsfilter für digitale Zertifikate | Filtert die Liste verfügbarer digitaler Zertifikate. Der Wert kann jeder Teil einer gültigen Signaturidentität sein, wie z. B. eine E-Mail-Adresse oder der Vorname. Alle Zertifikate, die dem eingegebenen Wert entsprechen, sind verfügbar. Wenn Sie z. B. "Bob" eingegeben haben, werden alle Zertifikate mit dem Namen "Bob" in der Signaturidentität verfügbar gemacht. Wählen Sie diese Option nur aus, wenn auf dem Computer digitale Zertifikate installiert sind, auf die nicht zugegriffen werden soll. |
| CRL-Verteilungspunkte überprüfen: | Zertifikatswiderrufslisten (CRLs) enthalten die Namen digitaler Zertifikate, die nicht mehr gültig sind. Wenn ein Formular signiert ist, überprüft der Viewer die zugehörigen lokal gespeicherten CRLs daraufhin, ob das Zertifikat gültig ist. Wählen Sie dieses Kontrollkästchen aus, damit der Viewer online CRLs überprüft. Wählen Sie dieses Kontrollkästchen nur aus, wenn der Viewer eine Verbindung zu den erforderlichen URLs herstellen kann. Wenn dieses Kontrollkästchen ausgewählt ist und der Computer nicht auf den erforderlichen URL zugreifen kann, tritt möglicherweise eine Verzögerung von bis zu 3 Minuten auf, während deren der Viewer nicht auf Anforderungen reagiert. |
Wenn Sie ein XFDL-Formular in eine HTML-Seite integrieren, deklarieren Sie, dass ein Abschnitt der Webseite von einem anderen Programm als dem Browser gesteuert wird, wie z. B. vom Viewer. Daher funktioniert dieser Abschnitt der Seite anders als die HTML-Seite, auf der er sich befindet.
Wenn z. B. ein Benutzer ein Formular auf einer Webseite ausfüllt, aber weitere Informationen dazu benötigt, klickt er möglicherweise auf einen Link auf der HTML-Seite, um eine neue Seite aufzurufen. Wenn ein Benutzer diese Aktion ausführt, gehen in der Regel alle in das Formular eingegebenen Daten verloren. Bei einem XFDL-Formular kann dieses Formular jedoch von der ersten Webseite abgehängt werden und zum Anzeigen auf einer zweiten Webseite bereitgestellt werden.
Wenn ein Formular von einer Webseite abgehängt und an eine andere angehängt wird, bleiben alle Benutzerdaten darin enthalten. Anders als die erste Webseite müssen nachfolgende Webseiten, auf denen dasselbe Formular angezeigt werden muss, das Formular nicht explizit integrieren. Wenn auf solchen Seiten dasselbe Formular angezeigt werden soll und die Benutzerdaten beibehalten werden sollen, müssen sie Objekte mit derselben detach_id enthalten.
Auf nachfolgenden Seiten muss nicht dasselbe Formular angezeigt werden. Auf einer zweiten Webseite kann ein anderes Formular angezeigt werden, wenn diese ein anderes Objekt enthält. Sie können Benutzer sogar auf eine andere Webseite umleiten, wenn sie zu lange brauchen, um ein Formular auszufüllen und das Zeitlimit des abgehängten Formulars überschritten wurde. Objekte, die ein Element vom Typ refresh_URL enthalten, stellen sicher, dass Benutzer zu einer anderen Webseite geleitet werden, wenn sie Unterstützung benötigen, oder zu einem neuen Formular, wenn sie das Ausfüllen des alten Formulars abbrechen.
Sobald der Viewer in eine HTML-Webseite integriert ist, können Sie ihn wie jedes andere HTML-Objekt behandeln. Sie können z. B. JavaScript™ sowie andere Portlets oder Servlets verwenden, um dynamischen Inhalt im Objekt oder im Formular zu generieren. Sie können auch neue XML-Instanzen für Ihr Formular generieren.
Das Implementieren des Viewers auf einer HTML-Seite ermöglicht es Ihnen, Formulare in einer Portalumgebung oder als Teil einer Serie von Webseiten anzuzeigen. Dadurch können Formulare dynamisch in Reaktion auf die Benutzerauswahl auf der HTML-Seite aktualisiert werden.
Zum Integrieren des Viewers müssen Sie zwei HTML-Elemente verwenden:
Das HTML-Objekt ist ein Platzhalter. Es gibt in der HTML-Datei die Position an, an der das Objekt in Relation zu den anderen Elementen auf der Webseite angezeigt wird. Sie könnten z. B. ein Objekt in eine HTML-Tabellenzelle setzen:
<tr>
<td>
<object>...</object>
</td>
</tr>
Das Scriptelement wird nicht als Teil der Webseite angezeigt und kann daher an beliebiger Stelle im HTML-Code platziert werden. Sie können Scripts direkt nach dem Objekt, dem sie zugeordnet sind, oder am Anfang oder Ende der Seite einfügen. Im folgenden Beispiel ist das Script mit dem Formular direkt nach der Tabelle mit dem Formularobjekt platziert:
</table>
<script>
... XFDL-Formular
</script>
Zum Integrieren eines Formulars in eine HTML-Seite müssen Sie wie folgt vorgehen:
Sie können ein Formular in eine beliebige HTML-Seite integrieren. Jedoch interpretiert jeder Browser den HTML-Code unterschiedlich. Wenn Sie wissen, dass alle Ihre Benutzer nur einen Browsertyp verwenden, können Sie den HTML-Code auf die Unterstützung dieses Browsers ausrichten. Wenn Ihre Benutzer aber mehrere Browsertypen verwenden, müssen Sie zusätzlichen Code erstellen, um sicherzustellen, dass alle Browser das integrierte Formular erkennen und anzeigen.
Wenn Sie nur einen Browsertyp unterstützen, können Sie ein einzelnes Objekt erstellen. Wenn Sie mehrere Browser unterstützen, müssen Sie das Objekt dynamisch mit JavaScript erstellen, wie in Mehrere Browser unterstützen dargestellt.
Mit dem Objektelement in HTML können Webseitendesigner Daten anzugeben, die von einem Browser-Plug-in wiedergegeben werden. IBM nutzt dieses Element zum Integrieren von XFDL-Formularen in eine Webseite. Mit dem Objektelement können Sie angeben, wie das Objekt implementiert wird, und Sie können die Position der Objektdaten angeben. Dies erfolgt über die folgenden Attribute:
Sie können den Anzeigebereich des Formulars auch mit Hilfe der folgenden optionalen Attribute ändern:
| Attribut | Browserunterstützung | Beschreibung |
|---|---|---|
| align | Alle | Legt die Position des Objekts innerhalb des zulässigen
Anzeigebereichs fest. Gültig sind die folgenden Einstellungen: left,
right und center.
Beispiel: <OBJECT align="center"> |
| border | Alle | Legt die Breite des Objektrahmens in Pixel fest.
Dieser Wert muss immer eine ganze Zahl sein. Beispiel: <OBJECT border="2"> |
| hspace | Alle | Legt fest, wie viel Leerraum (in Pixel) links und rechts neben
einem Objekt eingefügt wird. Wenn das Objekt einen Rahmen aufweist, befindet sich dieser zusätzliche
Leerraum außerhalb des Rahmens. Bei diesem Wert handelt es sich immer um eine ganze Zahl. Beispiel: <OBJECT hspace="2"> |
| vspace | Alle | Legt fest, wie viel Leerraum (in Pixel) über und unter einem
Objekt eingefügt wird. Wenn das Objekt einen Rahmen aufweist, befindet sich dieser
zusätzliche Leerraum außerhalb des Rahmens. Bei diesem Wert handelt es sich immer um eine ganze Zahl. Beispiel: <OBJECT hspace="2"> |
Im folgenden Beispiel werden dem Objekt ein eindeutiger Name, der auf das Active X-Steuerelement des Viewers verweist, und eine Größe zugeordnet.
<OBJECT id="unique_name" height="400" width="800"
classid="CLSID:354913B2-7190-49C0-944B-1507C9125367">
... Objekt Parameter
</OBJECT>
Objektattribute identifizieren das Objekt und legen seine Größe fest. Zum Angeben von Laufzeitwerten müssen Sie jedoch das Element param verwenden. Das Element param besteht aus Name-Wert-Paaren. Beispiel:
<PARAM NAME="XFDLID" VALUE="XFDLData">
Das Element "param" legt das Verhalten des Viewers und dessen Handhabung des integrierten Formulars fest. Es gibt sechs param-Elemente:
<PARAM NAME="XFDLID" VALUE="XFDLData">
<PARAM NAME="detach_id" VALUE="1234567890ABCD">
Aufeinander folgende Objekte mit demselben Formular müssen alle über dieselbe detach_id verfügen, wenn die Benutzerdaten seitenübergreifend beibehalten werden sollen. Wenn z. B. Formular A auf den HTML-Seiten 1 bis 4 angezeigt wird und das Formularobjekt auf Seite eins die detach_id 10236B aufweist, müssen die Formularobjekte auf den Seiten 2 bis 4 ebenfalls die detach_id 10236B aufweisen.
Wenn Sie eine detach_id angeben, müssen Sie dem Objekt auch eine Lebensdauer (TTL - Time To Live) zuordnen.
<PARAM NAME="refresh_URL"
VALUE="http://www.serv1/IRS/Sched22.htm">
<PARAM NAME="TTL" VALUE="15">
Wenn Sie einen Wert für TTL angeben, müssen Sie auch eine detach_id angeben.
Wenn Sie Dateninstanzen verwenden, können mehrere zusätzliche Werte enthalten sein:
Im folgenden Codemuster wird dargestellt, wie die Objektparameter definiert werden, wenn Sie neue XML-Daten am Ende einer vorhandenen XML-Datenmodellinstanz hinzufügen möchten:
<PARAM NAME="instance_1"
VALUE="new_Inst old_Inst append '[custom:rec][custom:name]'">
Im folgenden Codemuster wird dargestellt, wie die Objektparameter definiert werden, wenn Sie die vorhandene XForms-Dateninstanz durch eine neue ersetzen möchten:
<PARAM NAME="instance_1"
VALUE="new_Inst old_Inst xforms; replace="."">
Im folgenden Beispiel wird ein Objekt mit einem vollständigen Satz von param-Attributen zum Ersetzen einer XML-Datenmodellinstanz dargestellt.
<OBJECT...Objektattribute...>
<PARAM NAME="XFDLID" VALUE="theForm">
<PARAM NAME="TTL" VALUE="15">
<PARAM NAME="detach_id" VALUE="12354678901234567890">
<PARAM NAME="refresh_URL" VALUE="http://www.serv1/IRS/Sched22.htm">
<PARAM NAME="retain_Viewer" VALUE="on">
<PARAM NAME="instance_1" VALUE="newIns oldIns replace [0][0]">
</OBJECT>
Im folgenden Beispiel wird ein Objekt mit einem vollständigen Satz von param-Attributen zum Ersetzen einer XForms-Instanz dargestellt:
<OBJECT...Objektattribute...>
<PARAM NAME="XFDLID" VALUE="theForm">
<PARAM NAME="TTL" VALUE="15">
<PARAM NAME="detach_id" VALUE="12354678901234567890">
<PARAM NAME="refresh_URL" VALUE="http://www.serv1/IRS/Sched22.htm">
<PARAM NAME="retain_Viewer" VALUE="on">
<PARAM NAME="instance_1"
VALUE="new_Inst old_Inst xforms; replace="."">
</OBJECT>
Objekte enthalten oft mehrere Parameter. Daher muss der Viewer eine Ausführungspriorität befolgen, damit die Objektparameter immer auf konsistente Weise verarbeitet werden. Wenn eine neue Webseite mit einem Formularobjekt geöffnet wird, wird die folgende Ausführungspriorität verwendet, um zu bestimmen, was angezeigt wird:
Internet Explorer und Mozilla Firefox integrieren Objekte auf unterschiedliche und nicht kompatible Weise. Die beste Möglichkeit, beide Browser zu unterstützen, besteht in der Verwendung von JavaScript zum dynamischen Erstellen des Objekts in Abhängigkeit vom verwendeten Browser.
Die JavaScript-Technik wird im folgenden Beispiel dargestellt. Der Code besteht aus zwei Teilen. Beim ersten Teil handelt es sich um eine Funktionsdeklaration, die Sie in den HTML-Abschnitt "head" der Webseite setzen. Im Beispiel wird die Funktion als addViewer bezeichnet, Sie können ihr jedoch einen beliebigen Namen geben. Sie können diesen Teil des Codes ohne Änderungen kopieren.
Stellen Sie beim Ändern der Parameter sicher, dass nach jedem Parameter ein Komma gesetzt ist. Nach dem letzten Parameter ist kein Komma erforderlich.
<html>
<head>
<title>Embedded Form</title>
<script type="text/javascript">
function addViewer(containerDiv, tagID, _width, _height)
{
var parentDiv = document.getElementById(containerDiv);
var element = document.createElement('object');
for (var i = 4; i < arguments.length; i+=2) {
var param = document.createElement('param');
param.setAttribute('name', arguments[i]);
param.setAttribute('value',arguments[i+1]);
element.appendChild(param);
}
element.setAttribute('id',tagID);
element.setAttribute('height',_height);
element.setAttribute('width',_width);
if (navigator.appName == 'Microsoft Internet Explorer')
{
parentDiv.appendChild(element);
element.setAttribute('classid', 'clsid:354913B2-7190-49C0-944B-1507C9125367');
}
else
{
element.setAttribute('type', 'application/vnd.xfdl');
parentDiv.appendChild(element);
}
} </script>
<script language="XFDL" id="XFDLData" type="application/vnd.xfdl;
wrapped=comment;">
<!--
Hier werden die Formulardaten eingefügt
-->
</script>
</head>
<body>
<div id="viewer">
<script type="text/javascript">
addViewer (
"viewer", // id of the HTML div element
"CPClient", // id to assign to the object element
800, 400, // width and height of the Viewer
"XFDLID", "XFDLData", // name/value pair for XFDL param
"detach_id", value="2507088000" // name/value pair for detach_id param
/* weitere Parameter nach Bedarf. */
);
</script>
</div>
Hier wird der Inhalt der Webseite eingefügt
</body>
</html>
In HTML platziert ein Scriptelement ein Script auf einer HTML-Seite. Im Fall von XFDL-Formularen enthält das Script das Formular. Es gibt eine Anzahl von Attributen, die das Scriptelement ändern. Diese Attribute unterstützen den Viewer beim Erkennen des integrierten Formulars als gültiges XFDL. Dazu gehören die folgenden:
<SCRIPT language="XFDL">
<PARAM NAME="XFDLID" VALUE="XFDLData">
Dann muss die Script-ID wie folgt lauten:
<SCRIPT id="XFDLData">
<SCRIPT type="application/vnd.xfdl; wrapped=comment;
encoding=base64; next-chunk=Part2; content-encoding=utf-16">
Diese Parameter müssen durch ein Semikolon, gefolgt von einem Leerzeichen, getrennt werden.
Im folgenden Beispiel ist ein Tag zum Starten eines Scripts mit allen erforderlichen Attributen dargestellt:
<SCRIPT language="XFDL" id="XFDLData"
type="application/vnd.xfdl; wrapped=comment;">
...integriertes Formular...
</SCRIPT>
Im folgenden Beispiel wird ein kleines XFDL-Formular angezeigt, das in einem Kommentarwrapper enthalten ist:
<SCRIPT
Scriptattribute>
<!--
<?xml version="1.0"?>
<XFDL xmlns="http://www.ibm.com/xmlns/prod/XFDL/7.0"
xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom">
<globalpage sid="global">
<global sid="global">
<vfd_date>9/7/2004</vfd_date>
</global>
</globalpage>
<page sid="PAGE1">
<global sid="global">
<label>PAGE1</label>
</global>
<label sid="LABEL1">
<value>Dies ist ein kurzes Beispiel für ein Formular. </value>
</label>
</page>
</XFDL>
-->
</SCRIPT>
Sie können XML-Instanzen (XForms- oder XML-Datenmodell) mit XML-Daten, die Sie in Ihr Formular verschieben können, auf die Webseite aufnehmen. Diese XML-Daten können in dem Formular vorhandene XML-Daten ersetzen oder zu diesen hinzugefügt werden. Dies ist insbesondere für das dynamische Ausfüllen von Formularen mit vom Benutzer auf einer HTML-Seite ausgewählten Informationen nützlich.
Beispiel: Ein in eine HTML-Seite integriertes Bestellformular. Das XFDL-Formular ist ein allgemeines Bestellformular, das möglicherweise über ein Datenfragment mit Benutzerdaten personalisiert wird. Dieses Formular wird auf einer HTML-Seite (oder einer Serie von HTML-Seiten) angezeigt, auf der/denen Benutzer die Produkte, die sie kaufen möchten, auswählen können. Wenn Benutzer das gewünschte Produkt auswählen, lösen sie aus, dass der Anwendungsserver eine angepasste XML-Instanz erstellt, die die derzeit in dem XFDL-Formular vorhandene generische XML-Instanz ersetzt. Für Benutzer sieht es so aus, als würde das Formular automatisch mit den richtigen Einkaufsdaten, einschließlich Bestellnummer, Produkttyp und Preis, ausgefüllt.
Unabhängig davon, ob die XML-Instanz fest auf der HTML-Seite codiert ist oder von einem Anwendungsserver generiert wird, muss sie in einen Script-Container eingeschlossen sein. Wie bei einem Scriptelement, das ein XFDL-Formular enthält, müssen Sie die folgenden Attribute definieren:
<SCRIPT language="XFDL">
<OBJECT ... Objektattribute>
<PARAM NAME="instance_1"
VALUE="new_Instance old_Instance
append[custom:record][custom:name]">
... andere Parameter ...
</OBJECT>
Dann muss die Script-ID wie folgt lauten:
<SCRIPT id="new_Instance">
<SCRIPT type="application/vnd.xfdl; wrapped=comment">
Der Typ und die eingeschlossenen Parameter müssen durch ein Semikolon voneinander getrennt werden.
Im folgenden Beispiel ist ein Scriptelement mit einer XML-Instanz, die in einen Kommentarwrapper eingeschlossen ist, dargestellt.
<SCRIPT id="new_Instance" type="application/vnd.xfdl; wrapped=comment">
<!--
<name xmlns="http://www.ibm.com/xmlns/prod/XFDL/Custom">
Arnold Jevaston</name>
-->
</SCRIPT>
Formulare enthalten oft mehrere XML-Instanzen. Sie können sogar auf Datenfragmente, also häufig verwendete Abschnitte von XML-Daten, die auf Benutzercomputern gespeichert sind, verweisen. Wenn Ihr HTML Austauschinstanzen enthält oder wenn die Austauschinstanzen durch einen Anwendungsserver generiert werden, muss der Viewer eine Ausführungspriorität befolgen, damit sichergestellt ist, dass die Instanzen immer auf konsistente Weise geladen werden.
Wenn eine neue Webseite mit XML-Instanzen geöffnet wird, wird die folgende Ausführungspriorität verwendet, um zu bestimmen, was angezeigt wird:
Im folgenden Beispiel wird der gesamte Code angezeigt, der erforderlich ist, um ein Formular vollständig in den Internet Explorer oder in Firefox zu integrieren.
Dieses Beispiel enthält ein Objektelement, die Objektparameter, das Scriptelement und ein XFDL-Beispielformular, die in eine Kommentarstruktur eingeschlossen ist.
<OBJECT id="Object1" height="200" width="200" border="5"
classid="CLSID:354913B2-7190-49C0-944B-1507C9125367">
<PARAM NAME="XFDLID" VALUE="XFDLData">
<PARAM NAME="detach_id" VALUE="2507088000">
<PARAM NAME="refresh_url" VALUE="envAware.html">
<PARAM NAME="TTL" VALUE="17">
<PARAM NAME="retain_Viewer" VALUE="on">
</OBJECT>
<!--[if !IE]>
Mozilla 1.x, Firefox 1.x, Netscape 7+ und andere Browser verwenden das innere, verschachtelte Objekt
-->
<OBJECT ID="forMozillabrowser" height="300" width="800" border="5"
type="application/vnd.xfdl">
<PARAM NAME="XFDLID" VALUE="theForm2">
<PARAM NAME="detach_id" VALUE="2507088000">
<PARAM NAME="refresh_url" VALUE="envAware.html">
<PARAM NAME="TTL" VALUE="17">
<PARAM NAME="retain_Viewer" VALUE="on">
<PARAM NAME="instance_1" VALUE="newInst xforms; replace="."">
</OBJECT>
<!--<![endif]-->
</OBJECT>
<SCRIPT language="XFDL" id="XFDLData"
type="application/vnd.xfdl; wrapped=comment">
<!--
<?xml version="1.0"?>
<XFDL xmlns="http://www.ibm.com/xmlns/prod/XFDL/7.0"
xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom">
<globalpage sid="global">
<global sid="global">
<vfd_date>9/7/2004</vfd_date>
</global>
</globalpage>
<page sid="PAGE1">
<global sid="global">
<label>PAGE1</label>
</global>
<label sid="LABEL1">
<value>Dies ist ein kurzes Beispiel für ein Formular. </value>
</label>
</page>
</XFDL>
-->
</SCRIPT>
Im folgenden Beispiel wird der gesamte Code dargestellt, der erforderlich ist, um ein XForms-Formular vollständig zu integrieren und sowohl den Internet Explorer-Browser als auch den Firefox-Browser zu unterstützen. Zudem wird demonstriert, wie Chunking verwendet wird.
<html>
<head>
<title>Embed Form</title>
<script type="text/javascript">
function addViewer(containerDiv, tagID, _width, _height)
{
var parentDiv = document.getElementById(containerDiv);
var element = document.createElement('object');
for (var i = 4; i < arguments.length; i+=2) {
var param = document.createElement('param');
param.setAttribute('name', arguments[i]);
param.setAttribute('value',arguments[i+1]);
element.appendChild(param);
}
element.setAttribute('id',tagID);
element.setAttribute('height',_height);
element.setAttribute('width',_width);
if (navigator.appName == 'Microsoft Internet Explorer')
{
parentDiv.appendChild(element);
element.setAttribute('classid', 'clsid:354913B2-7190-49C0-944B-1507C9125367');
}
else
{
element.setAttribute('type', 'application/vnd.xfdl');
parentDiv.appendChild(element);
}
}
</script>
<script language="XFDL" id="XFDLData" type="application/vnd.xfdl;
wrapped=comment; next-chunk=chunk2">
<!--
<?xml version="1.0" encoding="UTF-8"?>
<XFDL xmlns="http://www.ibm.com/xmlns/prod/XFDL/7.1"
xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xforms="http://www.w3.org/2002/xforms">
<globalpage sid="global">
<global sid="global">
<xformsmodels>
<xforms:model>
<xforms:instance id="instance1" xmlns="">
<root>
<field_1></field_1>
<field_2></field_2>
<field_3></field_3>
</root>
</xforms:instance>
</xforms:model>
</xformsmodels>
</global>
</globalpage>
-->
</script>
<script language="XFDL" id="chunk2" type="application/vnd.xfdl;
wrapped=comment; next-chunk=chunk3">
<!--
<page sid="PAGE1">
<global sid="global">
<label>PAGE1</label>
</global>
<field sid="field1">
<xforms:input ref="field_1">
<xforms:label>Field with xforms:input</xforms:label>
</xforms:input>
</field>
<field sid="field2">
<xforms:textarea ref="field_2">
<xforms:label>Field with xforms:textarea</xforms:label>
</xforms:textarea>
<size>
<width>30</width>
<height>2</height>
</size>
</field>
-->
</script>
<script language="XFDL" id="chunk3" type="application/vnd.xfdl;
wrapped=comment">
<!--
<field sid="field3">
<xforms:secret ref="field_3">
<xforms:label>Field with xforms:secret</xforms:label>
</xforms:secret>
</field>
<spacer sid="vfd_spacer">
<itemlocation>
<x>250</x>
<y>250</y>
<width>1</width>
<height>1</height>
</itemlocation>
</spacer>
</page>
</XFDL>
-->
</script>
</head>
<body>
<div id="viewer">
<script type="text/javascript">
addViewer (
"viewer", // id of the HTML div element
"CPClient", // id to assign to the object element
800, 400, // width and height of the Viewer
"XFDLID", "XFDLData", // name/value pair for XFDL param
"detach_id", value="2507088000" // name/value pair for detach_id param
/* weitere Parameter nach Bedarf. */
);
</script>
</div>
</body>
</html>
Die Viewer-Funktionen ermöglichen Ihnen das Auslösen von Aktionen im Viewer. Die Viewer-Funktion "param" ermöglicht Ihnen das Aufrufen bestimmter Objektparameter in Berechnungen, die den Parameterwert zurückgeben. Wenn z. B. die Funktion "param" den XFDLID-Parameter des Objekts aufgerufen hat, gibt sie die XFDL-ID des Objekts zurück. Weitere Informationen hierzu finden Sie unter XFDL Specification.
Wenn Sie ein signiertes Formular in eine Webseite integrieren möchten, muss das Formular base64-gzip-verschlüsselt sein. Wenn der Internet Explorer ein signiertes integriertes Formular analysiert, fügt er möglicherweise zusätzliche Zeilenumbrüche zum Formular hinzu. Dies verhindert, dass das Formular dem Hashwert der Signatur entspricht, wodurch der Viewer deklariert, dass die Signatur des Formulars ungültig ist. Wenn signierte Formulare mit base64-gzip verschlüsselt werden, geschieht dies nicht.
Die einfachste Weise, ein XFDL-Formular zu verschlüsseln, besteht darin, es zu öffnen und es im Designer zu verschlüsseln.
Gehen Sie wie folgt vor, um ein Formular mit base64-gzip zu verschlüsseln:
Wenn Ihr Formular Zeichen außerhalb des ASCII-Bereichs (0-7F) enthält, muss die Zeichencodierung im XFDL-Formular der BSTR-Codierung entsprechen, die vom Browser an das Objekt mit dem Viewer übergeben wird. Die einfachste Weise, sicherzustellen, dass sie übereinstimmen, besteht darin, die Zeichencodierung nur im HTML-Formular anzugeben. Sie können sie in einen Meta-Tag in den HTML-Tag "head" setzen. Beispiel:
<META http-equiv="Content-Type" content="text/html;
charset=utf-8">
Außerdem müssen Sie die bereits in dem Formular angegebene Zeichencodierung entfernen. Da der Designer die Zeichencodierung automatisch hinzufügt, müssen Sie das Formular in einem anderen Texteditor, wie z. B. UltraEdit, Notepad oder TextPad, öffnen und die Codierung löschen.
Gehen Sie wie folgt vor, um die Zeichencodierung aus einem XFDL-Formular zu entfernen:
Unter bestimmten Umständen muss jedoch möglicherweise die Zeichencodierung im XFDL-Formular beibehalten werden. Ist dies der Fall, müssen Sie dennoch sicherstellen, dass die Formularcodierung der BSTR-Codierung entspricht. Wenn Sie eine Zeichencodierung in das Formular integrieren, muss sie daher immer wie folgt lauten:
Sie können die Zeichencodierung des Formulars nicht im Designer ändern. Sie müssen sie in einem anderen Texteditor, wie z. B. UltraEdit oder Notepad, bearbeiten.
Gehen Sie wie folgt vor, um die Zeichencodierung des Formulars zu ändern:
Sie können die IBM Forms-JavaScript-API für die Kommunikation zwischen einem Formular und einer Webseite verwenden. Die Webseite kann sich in einem XFDL-Element vom Typ "pane" oder in einem modalen Dialogfeld befinden.
In diesen Lerntexten wird beschrieben, wie Dojo-Widgets auf einer Webseite in einem XFDL-Formular verwendet werden und wie die JavaScript-API zum Übertragen von Daten zwischen dem Formular und der Webseite verwendet wird. Es wird zwar nur die Verwendung des Dojo-Toolkits beschrieben, Sie können die Technik aber für die Verwendung anderer Toolkits anpassen.
Abgesehen von geringfügigen Unterschieden bei den Dateipfaden sind die Formulare und Webseiten der Webform Server- und Viewer-Version der Lerntexte identisch. Die Unterschiede in den Dateipfaden kommen dadurch zustande, dass das mit Webform Server gelieferte Beispielservlet mit relativen URLs arbeitet. Es ist möglich, ein Servlet zu entwickeln, bei dem die Pfade gleich sind. Da jedoch der Lerntext auf dem Beispielservlet basiert, sind einige Anpassungen an den Dateipfaden erforderlich.
Wenn Ihre Formulare von Webform Server bereitgestellt werden, aber im Viewer in eine HTML-Seite integriert angezeigt werden, befolgen Sie den Lerntext für Webform Server.
In diesem Lerntext lernen Sie, wie eine Webseite in ein Formular integriert wird. Die Webseite enthält ein Dojo-Schiebeleistenwidget. Wenn sich der Wert des Schiebeleistenwidgets ändert, wird der neue Wert in eine Beschriftung im Formular eingefügt.
Das Projekt, das Sie in diesem Lerntext erstellen, besteht aus zwei Dateien. Bei der einen Datei handelt es sich um ein einfaches XFDL-Formular, das Daten, ein Teilfenster und eine Beschriftung enthält. Bei der anderen Datei handelt es sich um eine Webseite, die eine Dojo-Schiebeleistensteuerung implementiert und im Teilfenster angezeigt wird. Auf der Webseite wird die IBM Forms-JavaScript-API verwendet, um Daten zwischen der Schiebeleistensteuerung und dem Formular zu übertragen.
Die Webseite wird beim Öffnen des Formulars geladen. Ein Script auf der Webseite kopiert den Schiebeleistenwert aus dem XForms-Modell in die Schiebeleistensteuerung. Wenn Sie den Wert der Schiebeleiste ändern, kopiert das Script den neuen Wert in das XForms-Modell, wodurch die Beschriftung aktualisiert wird.
Die erste Task besteht darin, zu überprüfen, ob Sie die richtigen Dateien auf dem Computer installiert haben. Anschließend erstellen Sie das XFDL-Formular, das die Webseite enthält. Nach dem Erstellen des Formulars erstellen Sie die Webseite, die im Formular angezeigt wird. Zuletzt implementieren und verwenden Sie das Formular.
Um zu vermeiden, dass beim Durcharbeiten des Lerntexts Probleme auftreten, stellen Sie sicher, dass sich das Dojo-Toolkit an der richtigen Position befindet und dass sich die entsprechenden Unterstützungsdateien an der richtigen Position befinden.
Die Ordnerstruktur, die Sie in diesem Lerntext erstellen, ist nur eine von mehren gültigen Strukturen. Sie können nach Wunsch eine andere Struktur verwenden, müssen dann aber die Dateipfade in Ihrem XFDL-Formular und auf den HTML-Seiten anpassen, sodass sie der Struktur entsprechen.
Sie können das Dojo-Toolkit von der Dojo-Website herunterladen oder Sie können die in Webform Server enthaltene Version verwenden. Wenn Sie über Webform Server verfügen, suchen Sie die Datei dojo.ibm.standard-1.4.3-20100331.zip unter C:\Programme\IBM\Forms Server\4.0\WebformServer\redist.
HTMLPane\dojo\dijit HTMLPane\dojo\dojo HTMLPane\dojo\dojox HTMLPane\JavaScript
Das Formular erstellt eine Beschriftung und ein Teilfenster. Das Formular enthält zudem ein XForms-Modell, das den Wert für die Beschriftung und für die Schiebeleistensteuerung liefert.
In diesem Stadium des Lerntexts erstellen Sie ein XFDL-Formular, das ein Teilfenster enthält. Im Teilfenster wird die Webseite angezeigt, die Sie in einem späteren Stadium erstellen.
Die vollständige Datei sieht wie folgt aus:
<?xml version="1.0" encoding="UTF-8"?>
<XFDL xmlns="http://www.ibm.com/xmlns/prod/XFDL/8.0"
xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/8.0"
xmlns:xforms="http://www.w3.org/2002/xforms">
<globalpage sid="global">
<global sid="global">
<xformsmodels>
<xforms:model>
<xforms:instance xmlns="" id="slider-value">
<data>
<slider>4</slider>
</data>
</xforms:instance>
</xforms:model>
</xformsmodels>
</global>
</globalpage>
<page sid="PAGE1">
<global sid="global">
<label>HTML in pane</label>
</global>
<label sid="LABEL1">
<value>Viewer HTML in pane Tutorial</value>
</label>
<label sid="LABEL2">
<xforms:output ref="instance('slider-value')/slider">
<xforms:label>Value of slider: </xforms:label>
</xforms:output>
<itemlocation>
<below>LABEL1</below>
</itemlocation>
</label>
<pane sid="PANE1">
<xforms:group ref="instance('slider-value')/slider">
<label sid="PANE1_LABEL1">
<value>This is printed.</value>
</label>
<spacer sid="vfd_spacer">
<itemlocation>
<x>300</x>
<y>40</y>
</itemlocation>
</spacer>
</xforms:group>
<!-- The file must be in the same folder as the XFDL form -->
<url>TutorialHTMLPane.html</url>
</pane>
</page>
</XFDL>
In diesem Stadium des Lerntexts erstellen Sie die Webseite für das Formular.
Die Webseite enthält einen kurzen JavaScript-Abschnitt, der die IBM Forms-JavaScript-API verwendet, um den Wert des Elements <slider> aus dem XForms-Modell abzurufen. Der Wert wird zum Anfangswert der Schiebeleistensteuerung. Wenn Sie die Schiebeleiste ändern, aktualisiert das Script das Element <slider> im XForms-Modell.
Die vollständige Datei sieht wie folgt aus:
<html>
<head>
<link href="dojo/dijit/themes/nihilo/nihilo.css" rel="stylesheet" type="text/css">
<link href="dojo/dojo/resources/dojo.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="dojo/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
<script type="text/javascript" src="JavaScript/LF_FormNodeP.js"></script>
<script type="text/javascript" src="JavaScript/LF_XFDL.js"></script> <script type="text/javascript">
dojo.require("dijit.form.Slider");
dojo.addOnLoad(function() {
/* get the value of the field in the form and assign it to the variable
initvalue. The extractXFormsInstance method from the IBM Forms
JavaScript API returns a string in this format: "<slider>n</slider>"
where n is a number */
var initvalue = XFDL.getCurrentForm().extractXFormsInstance(null,
"instance('slider-value')/slider", true, true, null);
// use a regular expression to extract the number from initvalue
initvalue = initvalue.match(/\d+/);
// set up the Dojo slider
var sliderRules = new dijit.form.HorizontalRule({
count: 10,
style: "height:5px;"
},
"sliderrules");
var slider = new dijit.form.HorizontalSlider({
name: "slider",
value: initvalue,
minimum: 1,
maximum: 10,
discreteValues: 10,
style: "width:300px;",
onChange: function(value) {
// update the XForms model when the slider value changes
XFDL.getCurrentForm().updateXFormsInstance(null,
"instance('slider-value')/slider",
null, value.toString(),
XFDL.UFL_XFORMS_UPDATE_REPLACE_TEXT);
}
},
"slider");
});
</script>
</head>
<body class="nihilo">
<div id="slider">
<div id="sliderrules"></div>
<ol dojoType="dijit.form.HorizontalRuleLabels" container="bottomDecoration"
style="height:1.5em;font-size:75%;color:gray;">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
</ol>
</div>
</body>
</html>
Öffnen Sie nach dem Erstellen des Formulars und der Webseite das Formular im Viewer.
Gehen Sie wie folgt vor, um die HTML im Teilfensterprojekt zu verwenden:
In diesem Lerntext lernen Sie, wie eine wechselseitige Übertragung zwischen einer HTML-Webseite im modalen Dialogfeld und einem XFDL-Formular implementiert wird.
Das Projekt, das Sie in diesem Lerntext erstellen, besteht aus zwei Dateien. Bei der einen Datei handelt es sich um ein einfaches XFDL-Formular, das Daten, eine Beschriftung und eine Schaltfläche enthält. Bei der anderen Datei handelt es sich um eine Webseite, die eine Dojo-Schiebeleistensteuerung implementiert und im modalen Dialogfeld angezeigt wird. Auf der Webseite wird die IBM Forms-JavaScript-API verwendet, um Daten zwischen der Schiebeleistensteuerung und dem Formular zu übertragen.
Wenn Sie auf die Schaltfläche im Formular klicken, wird das modale Dialogfeld geöffnet und die Webseite wird geladen. Ein Script auf der Webseite kopiert den Wert aus dem XForms-Modell in die Schiebeleistensteuerung. Wenn Sie im modalen Dialogfeld auf Update Form (Formular aktualisieren) klicken, kopiert das Script den Wert der Schiebeleistensteuerung in das XForms-Modell, wodurch der Wert, der im Feld angezeigt wird, aktualisiert wird.
Die erste Task besteht darin, zu überprüfen, ob Sie die richtigen Dateien auf dem Computer installiert haben. Anschließend erstellen Sie das XFDL-Formular, das das modale Dialogfeld öffnet. Nach dem Erstellen des Formulars erstellen Sie die Webseite, die im modalen Dialogfeld geöffnet wird. Zuletzt implementieren und verwenden Sie das Projekt für das modale Dialogfeld.
Um zu vermeiden, dass beim Durcharbeiten des Lerntexts Probleme auftreten, stellen Sie sicher, dass sich das Dojo-Toolkit an der richtigen Position befindet und dass sich die entsprechenden Unterstützungsdateien an der richtigen Position befinden.
Die Ordnerstruktur, die Sie in diesem Lerntext erstellen, ist nur eine von mehren gültigen Strukturen. Sie können nach Wunsch eine andere Struktur verwenden, müssen dann aber die Dateipfade in Ihrem XFDL-Formular und auf den HTML-Seiten anpassen, sodass sie der Struktur entsprechen.
Sie können das Dojo-Toolkit von der Dojo-Website herunterladen oder Sie können die in Webform Server enthaltene Version verwenden. Wenn Sie über Webform Server verfügen, suchen Sie die Datei dojo.ibm.standard-1.4.3-20100331.zip unter C:\Programme\IBM\Forms Server\4.0\WebformServer\redist.
ModalDialog\dojo\dijit ModalDialog\dojo\dojo ModalDialog\dojo\dojox ModalDialog\JavaScript
Das Formular enthält eine Beschriftung, eine Schaltfläche und ein Feld. Das Formular enthält zudem ein XForms-Modell, das den Wert für das Feld liefert.
Stellen Sie, bevor Sie beginnen, sicher, dass Sie die Umgebung durch Erstellen der Ordnerstruktur und Kopieren der Dojo-Dateien und der JavaScript-API-Dateien konfiguriert haben.
Über die Schaltfläche wird das modale Dialogfeld mithilfe der XFDL-Funktion viewer.launchModalDialog geöffnet.
In einem späteren Stadium des Lerntexts erstellen Sie die Webseite für das modale Dialogfeld. Die Webseite enthält einen kurzen JavaScript-Abschnitt, der die IBM Forms-JavaScript-API verwendet, um den Wert des Elements <slider> von der XForms-Instanz abzurufen. Der Wert wird zum Anfangswert der Schiebeleistensteuerung. Wenn auf die Schaltfläche Update Form (Formular aktualisieren) auf der Webseite geklickt wird, aktualisiert das Script das Element <slider> im Formular, bevor das modale Dialogfeld geschlossen wird.
Die vollständige Datei sieht wie folgt aus:
<?xml version="1.0" encoding="UTF-8"?>
<XFDL xmlns="http://www.ibm.com/xmlns/prod/XFDL/8.0"
xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom"
xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/8.0"
xmlns:xforms="http://www.w3.org/2002/xforms">
<globalpage sid="global">
<global sid="global">
<xformsmodels>
<xforms:model>
<xforms:instance id="slider-value" xmlns="">
<data>
<slider>9</slider>
</data>
</xforms:instance>
</xforms:model>
</xformsmodels>
</global>
</globalpage>
<page sid="PAGE1">
<global sid="global">
<label>Modal Dialog</label>
</global>
<label sid="LABEL1">
<value>Modal Dialog Tutorial</value>
</label>
<button sid="BUTTON1">
<value>Open Modal Dialog</value>
<layoutflow>block</layoutflow>
<custom:option xfdl:compute="toggle(activated, 'off', 'on') == '1' ?
viewer.launchModalDialog('TutorialModalDialog.html', '',
'380', '200', 'false', 'false') : ''"></custom:option>
</button>
<field sid="FIELD1">
<xforms:input ref="instance('slider-value')/slider">
<xforms:label></xforms:label>
</xforms:input>
<size>
<width>2</width>
</size>
<justify>right</justify>
<value></value>
</field>
</page>
</XFDL>
In diesem Stadium des Lerntexts erstellen Sie die Webseite für das modale Dialogfeld.
Die Webseite enthält einen kurzen JavaScript-Abschnitt, der die IBM Forms-JavaScript-API verwendet, um den Anfangswert der Schiebeleistensteuerung abzurufen. Wenn auf die Schaltfläche Update Form (Formular aktualisieren) auf der Webseite geklickt wird, aktualisiert das Script das Element "slider" im Formular, bevor das modale Dialogfeld geschlossen wird.
Die vollständige Datei sieht wie folgt aus:
<html>
<head>
<link href="dojo/dijit/themes/nihilo/nihilo.css"
rel="stylesheet" type="text/css">
<link href="dojo/dojo/resources/dojo.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="dojo/dojo/dojo.js" djConfig="parseOnLoad:
true"></script>
<script type="text/javascript" src="JavaScript/LF_FormNodeP.js"></script>
<script type="text/javascript" src="JavaScript/LF_XFDL.js"></script> <script type="text/javascript">
dojo.require("dijit.form.Slider");
dojo.require("dijit.form.TextBox");
dojo.addOnLoad(function() {
// get the value of the field in the form, and assign it to the variable
// initvalue. The extractXFormsInstance method from the IBM Forms
// JavaScript API returns a string in this format:
// "<slider>n</slider>" where n is a number
var initvalue = XFDL.getCurrentForm().extractXFormsInstance(null,
"instance('slider-value')/slider", true, true, null);
// use a regular expression to extract the number from initvalue
initvalue = initvalue.match(/\d+/);
// set up the Dojo slider
var sliderRules = new dijit.form.HorizontalRule({
count: 10,
style: "height:5px;"
},
"sliderrules");
var slider = new dijit.form.HorizontalSlider({
name: "slider",
value: initvalue,
minimum: 1,
maximum: 10,
discreteValues: 10,
style: "width:300px;",
onChange: function(value) {
dojo.byId("sliderValue").value = value;
}
},
"slider");
dojo.byId("sliderValue").value = slider.value;
});
function update()
{
// Use the updateXFormsInstance method from the IBM Forms
// JavaScript API to update the form
XFDL.getCurrentForm().updateXFormsInstance(null,
"instance('slider-value')/slider",
null, dojo.byId("sliderValue").value,
XFDL.UFL_XFORMS_UPDATE_REPLACE_TEXT);
}
function cancel()
{
XFDL.getCurrentForm().getDialog().close();
}
</script>
</head>
<body class="nihilo">
<div style="position:absolute;left:34px;top:30px;width:302px;height:150px">
<div id="slider">
<div id="sliderrules"></div>
<ol dojoType="dijit.form.HorizontalRuleLabels" container="bottomDecoration"
style="height:1.5em;font-size:75%;color:gray;">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
</ol>
</div>
<table>
<tr>
<td style="text-align:center;width:318px;height:38px;">Selected Value:
<label style="width:30px" id="sliderValue"
dojoType="dijit.form.TextBox"></label>
</td>
</tr>
<tr>
<td style="text-align:center;width:318px;height:38px;">
<button onclick="javascript:update();">Update Form</button>
<button onclick="javascript:cancel();">Close</button>
</td>
</tr>
</table>
</div>
</body>
</html>
Öffnen Sie nach dem Erstellen des Formulars und der Webseite das Formular im Viewer.
Gehen Sie wie folgt vor, um das Projekt für das modale Dialogfeld zu verwenden:
The IBM Forms Server – JavaScript API is a collection of tools that allow you to programmatically interact with XFDL forms on web pages.
The API gives you direct access to an entire form and all of its nodes. The API has functions that allow you to manipulate the properties of fields, labels, lists, and other controls. You can retrieve information from a form that is embedded in a Web page, manipulate it with your own JavaScript code, and then insert it back into the same form or into another form on the same Web page. Furthermore, you can get information about the digital signatures on the form (if any), and verify that the signatures are valid.
The forms can be displayed by IBM Forms Viewer or by IBM Forms Server – Webform Server. For the most part, whether your form is hosted by the Viewer or by Webform Server, the use of the API is identical.
There are two sources of exceptions that can occur. One source is the JavaScript code, and the other is the underlying form processing code in the Viewer or on the Webform Server server.
JavaScript errors are handled in the normal fashion. That is, you can keep the default browser behavior, or you can use JavaScript try-catch blocks to intercept these errors.
Exceptions thrown by the underlying processing code are intercepted by the error handling mechanism of the JavaScript API. These exceptions are either displayed as an error in a JavaScript alert box, or passed to a custom exception handler that you write to handle the exception. You register the custom function using the API method XFDL.registerAPIExceptionHandler. Note that because these types of exceptions are intercepted, you cannot catch them inside a normal JavaScript try-catch block.
Both the Viewer and Webform Server implement the JavaScript API, but you might need to adjust your application design if you are using Webform Server.
When the form is rendered in the Viewer, the Viewer handles calls made into the JavaScript API. When the form is rendered by Webform Server as HTML, the JavaScript API calls are sent over the Internet and executed on the server. This arrangement imposes design limitations on applications that access the JavaScript API.
Web page loading: Your JavaScript code must not use the API until the form is completely loaded into the browser and registered by Webform Server. However, you cannot depend on the Web browser to load the various sections of a page in the correct order. This means that you cannot be sure that the form is properly loaded and registered before your JavaScript application tries to access it.
If you are using portlets, you can solve the problem by creating two portlets. One portlet contains a button that the user must click to initialize the JavaScript application. The other portlet contains the form. The technique is described in Portlet scenario.
If you are using a servlet, you can solve the problem by separating your web page into frames, as described in Servlet scenario. Use the onload event of the frameset element to initialize the API; the onload event of the frameset does not fire until all frames are completely loaded.
Web page reloading: Although Webform Server makes extensive use of AJAX, it must still reload the entire page from time to time. When a page is reloaded, the JavaScript state information is lost; variables are reset and any data in memory is destroyed.
You can prevent page reloads by avoiding changes to the XFDL form options that are updated by automatic refresh. These options are listed in Supported XFDL options. A compute on a form that changes one or more of these options will also trigger a page reload.
If you are using portlets, then you must either avoid changing the values of the listed options, or take steps to preserve the state of your JavaScript application across page reloads.
If you are using servlets, you can separate your web page into HTML frames. One frame contains the JavaScript application and another frame contains the form supplied as HTML by Webform Server. In this case, Webform Server can reload the frame without resetting your JavaScript application. The technique is described in Servlet scenario.
This section contains a tutorial to help you understand how to use the JavaScript API. By working through the tutorial, you will perform all of the steps involved in creating an application that uses the API.
The sample application is for demonstration purposes only and is not to be used in production. It is intended as a guide to help you use the JavaScript API. It is not intended to demonstrate best practices for form deployment.
The form that is used in the sample applications is the Calculate Age form, which was originally intended as a simple example for basic server-side processing of forms in C and Java™. It accepts data but does not process it. Using this form as a base, you will create an interactive application that displays a person's age given a birth date and the current date. You will do that without modifying the form itself; everything will be done via the JavaScript API.
Use a Web server to deliver a form for display in the Viewer.
First, you must create the HTML file that will contain both the form and the JavaScript code that manipulates the form. Initially, you will only embed the form so that you can test to make sure that it opens properly in the Viewer.
To embed the form:
When you have the form displayed in your browser, change one or more of the fields. When you change a value, the Age field is not updated, but this is the expected behavior for this form. As mentioned previously, it was originally intended for demonstrating server-side processing of completed forms. Normally, this form would be processed on the server using either the C or Java API. In this case though, you want to make the form interactive without redesigning it.
The next step is to register the form with the API.
<script type="text/javascript">
var objectID = "Main";
// this must be "OnLoadForm" or IE will have error on page
function OnLoadForm () {
try {
var theForm = new FormNodeP(objectID);
XFDL.registerForm(theForm, objectID);
} catch (error) {
alert("Could not register the form\n" + error);
return;
}
}
</script>
var formMain = ibmForms[objectID];
Now you are ready to add the JavaScript.
In this section, you add the JavaScript code that interacts with the form. In the final step, you add a heading, a button, and an empty paragraph in the HTML body.
To add the JavaScript code:
When you open the file, notice the changes to the form. Click the "Insert Today's Date" button and change the values of one or more fields. You have turned an old, static form into a simple interactive application.
The entire file, including the Calculate Age XFDL form, is shown in The complete application.
<html>
<head>
<script type="text/javascript" src="LF_XFDL.js"></script>
<script type="text/javascript" src="LF_FormNodeP.js"></script>
<script type="text/javascript" src="LF_ViewerScript.js"></script>
<script language="XFDL" id="XFDLData" type="application/vnd.xfdl; wrapped=comment">
<!--
<?xml version="1.0" encoding="UTF-8"?>
<XFDL xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom"
xmlns:designer="http://www.ibm.com/xmlns/prod/workplace/forms/designer/2.6"
xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/7.0"
xmlns="http://www.ibm.com/xmlns/prod/XFDL/7.0">
<globalpage sid="global">
<global sid="global">
<label>Calculate Age Input</label>
<transmitformat>application/vnd.xfdl</transmitformat>
<saveformat>application/vnd.xfdl</saveformat>
<designer:date>12/3/98</designer:date>
<printsettings>
<dialog>
<copies>1</copies>
</dialog>
</printsettings>
<formid>
<version>1.5.3</version>
</formid>
</global>
</globalpage>
<page sid="PAGE1">
<global sid="global">
<designer:pagesize>960;1260</designer:pagesize>
</global>
<label sid="TITLE">
<value>Calculate Age 
Input Form</value>
<fontinfo>
<fontname>Helvetica</fontname>
<size>14</size>
<effect>bold</effect>
</fontinfo>
<itemlocation>
<x>17</x>
<y>12</y>
</itemlocation>
<fontcolor>0,0,0</fontcolor>
<justify>left</justify>
</label>
<label sid="NAMELABEL">
<value>Name:</value>
<itemlocation>
<x>19</x>
<y>178</y>
</itemlocation>
</label>
<field sid="NAMEFIELD">
<value>Jane E. Smith</value>
<itemlocation>
<x>74</x>
<y>178</y>
<width>166</width>
<height>22</height>
</itemlocation>
</field>
<label sid="BIRTHLABEL">
<value>Date of Birth:</value>
<itemlocation>
<x>19</x>
<y>227</y>
</itemlocation>
</label>
<field sid="BIRTHYEAR">
<label>Year</label>
<value>1972</value>
<format>
<datatype>integer</datatype>
<presentation>
<groupingseparator>none</groupingseparator>
</presentation>
</format>
<size>
<width>6</width>
<height>1</height>
</size>
<itemlocation>
<x>141</x>
<y>206</y>
</itemlocation>
</field>
<field sid="BIRTHMONTH">
<label>Month</label>
<value>9</value>
<format>
<datatype>month</datatype>
<constraints>
</constraints>
<presentation>
<style>short</style>
</presentation>
</format>
<size>
<width>4</width>
<height>1</height>
</size>
<itemlocation>
<x>210</x>
<y>206</y>
</itemlocation>
</field>
<field sid="BIRTHDAY">
<label>Day</label>
<value>14</value>
<format>
<datatype>day_of_month</datatype>
</format>
<size>
<width>4</width>
<height>1</height>
</size>
<itemlocation>
<x>268</x>
<y>206</y>
</itemlocation>
</field>
<label sid="SHOWAGE">
<itemlocation>
<x>73</x>
<y>328</y>
</itemlocation>
<value compute="
PAGE1.HIDDENYEAR.value == '' ? 'run calculateAge and see output.xfd' 

: ((PAGE1.CURRENTMONTH.value > PAGE1.BIRTHMONTH.value) or 

! ( ! (PAGE1.CURRENTMONTH.value == PAGE1.BIRTHMONTH.value) or 

! (PAGE1.CURRENTDAY.value > PAGE1.BIRTHDAY.value)) 

? PAGE1.CURRENTYEAR.value - PAGE1.BIRTHYEAR.value 

: PAGE1.CURRENTYEAR.value - PAGE1.BIRTHYEAR.value - '1')

">run calculateAge and see output.xfd
</value>
</label>
<label sid="DATELABEL">
<value>Today's date:</value>
<fontcolor>0,0,0</fontcolor>
<itemlocation>
<x>19</x>
<y>282</y>
<width>83</width>
<height>23</height>
</itemlocation>
</label>
<field sid="CURRENTYEAR">
<label>Year</label>
<value>2001</value>
<format>
<datatype>integer</datatype>
<presentation>
<groupingseparator>none</groupingseparator>
</presentation>
</format>
<size>
<width>6</width>
<height>1</height>
</size>
<itemlocation>
<x>141</x>
<y>262</y>
</itemlocation>
</field>
<field sid="CURRENTMONTH">
<label>Month</label>
<value>9</value>
<format>
<datatype>month</datatype>
<constraints>
</constraints>
<presentation>
<style>short</style>
</presentation>
</format>
<size>
<width>4</width>
<height>1</height>
</size>
<itemlocation>
<x>210</x>
<y>262</y>
</itemlocation>
</field>
<field sid="CURRENTDAY">
<label>Day</label>
<value>13</value>
<format>
<datatype>day_of_month</datatype>
</format>
<size>
<width>4</width>
<height>1</height>
</size>
<itemlocation>
<x>268</x>
<y>262</y>
</itemlocation>
</field>
<label sid="LABEL1">
<itemlocation>
<x>15</x>
<y>78</y>
</itemlocation>
<value>This is a demonstration of the Calculate Age application
presented in the IBM(R) IBM(R) Forms Server - API Installation & Setup Guide.

Fill out and save this input form. Run the Calculate Age application.
View the results in the output form called "output.xfd".</value>
<fontinfo>
<fontname>Helvetica</fontname>
<size>8</size>
<effect>plain</effect>
</fontinfo>
<justify>left</justify>
</label>
<field sid="HIDDENYEAR">
<itemlocation>
<x>343</x>
<y>181</y>
<width>51</width>
<height>22</height>
</itemlocation>
<value></value>
<visible>off</visible>
</field>
<field sid="HIDDENMONTH">
<itemlocation>
<x>344</x>
<y>216</y>
<width>49</width>
<height>22</height>
</itemlocation>
<value></value>
<visible>off</visible>
</field>
<field sid="HIDDENDAY">
<itemlocation>
<x>344</x>
<y>248</y>
<width>50</width>
<height>23</height>
</itemlocation>
<value></value>
<visible>off</visible>
</field>
<label sid="AGELABEL">
<itemlocation>
<x>19</x>
<y>327</y>
<width>38</width>
<height>24</height>
</itemlocation>
<value>Age:</value>
</label>
<spacer sid="vfd_spacer">
<itemlocation>
<x>420</x>
<y>360</y>
<width>1</width>
<height>1</height>
</itemlocation>
</spacer>
</page>
</XFDL>
-->
</script>
<script type="text/javascript">
var objectID = "Main";
window.onload = OnLoadForm;
function OnLoadForm() {
try {
var theForm = new FormNodeP(objectID);
XFDL.registerForm(theForm, objectID);
} catch (error) {
alert("Could not register the form\n" + error);
return;
}
try {
// put any value in the HIDDENYEAR field, which activates the compute
ibmForms[objectID].setLiteralByRefEx(null, "PAGE1.HIDDENYEAR.value",
0, null, "trigger compute");
// set up a couple of OnChange events
var age = ibmForms[objectID].dereferenceEx(null, "PAGE1.SHOWAGE", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
age.addOnChange(showMessage);
var name = ibmForms[objectID].dereferenceEx(null, "PAGE1.NAMEFIELD", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
name.addOnChange(showMessage);
// change the form labels
changeForm();
// update the result message
showMessage();
} catch (error) {
alert("Could not set up custom form\n\n" + error);
}
}
function showMessage(xfdlEvent) {
var theForm = ibmForms[objectID];
var s;
try {
s = theForm.getLiteralByRefEx(null, "PAGE1.NAMEFIELD.value", 0, null);
s += " is " + theForm.getLiteralByRefEx(null, "PAGE1.SHOWAGE.value", 0, null) + " years old."
document.getElementById("message").innerHTML = s;
} catch (error) {
alert("Can't show message\n" + error);
}
}
function changeForm() {
var theForm = ibmForms[objectID];
var s;
try {
s = "Calculate a Person's Age";
theForm.setLiteralByRefEx(null, "PAGE1.TITLE.value", 0, null, s);
s = "This is a simple form that calculates a person's age.\n";
s += "The age is updated whenever one of the values is changed.\n\n"
s += "Click on the 'Insert Today's Date' button to insert today's date.";
theForm.setLiteralByRefEx(null, "PAGE1.LABEL1.value", 0, null, s);
} catch (error) {
alert("Could not change one or more labels on the form\n" + error);
}
}
function insertToday() {
var theForm = ibmForms[objectID];
var today = new Date();
try {
theForm.setLiteralByRefEx(null, "PAGE1.CURRENTYEAR.value", 0, null,
today.getFullYear().toString());
theForm.setLiteralByRefEx(null, "PAGE1.CURRENTMONTH.value", 0, null,
(today.getMonth()+1).toString());
theForm.setLiteralByRefEx(null, "PAGE1.CURRENTDAY.value", 0, null,
today.getDate().toString());
} catch (ex) {
alert("Failed to set today's date.\n" + ex);
}
}
</script>
</head>
<body>
<h3>JavaScript API Sample</h3>
<div id="viewer">
<script type="text/javascript">
addViewer (
"viewer", // id of the HTML div element
objectID, // id to assign to the object element
500, 400, // width and height of the Viewer
"XFDLID", "XFDLData", // name-value pair for XFDL param
"detach_id", "2507088000" // name-value pair for detach_id param
);
</script>
</div>
<input type="button" value="Insert Today's Date" onClick="insertToday();"/>
<div style="width:200px;margin-top:10px;padding:5px;border:solid blue thin">
<p id="message"></p>
</div>
</body>
</html>
You also learned how to register a form and then access it through the global array ibmForms[].
Contains the methods that manipulate forms. This is the primary object that you use for adding, revising, deleting, and validating form content.
Each XFDL element in a form corresponds to a FormNodeP object. The API represents a form in memory as a DOM-like tree structure, with a FormNodeP object at each node, including the root node.
<script type="text/javascript" src="LF_FormNodeP.js"></script>
This method adds a namespace declaration to the node it is called on. Each namespace is defined in the form using the XML xmlns namespace declaration as shown in these two sample declarations:
xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/7.7" xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom"
Each namespace declaration defines a prefix and a URI for the namespace. In the samples shown, the prefix for the XFDL namespace is xfdl and the URI is http://www.ibm.com/xmlns/prod/XFDL/7.7. The prefix for the custom namespace is custom and the URI is http://www.ibm.com/xmlns/prod/XFDL/Custom.
Tags within the form are assigned specific namespaces by using the defined prefix. For example, to declare that an option is in the custom namespace, use the prefix custom as shown:
<field sid="testField">
<custom:custom_option>value</custom:custom_option>
</field>
| Expression | Type | Description |
|---|---|---|
| uri | String | The namespace URI. For example: http://www.ibm.com/xmlns/prod/XFDL/7.7 |
| prefix | String | The prefix for the namespace. For example, xfdl. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample function adds a new namespace to the form that is passed in. It also adds a namespace with the prefix "myspace" to the PAGE1.FIELD1 node on the form.
function AddNamespace(theForm) {
var s;
var fieldNode;
s = "--- Results of addNamespace test ---\n";
theForm.addNamespace("http://www.example.com/xmlns/newspace", "news");
s += " Namespace added to form.\n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.FIELD1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(fieldNode == null) {
s += " Could not locate FIELD1 node.\n";
} else {
fieldNode.addNamespace("http://www.example.com/xmlns/myspace", "myspace");
s += " Namespace added to PAGE1.FIELD1.\n";
}
alert(s);
}
--- Results of addNamespace test --- Namespace added to form. Namespace added to PAGE1.FIELD1.
void addOnBlur ( Function handler );
| Expression | Type | Description |
|---|---|---|
| handler | Function | The name of the function that will be called when the onBlur event occurs. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code adds an onBlur event handler to BUTTON1. The event handler is given the name button1OnBlur, but you can use any name that you want. The event handler displays the type of event and the local name of the source node.
function registerButtonEvent(theForm) {
var buttonNode;
var s;
s = "- Results of registerButtonEvent function call -\n";
buttonNode = theForm.dereferenceEx(null, "PAGE1.BUTTON1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(buttonNode == null) {
s += " Could not find BUTTON1 on the form.\n";
} else {
buttonNode.addOnBlur(button1OnBlur);
s += " function button1OnBlur registered.\n";
}
alert(s);
}
function button1OnBlur(xfdlEvent) {
alert(xfdlEvent.type);
alert(xfdlEvent.source.getLocalName());
}
void addOnChange ( Function handler );
| Expression | Type | Description |
|---|---|---|
| handler | Function | The name of the function that will be called when the onChange event occurs. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code adds an onChange event handler to BUTTON1. The event handler is given the name button1OnChange, but you can use any name that you want. The event handler displays the type of event and the local name of the source node.
function registerButtonEvent(theForm) {
var buttonNode;
var s;
s = "--- Results of registerButtonEvent function call ---\n";
buttonNode = theForm.dereferenceEx(null, "PAGE1.BUTTON1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(buttonNode == null) {
s += " Could not find BUTTON1 on the form.\n";
} else {
buttonNode.addOnChange(button1OnChange);
s += " Function button1OnChange registered.\n";
}
alert(s);
}
function button1OnChange(xfdlEvent) {
alert(xfdlEvent.type);
alert(xfdlEvent.source.getLocalName());
}
void addOnClick ( Function handler );
| Expression | Type | Description |
|---|---|---|
| handler | Function | The name of the function that will be called when the onclick event occurs. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code adds an onClick event handler to BUTTON1. The event handler is given the name button1OnClick, but you can use any name that you want. The event handler displays the type of event and the local name of the source node.
function registerButtonEvent(theForm) {
var buttonNode;
var s;
s = "--- Results of registerButtonEvent function call ---\n";
buttonNode = theForm.dereferenceEx(null, "PAGE1.BUTTON1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(buttonNode == null) {
s += " Could not find BUTTON1 on the form.\n";
} else {
buttonNode.addOnClick(button1OnClick);
s += " function button1OnClick registered.\n";
}
alert(s);
}
function button1OnClick(xfdlEvent) {
alert(xfdlEvent.type);
alert(xfdlEvent.source.getLocalName());
}
void addOnFocus ( Function handler );
| Expression | Type | Description |
|---|---|---|
| handler | Function | The name of the function that will be called when the onFocus event occurs. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
function button1OnFocus(xfdlEvent) {
alert(xfdlEvent.type);
alert(xfdlEvent.source.getInfoEx(FormNodeP.IDENTIFIER));
}
The sample code adds an onFocus event handler to BUTTON1. The event handler is given the name button1OnFocus, but you can use any name that you want. The event handler displays the type of event and the local name of the source node.
function registerButtonEvent(theForm) {
var buttonNode;
var s;
s = "--- Results of registerButtonEvent function call ---\n";
buttonNode = theForm.dereferenceEx(null, "PAGE1.BUTTON1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(buttonNode == null) {
s += " Could not find BUTTON1 on the form.\n";
} else {
buttonNode.addOnFocus(button1OnFocus);
s += " function button1OnFocus registered.\n";
}
alert(s);
}
function button1OnFocus(xfdlEvent) {
alert(xfdlEvent.type);
alert(xfdlEvent.source.getLocalName());
}
This method checks the format of either all items on the form or all items on a single page. It returns a list of items that have non valid formats.
The list of all nodes with non valid formats. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code takes the root node of the form as input, calls checkValidFormats, then displays the results in a JavaScript alert window.
function testCheckValidFormats(theForm) {
var nodes = new Array();
var s;
s = "--- Results of checkValidFormats test ---\n";
nodes = theForm.checkValidFormats();
if(nodes == null || nodes.length == 0) {
s += " All nodes have valid formats.\n";
} else {
s += " These nodes have non valid formats:\n"
for(i = 0; i < nodes.length; i++) {
s += " Node: " + nodes[0].getReferenceEx(null, null, null, false) + "\n";
}
}
alert(s);
}
--- Results of checkValidFormats test --- These nodes have non valid formats: Node: PAGE1.FIELD1
Use this method to create a new cell item for a combobox, list, or popup. The createCell method adds one new cell to a group on a page in the form. Note that this method can only assign a name to the new cell; it cannot set the value of the cell. To set the value of a cell, you must use the setLiteralByRefEx method.
This method is called from a page level node, and creates the new cell in that page. Note that you cannot call this method from the global page node.
| Expression | Type | Description |
|---|---|---|
| cellName | String | The name of the new cell being created. |
| groupName | String | The name of the group option to which the new cell will be added. |
A FormNodeP containing the new cell. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
This sample code makes two calls to createCell to add two new cells to the same group. Each call to createCell is followed by a call to setLiteralByRefEx to set the value for the new cell.
function testCreateCell(theForm) {
var newCell;
var pageNode;
var s;
s = "--- Results of createCell test ---\n";
pageNode = theForm.dereferenceEx(null, "PAGE1", 0,
FormNodeP.UFL_PAGE_REFERENCE, null);
if(pageNode == null) {
s += "Could not find PAGE1 on the form.";
} else {
newCell = pageNode.createCell("ORANGE_CELL", "POPUP1_GROUP");
newCell.setLiteralByRefEx(null, "value", 0, null, "Orange");
newCell = pageNode.createCell("PURPLE_CELL", "POPUP1_GROUP");
newCell.setLiteralByRefEx(null, "value", 0, null, "Purple");
s += " Cells added to the popup item.";
}
alert(s);
}
--- Results of createCell test --- Cells added to the popup item.
This method deletes the specified digital signature in the form. For security reasons, the form must meet certain criteria before this is allowed. None of the following should be locked by another signature: the signature, its descendants, the associated signature button, and its signer option. If these criteria are met, then the signature's locks are removed, the signature item is deleted, and the signer of the associated signature button is set to empty ("").
| Expression | Type | Description |
|---|---|---|
| signatureItem | FormNodeP | The signature node to delete. You can retrieve this node by calling dereferenceEx |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
If the signatureItem item contains a layoutinfo option, deleteSignature will not remove the entire signature from the form. Instead, the signature item and the layoutinfo option will remain. To completely delete the signature item, you must delete the remaining nodes manually by using destroy to delete the signature item.
function testDeleteSignature(theForm) {
var s;
var node;
s = "--- Results of deleteSignature test ---\n";
node = theForm.dereferenceEx(null, "PAGE1.BUTTON1_SIGNATURE_405824760", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(node == null) {
s += " Could not find PAGE1.BUTTON1_SIGNATURE_405824760 on the form.\n";
} else {
theForm.deleteSignature(node);
s += " The signature has been deleted.\n";
}
alert(s);
}
--- Results of deleteSignature test -- The signature has been deleted.
Use this function to locate a particular FormNodeP, to locate a cell in a particular group, or to locate a data item in a particular datagroup.
FormNodeP dereferenceEx(
String scheme,
String reference,
Number referenceCode,
Number referenceType,
FormNodeP NSNode
);
The FormNodeP defined by the reference string or null if the referenced node does not exist and FormNodeP.UFL_SEARCH_AND_CREATE is not specified. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
Before you decide which FormNodeP to use this method on, be sure you understand the following:
For general information about creating a reference string, see About references .
Reference strings for groups or datagroups follow this format:
page.group. or page.datagroup
In both cases, the page component is optional. It is only required if you want to search a different page than the one containing your reference node.
For example, to refer to the "State" group of cells on PAGE1 of the form, use:
PAGE1.State
If you want to locate a cell or a data item, you must perform a bitwise OR with UFL_FIRST or UFL_NEXT. UFL_FIRST will locate the first cell or data item in the page. UFL_NEXT will locate the next cell or data item. This allows you to loop through all the cells or data item on a page until you have found the one you want.
Note that groups and datagroups are limited to a single page, and that your search will likewise be limited to a single page.
For an option or argument reference, you can have the library create a node that does not exist. To do so, perform a bitwise OR of UFL_SEARCH_AND_CREATE to the referenceType parameter; otherwise, perform a bitwise OR of UFL_SEARCH to the referenceType variable and the function will return null if the node does not exist.
In some cases, you may want to use the dereferenceEx method to locate a node that does not have a globally defined namespace. For example, consider the following form:
<label sid="Label1">
<value>Field1.processing:myValue</value>
</label>
<field sid="Field1" xmlns:processing="URI">
<value></value>
<processing:myValue>10<processing:myValue>
</field>
In this form, the processing namespace is declared in the Field1 node. Any elements within Field1 will understand that namespace; however, elements outside of the scope of Field1 will not.
In cases like this, you will often start your search at a node that does not understand the namespace of the node you are trying to locate. For example, you might want to locate the node referenced in the value of Label1. In this case, you would first locate the Label1 value node and get its literal. Then, from the Label1 value node, you would attempt to locate the processing:myValue node as shown:
Label1Node.dereferenceEx(null, "Field1.processing:myValue", 0,
FormNodeP.UFL_OPTION_REFERENCE, null)
In this example, the dereferenceEx method would fail. The method cannot properly resolve the processing namespace because this namespace is not defined for the Label1 value node. To correct this, you must also provide a node that understands the processing namespace (in this case, any node in the scope of Field1) as the last parameter in the method:
Label1Node.dereferenceEx(null, "Field1.processing:myValue", 0,
FormNodeP.UFL_OPTION_REFERENCE, Field1Node)
The sample code makes a variety of calls to dereferenceEx and displays the results in a JavaScript alert() message.
function testDereferenceEx(theForm) {
var s;
var tempNode;
s = "--- results of dereferenceEx test ---\n";
/* find PAGE2 */
s += "1. ";
tempNode = theForm.dereferenceEx(null, "PAGE2", 0,
FormNodeP.UFL_PAGE_REFERENCE, null);
if(tempNode == null) {
s += "Could not find PAGE2 on the form.\n";
} else {
s += "PAGE2 found.\n";
}
/* find PAGE1.FIELD3 */
s += "2. ";
tempNode = theForm.dereferenceEx(null, "PAGE1.FIELD3", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(tempNode == null) {
s += "Could not find PAGE1.FIELD3 on the form.\n";
} else {
s += "PAGE1.FIELD3 found.\n";
}
/* find fontinfo of FIELD3, create if not found*/
s += "3. ";
tempNode = theForm.dereferenceEx(null, "PAGE1.FIELD3.fontinfo[fontname]", 0,
FormNodeP.UFL_ARRAY_REFERENCE | FormNodeP.UFL_SEARCH_AND_CREATE, null);
if(tempNode == null) {
s += "Could not create PAGE1.FIELD3.fontinfo[fontname].\n";
} else {
s += "PAGE1.FIELD3.fontinfo[fontname] created.\n";
}
/* find the first node in the COMBOBOX1_GROUP group */
s += "4. ";
tempNode = theForm.dereferenceEx(null, "PAGE1.COMBOBOX1_GROUP", 0,
FormNodeP.UFL_GROUP_REFERENCE | FormNodeP.UFL_FIRST, null);
if(tempNode == null) {
s += "Could not find PAGE1.COMBOBOX1_GROUP.\n";
} else {
s += "The first COMBOBOX1_GROUP on PAGE1 is: ";
s += tempNode.getAttribute("http://www.ibm.com/xmlns/prod/XFDL/7.5", "sid");
}
alert(s);
}
--- Results of dereferenceEx test --- 1. Could not find PAGE2 on the form. 2. PAGE1.FIELD3 found. 3. PAGE1.FIELD3.fontinfo[fontname] created. 4. The first PAGE1.COMBOBOX1_GROUP is: ORANGE_CELL.
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code destroys PAGE1.FIELD2.
function testDestroy(theForm) {
var s;
var node;
s = "--- Results of destroy test ---\n";
node = theForm.dereferenceEx(null, "PAGE1.FIELD2", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(node == null) {
s += " Could not find PAGE1.FIELD2 on the form.\n";
} else {
node.destroy();
s += " PAGE1.FIELD2 has been destroyed.\n";
}
alert(s);
}
--- Results of destroy test --- PAGE1.FIELD2 has been destroyed.
This method makes a copy of a node. The duplicated node can be attached to any other node as either a sibling or a child, or can be stored as a separate node structure. The new node can also be assigned a new identifier with the identifier parameter. All of the properties of the original node are duplicated, including any children and any namespace settings.
The new node. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code makes a duplicate of PAGE1.FIELD1 and gives it the sid FIELD5. Because the new node is an exact copy of PAGE1.FIELD1, it will also have the same value and location as PAGE1.FIELD1. For this reason, the sample code uses setLiteralByRefEx to give FIELD5 a new value and location.
function testDuplicate(theForm) {
var tempNode, newNode;
var s;
s = "--- Results of duplicate test ---\n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.FIELD1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(fieldNode == null) {
s += " Could not locate FIELD1 node.";
} else {
newNode = fieldNode.duplicate(null, XFDL.UFL_AFTER_SIBLING, "FIELD5");
if(newNode == null) {
s += " Could not duplicate FIELD1 node.\n";
} else {
/* give the new node a new value and location */
newNode.setLiteralByRefEx(null, "value", 0,
null, "this field is a duplicate of FIELD1");
newNode.setLiteralByRefEx(null, "itemlocation[y]", 0,
null, "300");
s += " FIELD1 duplicated and new field relocated.\n";
}
}
alert(s);
}
--- Results of duplicate test --- FIELD1 duplicated and new field relocated.
This method encloses file data in a form. The formNodeP object can be either a page node or an item node. If the formNodeP is a page node, the method creates a data item in that page to contain the enclosure. If the formNodeP is an item node, it must be a data item, and the method encloses the file in that node.
FormNodeP encloseFile( String data, String dataEncoding, String mimeType, String dataGroup, String identifier );
| Expression | Type | Description |
|---|---|---|
| data | String | The data to enclose. |
| dataEncoding | String | A string that represents the encoding of the data. Valid values are "xml", "base64", and "base64-gzip". |
| mimeType | String | The MIME type of the file. If null, the library will attempt to find a suitable MIME type for the file. |
| dataGroup | String | The data group to which this file should belong. If the object is a page node, you must provide this parameter. If the object is an item node, use null to keep the current datagroup option, or provide a different value to overwrite the option. |
| identifier | String | The identifier to assign to the new data item if one is created. If null, either the current name is used or a unique name is automatically generated for the new data item. |
The item formNodeP that contains the enclosure on success or null on failure.On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code encloses a short string in the form and displays the result in a JavaScript alert() message.
function testEncloseFile(theForm) {
var pageNode, newNode;
var s, sData;
s = "--- Results of encloseFile test ---\n";
pageNode = theForm.dereferenceEx(null, "PAGE1", 0,
FormNodeP.UFL_PAGE_REFERENCE, null);
if(pageNode == null) {
s += " Could not find PAGE1 on the form.";
} else {
s += " XML encoding test:\n";
sData = "data to enclose as xml encoding";
newNode = pageNode.encloseFile(sData, "xml", null, "dGroup", "xmldata");
if(newNode == null) {
s += " Fail. The data was not enclosed.\n";
} else {
s += " Success. The data was enclosed.\n";
}
}
alert(s);
}
--- Results of encloseFile test --- XML encoding test: Success. The data was enclosed.
This method modifies one instance in the data model, either updating information or appending information. Note that the form must have an existing data model.
void encloseInstance(
String instanceID,
String data,
Number flags,
String scheme,
String rootReference,
FormNodeP NSNode,
boolean replaceNode
);
| Expression | Type | Description |
|---|---|---|
| instanceID | String | The ID of the instance node to create
or replace. This is defined by the id attribute
of that node, and is case sensitive. To replace the root node of the form, set this parameter to null. |
| data | String | A valid XML document. |
| flags | Number | Reserved. Must be 0. |
| scheme | String | Reserved. Must be null. |
| rootReference | String | A reference to the node you want to replace
or append children to. This reference is relative to the instance
node. Use null to default to the instance node. |
| NSNode | FormNodeP | A node that inherits the namespaces used in the reference. This node defines the namespaces for the method. Use null if the node that this method is operating on has inherited the necessary namespaces. |
| replaceNode | boolean | If true, the node specified by rootReference is replaced with data. If false, the data is appended as the last child of the rootReference node. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code encloses some XML data in the form, then uses extractInstance for display in a JavaScript alert box. Note that in the sample, the instance "instance1" must exist in the XML data model.
function testEncloseInstance(theForm) {
var s, xmlData;
s = "--- Results of encloseInstance test ---\n";
xmlData = "<data><flower>Rose</flower></data>";
theForm.encloseInstance("instance1", xmlData, 0, null, null, null, true);
s += " New contents of instance1:\n ";
s += theForm.extractInstance("instance1",null, "", 0, null, null, null) + "\n";
alert(s);
}
--- Results of encloseInstance test ---
New contents of instance1:
<data xmlns="" xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom"
xmlns:designer="http://www.ibm.com/xmlns/prod/workplace/forms/designer/2.6"
xmlns:test="http://www.ibm.com/xmlns/prod/XFDL/Custom"
xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/7.5"
xmlns:xforms="http://www.w3.org/2003/xforms">
<flower>Rose</flower>
</data>
This method will extract an enclosure contained in a node and return it as a string. Note that this method does not remove the enclosure from the form.
| Expression | Type | Description |
|---|---|---|
| dataEncoding | String | A string that represents the encoding of the returned data. Valid values are: "xml", "base64", and "base64-gzip". |
The data is returned as a string in the encoding specified by the dataEncoding parameter. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
<data sid="data">
<mimetype>text/base64-gzip</mimetype>
<filename>base64-gzip.txt</filename>
<mimedata encoding="base64-gzip">H4sIAAAAAAAAAEtJLElUKMlXSM1LzskvT
lVILFZISixONTMBieSnZOalAwBjuqgyIgAAAA==</mimedata>
</data>
Note that the mimedata content has been artificially split
to fit the width of this page.In the above fragment, the plain-text version of the mimedata is: "data to enclose as base64 encoding".
function testExtractFile(theForm) {
var fieldNode;
var s, sData;
s = "--- Results of extractFile test ---\n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.data", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(fieldNode == null) {
s += " Could not find PAGE1.data on the form.";
} else {
s += " XML encoding test:\n";
sData = fieldNode.extractFile("xml");
if(sData == "") {
s += " Failed XML extract test.\n";
} else {
s += " The data with no encoding is:\n '";
s += sData + "'\n";
}
sData = fieldNode.extractFile("base64");
if(sData == "") {
s += " Failed BASE64 extract test.\n";
} else {
s += " The data with base64 encoding is:\n '";
s += sData + "'\n";
}
sData = fieldNode.extractFile("base64-gzip");
if(sData == "") {
s += " Failed BASE64-GZIP extract test.\n";
} else {
s += " The data with base64-gzip encoding is:\n '";
s += sData + "'";
}
}
alert(s);
}
--- Results of extractFile test --- XML encoding test: The data with no encoding is: 'data to enclose as base64 encoding' The data with base64 encoding is: 'ZGF0YSB0byBlbmNsb3NlIGFzIGJhc2U2NCBlbmNvZGluZw==' The data with base64-gzip encoding is: 'H4sIAAAAAAAAC0tJLElUKMlXSM1LzskvTlVILFZISixONTMBieSnZOalAwBjuqgyIgAAAA=='
This method returns the XML instance data as a string. It does not remove the instance from the form.
Call this method on the root node of the form or an XML instance node.
String extractInstance ( String instanceID, FormNodeP triggerItem, String includeNamespacePrefixes, Number flags, String scheme, String rootReference, FormNodeP NSNode );
The instance as a string. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code encloses some XML data in the form then uses extractInstance for display in a JavaScript alert box. Note that in the sample, the instance "instance1" must exist in the XML data model.
function testExtractInstance(theForm) {
var s, xmlData;
s = "--- Results of extractInstance test ---\n";
xmlData = "<data><flower>Rose</flower></data>";
theForm.encloseInstance("instance1", xmlData, 0, null, null, null, false);
s += " New contents of instance1:\n ";
s += theForm.extractInstance("instance1",null, "", 0, null, null,null) + "\n";
alert(s);
}
--- Results of extractInstance test ---
New contents of instance1:
<data xmlns="" xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom"
xmlns:designer="http://www.ibm.com/xmlns/prod/workplace/forms/designer/2.6"
xmlns:test="http://www.ibm.com/xmlns/prod/XFDL/Custom"
xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/7.5"
xmlns:xforms="http://www.w3.org/2003/xforms">
<flower>Rose</flower>
</data>
This method returns the XForms instance data as a string. It does not remove the instance from the form.
Call this method on the root node of the form or an instance node.
String extractXFormsInstance(
String modelID,
String instanceXPath,
boolean respectRelevantMIP,
boolean ignoreFailures,
FormNodeP NSNode,
);
| Expression | Type | Description |
|---|---|---|
| modelID | String | The ID of the model to extract. Use null to extract the default model. |
| instanceXPath | String | An XPath reference to a node in the instance. This node and all of its children are copied. Leave blank to extract the entire instance. |
| respectRelevantMIP | boolean | If true, returns only relevant instance data, else use false. |
| ignoreFailures | boolean | If true, ignores constraint or validation failures, else use false. |
| NSNode | FormNodeP | A node that inherits the namespaces used in the reference. This node defines the namespaces for the method. Use null if the node that this method is operating on has inherited the necessary namespaces. |
XForms instance data as a string. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
XForms data model
The updateXFormsInstance and the extractXFormsInstance methods are the only methods that are intended to modify the XForms data model.The sample code extracts various portions of an instance and places the results in a string. It then displays the string in a JavaScript alert window.
<xformsmodels>
<xforms:model>
<xforms:instance id="instance1" xmlns="">
<document>
<cities>
<city>Paris</city>
<city>Beijing</city>
</cities>
</document>
</xforms:instance>
</xforms:model>
</xformsmodels>
Sample code:
function testExtractXFormsInstance(theForm) {
var s, sData;
s = "--- Results of extractXFormsInstance test ---\n\n";
s += "Entire instance:\n"
sData = theForm.extractXFormsInstance(null,
"",
true, true, null);
s += sData + "\n\n";
s += "Cities data only:\n"
sData = theForm.extractXFormsInstance(null,
"instance('instance1')/cities",
true, true, null);
s += sData + "\n\n";
s += "The first city element:\n"
sData = theForm.extractXFormsInstance(null,
"instance('instance1')/cities/city[1]",
true, true, null);
s += sData + "\n\n";
alert(s);
}
--- Results of extractXFormsInstance test ---
Entire instance:
<document>
<cities>
<city>Paris</city>
<city>Beijing</city>
</cities>
</document>
Cities data only:
<cities>
<city>Paris</city>
<city>Beijing</city>
</cities>
The first city element:
<city>Paris</city>
This method returns the value of an attribute in a node. For example, in the XFDL fragment shown, the mimedata node has an attribute called encoding with the value base64.
<mimedata encoding="base64"></mimedata>
| Expression | Type | Description |
|---|---|---|
| namespaceURI | String | The namespace URI for the attribute.
For example: http://www.ibm.com/xmlns/prod/XFDL/7.7 |
| localName | String | The local name of the attribute. For example, encoding. |
The value of the attribute. If the attribute is empty or does not exist, the method returns an empty string. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
If you refer to an attribute with a namespace prefix, getAttribute first looks for a complete match, including both prefix and attribute name. If it does not find a match, it will look for a matching attribute name that has no prefix but whose containing element has the same namespace.
For example, assume that the custom namespace and the test namespace both resolve to the same URI. In the following case, looking for the id attribute would locate the second attribute (test:id), since it has an explicit namespace declaration:
<a xmlns:custom="ABC" xmlns:test="ABC">
<custom:myElement id="1" test:id="2">
</a>
However, in the next case, the id attribute does not have an explicit namespace declaration. Instead, it inherits the custom namespace. However, since the inherited namespace resolves to the same URI, the id attribute is still located:
<custom:myElement id="1">
Forms generally use three special attributes that are not in an explicitly defined namespace and which require special commands to retrieve.
The first is the default namespace attribute, which looks like this:
xmlns="http://www.ibm.com/xmlns/prod/XFDL/7.7"
To retrieve this attribute, you must use a namespace URI of null and the attribute name xmlns.
The second special attribute is a namespace declaration, which looks like this:
xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom"
To retrieve this sort of attribute, you must use the namespace URI http://www.w3.org/2000/xmlns and the appropriate attribute name, such as custom.
Finally, there is the language attribute, which looks like this:
xml:lang="en-GB"
To retrieve this sort of attribute, you must use the namespace URI http://www.w3.org/XML/1998/namespace and the attribute name lang.
The following example shows a method that gets the value of the encoding attribute for a node. The node is passed to the method which calls getAttribute to get the value of encoding attribute. This sample method assumes that the attribute is always in the XFDL namespace.
The sample code uses getAttribute to retrieve the sid of the first child node on PAGE1 of the form that is passed in, and to retrieve the lang attribute of the form.
function testGetAttribute(theForm) {
var pageNode, childNode;
var s;
s = "--- Results of getAttribute test ---\n";
pageNode = theForm.dereferenceEx(null, "PAGE1", 0,
FormNodeP.UFL_PAGE_REFERENCE, null);
if(pageNode == null) {
s += " FAILED: Could not find PAGE1 on the form.\n";
} else {
childNode = pageNode.getChildren();
}
if(childNode == null) {
s += " FAILED: Could not find first child of PAGE1.\n";
} else {
s += " The sid of the first child node of PAGE1: '";
s += childNode.getAttribute("http://www.ibm.com/xmlns/prod/XFDL/7.7", "sid");
s += "'\n";
}
s += " The language of the form is: '";
s += theForm.getAttribute("http://www.w3.org/XML/1998/namespace", "lang");
s += "'\n";
alert(s);
}
--- Results of getAttribute test --- The sid of the first child node of PAGE1: 'global' The language of the form is: 'en-US'
This method returns a list of either the namespace URIs of all attributes of the node on which it is called, or the local names of all attributes of the node on which it is called. The returned list depends on the value of the namespaces parameter. If the parameter is FormNodeP.NAMESPACE, a list of the namespace URIs is returned. If the parameter is FormNodeP.LOCALNAME, a list of the local names of all attributes is returned. The lists are ordered such that element 1 of one list corresponds to element 1 of the other list.
String[] getAttributeList( Number namespaces );
| Expression | Type | Description |
|---|---|---|
| namespaces | Number | One of the two following constants: FormNodeP.NAMESPACE — a list of namespaces for the attributes of the node. FormNodeP.LOCALNAME — a list of local names for the attributes of the node. |
The requested list. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
<field sid="FIELD3" custom:id="2"> <value>This is the value for FIELD3</value> </field>
function testGetAttributeList(theForm) {
var namespaceURIList, localNameList;
var fieldNode;
var s;
s = "--- Results of getAttributeList test ---\n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.FIELD3", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(fieldNode == null) {
s += " Could not find PAGE1.FIELD3 on the form.\n";
} else {
namespaceURI = fieldNode.getAttributeList(FormNodeP.NAMESPACE);
localName = fieldNode.getAttributeList(FormNodeP.LOCALNAME);
for(i=0, j=1; i < namespaceURI.length; i++,j++) {
s += " Attribute " + j + ": '";
s += namespaceURIList[i] + "', '";
s += localNameList[i] + "'\n";
}
}
alert(s);
}
--- Results of getAttributeList test -- Attribute 1: 'http://www.ibm.com/xmlns/prod/XFDL/Custom', 'id'. Attribute 2: 'null', 'sid'.
This method, along with getParent, is used to traverse vertically along the form hierarchy. getChildren returns the first child of the indicated node. If the node has no children, null is returned. All child nodes of a FormNodeP can be traversed using a while loop in combination with getNext.
The FormNodeP that represents the first child or null if no child nodes exist. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code returns the first child node of PAGE1.FIELD1 and displays the result in a JavaScript alert() message.
function testGetChildren(theForm) {
var parentNode, tempNode;
var s;
s = "--- Results of getChildren test ---\n";
parentNode = theForm.dereferenceEx(null, "PAGE1.FIELD3", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(parentNode == null) {
s = " Cannot find PAGE1.FIELD3";
} else {
tempNode = parentNode.getChildren();
s += " The first child node of PAGE1.FIELD3 is: "
+ tempNode.getLocalName() + "\n";
}
alert(s);
}
--- Results of getChildren test --- The first child node of PAGE1.FIELD3 is: itemlocation.
Returns a reference to the Modal Dialog object.
After you obtain a reference to the Modal Dialog box, you can change its title, size, and whether it displays a header or footer section. You can also close the dialog.
The available methods are:
| Method | Parameters | Description |
|---|---|---|
| setTitle | string | The new title of the dialog. |
| setSize | integer, integer | The new width and height in pixels. |
| showHeader | boolean | To display a header, set to true. |
| showFooter | boolean | To display a footer, set to true. |
| close | Closes the dialog box. The close method has no parameters. | |
getDialog ();
This method has no parameters.
A reference to the Modal Dialog object. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample shows a JavaScript method that runs when the Modal Dialog box opens. The script modifies the title, the size, and the header sections of the Modal Dialog box.
<html>
<head>
<script src="LF_XFDL.js"> </script>
<script src="LF_FormNodeP.js"> </script>
<script>
function setupDialog () {
// get a reference to the Modal Dialog object
var dialog = ibmForms[""].getDialog();
// set a new title
dialog.setTitle("Modal Dialog");
// change the size to 600 pixels wide by 400 pixels high
dialog.setSize(600, 400);
// show the header section
dialog.showHeader(true);
// do not show the footer section
dialog.showFooter(false);
}
window.onload = setupDialog;
</script>
</head>
<body>
<p>This is the content of the Modal Dialog</p>
</body>
</html>
A decimal number that when converted to base 16, is in the form of MMmm300. The example below shows how to convert the return value to base 16.
The sample code retrieves the version of the form and converts it to a string for display in a JavaScript alert() window.
function testGetFormVersion(theForm)
{
var version;
var s;
s = "--- Results of getFormVersion test ---\n";
version = theForm.getFormVersion().toString(16);
s += " Form Version: " + version;
alert(s);
}
--- Results of getFormVersion test --- Form Version: 7050300
This method retrieves information about a particular node. If you do not want information about a particular property, set it to null.
String getInfoEx( Number property );
| Expression | Type | Description |
|---|---|---|
| property | Number | One of these four constants: FormNodeP.TYPE — to return the type of the node. FormNodeP.LITERAL — to return the literal of the node. FormNodeP.COMPUTE — to return the compute for the node. FormNodeP.IDENTIFIER — to return the identifer of the node. |
The value that corresponds to the parameter that is passed in, or null if the requested value does not exist. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
If you are getting information about a node that is not in the XFDL namespace, getInfoEx may return values that include namespace prefixes as follows:
The sample code makes four calls to getInfoEx to retrieve the type, literal, compute, and identifer properties of the node PAGE1.FIELD1.value, and displays the results in a JavaScript alert() message.
function testGetInfoEx(theForm) {
var fieldNode;
var s, sType, sLiteral, sCompute, sIdentifier;
s = "--- Results of getInfoEx test ---\n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.FIELD1.value", 0,
FormNodeP.UFL_OPTION_REFERENCE, null);
if(fieldNode == null) {
s += "Cannot find PAGE1.FIELD1.value";
} else {
sType = fieldNode.getInfoEx(FormNodeP.TYPE);
sLiteral = fieldNode.getInfoEx(FormNodeP.LITERAL);
sCompute = fieldNode.getInfoEx(FormNodeP.COMPUTE);
sIdentifier = fieldNode.getInfoEx(FormNodeP.IDENTIFIER);
s += " Type: " + sType + "\n";
s += " Literal: " + sLiteral + "\n";
s += " Formula: " + sCompute + "\n";
s += " Identifier: " + sIdentifier + "\n";
}
alert(s);
}
--- Results of getInfoEx test --- Type: undefined Literal: This is the value for FIELD3 Formula: PAGE1.FIELD3.value Identifier: value
This method finds a particular FormNodeP on the basis of a reference string. Once the FormNodeP is found, its literal is retrieved.
String getLiteralByRefEx( String scheme, String reference, Number referenceCode, FormNodeP NSNode );
| Expression | Type | Description |
|---|---|---|
| scheme | String | Reserved. This must be null. |
| reference | String | The reference string. |
| referenceCode | Number | Reserved. This must be 0. |
| NSNode | FormNodeP | A node that is used to resolve the namespaces in theReference reference parameter (see the note about namespace below). Use null if the node that this method is operating on has inherited the necessary namespaces. |
The literal string. If the literal is empty or does not exist, the method returns null. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
aNode.dereferenceEx(scheme, reference, referenceCode,
UFL_OPTION_REFERENCE | UFL_SEARCH_AND_CREATE,
theNamespaceNode).getLiteralEx();
Before you decide which FormNodeP to call the method on, be sure you understand the following:
For example, given a FormNodeP that represents "field_1" and a reference of "field_2", the method will access the "page" node above "field_1", and will then try to locate "field_2" below that node. If the two fields are not on the same page, the method will fail.
For more information about creating a reference, see About references .
In some cases, you may want to use the to get the literal of a node that does not have a globally defined namespace. For example, consider the following form:
<label sid="LABEL1">
<value>FIELD1.processing:myValue</value>
</label>
<field sid="FIELD1" xmlns:processing="URI">
<value>This is Field 1</value>
<processing:myValue>10</processing:myValue>
</field>
In this form, the processing namespace is declared in the FIELD1 node. Any elements within FIELD1 will understand that namespace; however, elements outside of the scope of FIELD1 will not.
In cases like this, you will often start your search at a node that does not understand the namespace of the node you are trying to locate. For example, you might want to locate the node referenced in the value of LABEL1. In this case, you would first locate the LABEL1 value node and get its literal. Then, from the LABEL1 value node, you would attempt to locate the processing:myValue node as shown:
Label1Node.getLiteralByRefEx(null, "FIELD1.processing:myValue", 0, null)
In this example, the getLiteralByRefEx method fails. The method cannot properly resolve the processing namespace because this namespace is not defined for the LABEL1 value node. To correct this, you must also provide a node that understands the processing namespace (in this case, any node in the scope of LABEL1) as a parameter in the method:
Label1Node.getLiteralByRefEx(null, "FIELD1.processing:myValue", 0, Field1Node)
Using the form fragment described above, the sample code retrieves the literal of PAGE1.FIELD1.value, which is "This is Field 1". The code then attempts to retrieve the literal of PAGE1.FIELD1.processing:myValue, which is in the processing namespace. The first attempt returns "null" because the namespace is not understood. The second attempt returns the correct value of "10" because the node representing FIELD1.PAGE1 is passed in as the NSNode parameter. The results are displayed in a JavaScript alert window.
function testGetLiteralByRefEx(theForm) {
var fieldNode, labelNode;
var s, sLiteral;
s = "--- testGetLiteralByRefEx results ---\n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.FIELD1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
labelNode = theForm.dereferenceEx(null, "PAGE1.LABEL1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(fieldNode == null) {
s += "Cannot find PAGE1.FIELD1";
} else {
sLiteral = labelNode.getLiteralByRefEx(null,
"PAGE1.FIELD1.value", 0, null);
s += " First test: " + sLiteral + "\n";
sLiteral = labelNode.getLiteralByRefEx(null,
"PAGE1.FIELD1.processing:myValue", 0, null);
s += " Second test: " + sLiteral + "\n";
sLiteral = labelNode.getLiteralByRefEx(null,
"PAGE1.FIELD1.processing:myValue", 0, fieldNode);
s += " Third test: " + sLiteral + "\n";
}
alert(s);
}
--- getLiteralByRefEx results --- First test: This is Field 1 Second test: null Third test: 10
This method retrieves the literal of a node. The literal is returned in the specified character set.
A string containing the literal of the node, or null if the literal is empty or does not exist. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The following example uses dereferenceEx to locate a specific node. getLiteralEx is then used to get the literal value for that node.
function testGetLiteralEx(theForm) {
var valueNode;
var s, value;
s = "--- Results of getLiteralEx test ---\n";
valueNode = theForm.dereferenceEx(null, "PAGE1.FIELD4.value", 0,
FormNodeP.UFL_OPTION_REFERENCE, null);
if(valueNode == null) {
s += "Cannot find PAGE1.FIELD4.value";
} else {
value = valueNode.getLiteralEx();
s += " The value is: " + value + "\n";
}
alert(s);
}
--- Results of getLiteralEx test --- The value is: This is FIELD4
This method returns the local name of a given node. The local name is determined by the XML tag that represents that node. For example, examine the following XML fragment:
<page sid="PAGE1">
<global sid="global"></global>
<field sid="testField">
<value>Hello</value>
<bgcolor>120, 120, 120</bgcolor>
</field>
</page>
In this sample, the name of the page node is "page", the name of the field node is "field", the name of the value node is "value", and the name of the bgcolor node is "bgcolor".
Note that the local name does not include any namespace prefix that might exist. For example, you might have a custom option in a different namespace as shown:
<field sid="testField">
<custom:my_option>value</custom:my_option>
</field>
In this case, the local name of the custom option is returned without the prefix, resulting in "my_option".
The name of the node. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code retrieves the local name of all child nodes of PAGE1.FIELD4 and displays the results in a JavaScript alert() message.
function testGetLocalName(theForm) {
var fieldNode, tempNode;
var s;
s = "--- Results of testGetLocalName test ---\n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.FIELD4", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(fieldNode == null){
s += "Cannot find PAGE1.FIELD4";
} else {
tempNode = fieldNode.getChildren();
while(tempNode != null){
s += "Local Name: " + tempNode.getLocalName() + "\n";
tempNode = tempNode.getNext();
}
}
alert(s);
}
--- Results of getLocalName test --- Local Name: myValue Local Name: value Local Name: focused Local Name: mouseover Local Name: itemprevious Local Name: itemnext
This method returns the namespace URI for the node.
Each namespace is defined in the form by a namespace declaration, as shown:
xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/7.5" xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom"
Each namespace declaration defines both a prefix and a URI for the namespace. In this sample, the prefix for the XFDL namespace is xfdl and the URI is http://www.ibm.com/xmlns/prod/XFDL/7.5.
Tags within the form are assigned specific namespaces by using the defined prefix. For example, to declare that an option was in the custom namespace you would use the prefix custom as shown:
<field sid="testField">
<custom:custom_option>value</custom:custom_option>
</field>
The namespace URI. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code retrieves the namespace URI for each child node of PAGE1.FIELD4 and displays the results in a JavaScript alert() message.
function testGetNamespaceURI(theForm) {
var fieldNode, tempNode;
var s;
s = "--- Results of testGetNamespaceURI test ---\n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.FIELD4", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(fieldNode == null){
s += "Cannot find PAGE1.FIELD4";
} else {
tempNode = fieldNode.getChildren();
while(tempNode != null){
s += "Local Name: " + tempNode.getNamespaceURI() + "\n";
tempNode = tempNode.getNext();
}
}
alert(s);
}
--- Results of getNamespaceURI test --- Namespace: http://www.sample.uri/processing Namespace: http://www.ibm.com/xmlns/prod/XFDL/7.5 Namespace: http://www.ibm.com/xmlns/prod/XFDL/7.5 Namespace: http://www.ibm.com/xmlns/prod/XFDL/7.5 Namespace: http://www.ibm.com/xmlns/prod/XFDL/7.5 Namespace: http://www.ibm.com/xmlns/prod/XFDL/7.5
This method returns the namespace URI that corresponds to a specific prefix. You can call this method from any node in the form, as long as that node either declares or inherits the namespace in question.
Each namespace is defined in the form by a namespace declaration, as shown:
xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/7.5" xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom"
Each namespace declaration defines both a prefix and a URI for the namespace. In this sample, the prefix for the XFDL namespace is xfdl and the URI is http://www.ibm.com/xmlns/prod/XFDL/7.5.
Tags within the form are assigned specific namespaces by using the defined prefix. For example, to declare that an option was in the custom namespace you would use the prefix custom as shown:
<field sid="testField">
<custom:custom_option>value</custom:custom_option>
</field>
| Expression | Type | Description |
|---|---|---|
| prefix | String | The namespace prefix. For example, xfdl. |
The namespace URI. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code retrieves the namespace URI associated with the prefix "xfdl", the prefix "custom", and the prefix "temp". The results are displayed in a JavaScript alert() message.
function testGetNamespaceURIFromPrefix(theForm) {
var fieldNode;
var s, sPrefix;
s = "--- Results of getNamespaceURIFromPrefix test ---\n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.FIELD4", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(fieldNode == null) {
s += "Cannot find PAGE1.FIELD4";
} else {
sPrefix = fieldNode.getNamespaceURIFromPrefix("xfdl");
s += " Namespace for prefix 'xfdl': " + sPrefix + "\n";
sPrefix = fieldNode.getNamespaceURIFromPrefix("custom");
s += " Namespace for prefix 'custom': " + sPrefix + "\n";
sPrefix = fieldNode.getNamespaceURIFromPrefix("processing");
s += " Namespace for prefix 'processing': " + sPrefix + "\n";
sPrefix = fieldNode.getNamespaceURIFromPrefix("temp");
s += " Namespace for prefix 'temp': " + sPrefix + "\n";
}
alert(s);
}
--- Results of getNamespaceURIFromPrefix test --- Namespace for prefix 'xfdl': http://www.ibm.com/xmlns/prod/XFDL/7.5 Namespace for prefix 'custom': http://www.ibm.com/xmlns/prod/XFDL/Custom Namespace for prefix 'temp': null
This method, along with getPrevious, is used to traverse horizontally along the form hierarchy. getNext returns the next node in the tree. For instance, the page node corresponding to the first page of your form can be reached by calling getNext on the global page node.
The FormNodeP that represents the next node or null if the next node does not exist. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The example uses the getNext method to retrieve all child nodes of the field PAGE1.FIELD4. The results are formatted into a string and displayed in a JavaScript alert() message.
function testGetNext(theForm) {
var fieldNode, tempNode;
var s;
s = "--- Results of getNext test ---\n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.FIELD4", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(fieldNode == null){
s += "Cannot find PAGE1.FIELD4";
} else {
tempNode = fieldNode.getChildren();
while(tempNode != null){
s += " Local Name: " + tempNode.getLocalName() + "\n";
tempNode = tempNode.getNext();
}
}
alert(s);
}
--- Results of getNext test --- Local Name: myValue Local Name: value Local Name: focused Local Name: mouseover Local Name: itemprevious Local Name: itemnext
This method returns the type for a node (for example, page, item, option, and array). This allows you to quickly determine the type of node you are working with and what depth you are at in the node hierarchy.
The sample code calls getNodeType on each node that it finds while traversing down the node tree, starting at the second child node of PAGE1. It also collects the localname of each node and displays the results in a JavaScript alert() message.
function testGetNodeType(theForm) {
var pageNode, tempNode;
var s, nodeType;
s = "--- Results of getNodeType test ---\n";
pageNode = theForm.dereferenceEx(null, "PAGE1", 0,
FormNodeP.UFL_PAGE_REFERENCE, null);
if(pageNode == null){
s += "Cannot find PAGE1";
} else {
/* get the second child node of PAGE1 */
tempNode = pageNode.getChildren().getNext();
while(tempNode != null){
nodeType = tempNode.getNodeType();
switch (nodeType) {
case FormNodeP.UFL_FORM:
s += " Node type for "
+ tempNode.getLocalName() + ": Form\n";
break;
case FormNodeP.UFL_PAGE:
s += " Node type for "
+ tempNode.getLocalName() + ": Page\n";
break;
case FormNodeP.UFL_ITEM:
s += " Node type for "
+ tempNode.getLocalName() + ": Item\n";
break;
case FormNodeP.UFL_OPTION:
s += " Node type for "
+ tempNode.getLocalName() + ": Option\n";
break;
case FormNodeP.UFL_ARRAY:
s += " Node type for "
+ tempNode.getLocalName() + ": Array\n";
break;
default:
s += " Node type: Unknown\n"; break;
}
tempNode = tempNode.getChildren();
}
}
alert(s);
}
--- Results of getNodeType test --- Node type for field: Item Node type for itemlocation: Option Node type for x: Array
This method, along with getChildren, is used to traverse vertically along the form hierarchy. getParent returns the parent of a node. If the node has no parent, null is returned. A form's structure can be traversed up to the root node using an iterator such as a while loop.
The FormNodeP that represents the parent node or null if no such parent exists. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code retrieves the parent node of PAGE1.FIELD4.value and each subsequent parent node, all the way up to the root node. It also collects the local name of each node and displays the result in a JavaScript alert() window.
function testGetParent(theForm) {
var valueNode, tempNode;
var s;
s = "--- Results of getParent test ---\n";
valueNode = theForm.dereferenceEx(null, "PAGE1.FIELD4.value", 0,
FormNodeP.UFL_OPTION_REFERENCE, null);
if(valueNode == null){
s += "Cannot find PAGE1.FIELD4.value";
} else {
tempNode = valueNode.getParent();
while(tempNode != null){
s += " Local Name: " + tempNode.getLocalName() + "\n";
tempNode = tempNode.getParent();
}
}
alert(s);
}
--- Results of getParent test --- Local Name: field Local Name: page Local Name: XFDL
This method returns the namespace prefix for the node.
Each namespace is defined in the form by a namespace declaration, as shown:
xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/7.5" xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom"
Each namespace declaration defines both a prefix and a URI for the namespace. In this sample, the prefix for the XFDL namespace is xfdl and the URI is http://www.ibm.com/xmlns/prod/XFDL/7.5.
Tags within the form are assigned specific namespaces by using the defined prefix. For example, to declare that an option is in the custom namespace, use the prefix custom as shown:
<field sid="testField">
<custom:custom_option>value</custom:custom_option>
</field>
The prefix for the node's namespace. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
<field sid="FIELD4" xmlns:processing="http://www.sample.uri/processing"> <processing:myValue>10</processing:myValue> <value>This is FIELD4</value> </field>The results are displayed in a JavaScript alert() window.
function testGetPrefix(theForm) {
var fieldNode, tempNode;
var s;
s = "--- Results of getPrefix test ---\n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.FIELD4", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(fieldNode == null){
s += "Cannot find PAGE1.FIELD4";
} else {
tempNode = fieldNode.getChildren();
s += " Namespace prefix for " + tempNode.getLocalName()
+ ": " + tempNode.getPrefix() + "\n";
}
alert(s);
}
--- Results of getPrefix test --- Namespace prefix for myValue: processing
This method returns the namespace prefix for a specific namespace URI. You can call this method from any node in the form, as long as that node either declares or inherits the namespace in question.
Each namespace is defined in the form by a namespace declaration, as shown:
xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/7.5" xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom"
Each namespace declaration defines both a prefix and a URI for the namespace. In this sample, the prefix for the XFDL namespace is xfdl and the URI is http://www.ibm.com/xmlns/prod/XFDL/7.5.
Tags within the form are assigned specific namespaces by using the defined prefix. For example, to declare that an option is in the custom namespace, use the prefix custom as shown:
<field sid="testField">
<custom:custom_option>value</custom:custom_option>
</field>
| Expression | Type | Description |
|---|---|---|
| uri | String | The namespace URI. For example: http://www.ibm.com/xmlns/prod/XFDL/7.5 |
The namespace prefix. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
<field sid="FIELD4" xmlns:processing="http://www.sample.uri/processing"> <processing:myValue>10</processing:myValue> <value>This is FIELD4</value> </field>The results are displayed in a JavaScript alert() window.
function testGetPrefixFromNamespaceURI(theForm) {
var fieldNode;
var s, prefix;
s = "--- Results of getPrefixFromNamespaceURI test ---\n";
s += " First: (Form) \n";
prefix = theForm.getPrefixFromNamespaceURI(
"http://www.ibm.com/xmlns/prod/XFDL/Custom");
s += " Namespace prefix for http://www.ibm.com/xmlns/prod/XFDL/Custom: "
+ prefix + "\n";
prefix = theForm.getPrefixFromNamespaceURI(
"http://www.sample.uri/processing");
s += " Namespace prefix for http://www.sample.uri/processing: "
+ prefix + "\n";
s += " Second: (PAGE1.FIELD4) \n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.FIELD4", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(fieldNode == null){
s += "Cannot find PAGE1.FIELD4";
} else {
prefix = fieldNode.getPrefixFromNamespaceURI(
"http://www.ibm.com/xmlns/prod/XFDL/Custom");
s += " Namespace prefix for http://www.ibm.com/xmlns/prod/XFDL/Custom: "
+ prefix + "\n";
prefix = fieldNode.getPrefixFromNamespaceURI(
"http://www.sample.uri/processing");
s += " Namespace prefix for http://www.sample.uri/processing: "
+ prefix + "\n";
}
alert(s);
}
--- Results of getPrefixFromNamespaceURI test --- First: (Form) Namespace prefix for http://www.ibm.com/xmlns/prod/XFDL/Custom: custom Namespace prefix for http://www.sample.uri/processing: null Second: (PAGE1.FIELD4) Namespace prefix for http://www.ibm.com/xmlns/prod/XFDL/Custom: custom Namespace prefix for http://www.sample.uri/processing: processing
This method, along with getNext, is used to traverse horizontally along the form hierarchy. getPrevious returns the previous node in the tree. For instance, if you call getPrevious on the Page1 node in your form, it will return the global page node.
The FormNodeP that represents the previous node or null if no such node exists. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code retrieves the list of nodes that are previous to PAGE1.FIELD4. The local name of each of the previous nodes is saved in a string and displayed in a JavaScript alert() window.
function testGetPrevious(theForm) {
var fieldNode, tempNode;
var s;
s = "--- Results of getPrevious test ---\n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.FIELD4", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(fieldNode == null){
s += "Cannot find PAGE1.FIELD4";
} else {
tempNode = fieldNode.getPrevious();
while(tempNode != null){
s += " Local Name: " + tempNode.getLocalName() + "\n";
tempNode = tempNode.getPrevious();
}
}
alert(s);
}
--- Results of getPrevious test --- Local Name: label Local Name: field Local Name: label Local Name: list Local Name: popup Local Name: combobox Local Name: field Local Name: global
This method returns the reference string that identifies the node. For example, a value node might return a reference of Page1.Field1.value. The reference will either begin at the page level of the form or at a level specified by the caller.
String getReferenceEx( String scheme, FormNodeP NSNode, FormNodeP startPoint, boolean addNamespaces );
| Expression | Type | Description |
|---|---|---|
| scheme | String | Reserved. This must be null. |
| NSNode | FormNodeP | A node that defines which namespace prefixes are used when constructing the reference. Only namespace prefixes that this node inherits are used. Use null if the node that this method is operating on has inherited the necessary namespaces. |
| startPoint | FormNodeP | A node that determines the starting point of the reference. This node must be a parent of the current node. The reference will begin one level below the start point node. For example, if you provide a page node the reference will begin at the item level. Use null to start the reference at the page level. |
| addNamespaces | boolean | Use true to add declarations for unknown namespaces to the namespace node (NSNode). Otherwise, use false. |
A string containing a reference to the node. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
For more information about creating a reference, see About references .
In some cases, you may want to use the getReferenceEx method to get the reference to a node that uses a different prefix for a known namespace. For example, consider the following form:
<label sid="Label1" xmlns:data="URI">
<value></value>
</label>
<field sid="Field1" xmlns:processing="URI">
<value></value>
<processing:myValue>10<processing:myValue>
</field>
In this form, processing and data are prefixes for the same namespace, since they both refer to the same URI. However, both namespaces have limited scope since they are declared at the item level. This means that Label1 node does not understand the processing prefix, and that the Field1 node does not understand the data prefix.
This becomes a problem if you want to refer to a namespace from a location that does not understand that namespace. For example, suppose you want to set the value of Label1 to be a reference to the myValue node in Field1. Normally, you would locate the myValue node and use getReferenceEx as shown:
In this case, getReferenceEx would return the following reference: Page1.Field1.processing:myValue. However, because the processing namespace is not defined for Label1, a reference to the processing namespace is not understood. This means that you cannot set the value of Label1 to equal this reference, since the node would not understand that content.
Instead, you must generate a reference that includes a known namespace prefix, such as the data namespace. You can do this by including a second node in the getReferenceEx method. The second node must understand the appropriate namespace. For example, you could include the Label1 node in the method, as shown:
In this case, the method will substitute the data prefix for the processing prefix, since they both resolve to the same namespace. As a result, the method will return: Page1.Field1.data:myValue. Since the data prefix is defined within Label1, you can use this reference to set Label1's value node.
In some cases, you may want to use the getReferenceEx method to get the reference to a node that uses an unknown namespace. For example, consider the following form:
<page sid="Page1" xmlns:processing="URI1">
<global sid="global">
<processing:info></processing:info>
</global>
<field sid="Field1" xmlns:data="URI2">
<value></value>
<data:info>data</data:info>
</field>
In this example, you might want to store a reference to the <data:info> element in the <processing:info> element. getReferenceEx would return the following reference for the <data:info> element: Page1.Field1.data:info. However, this reference includes the data namespace, which is not defined for the page global. This means that you could not store this reference in the <processing:info> element, because it would not understand the reference.
To solve this problem, you can use the addNamespaces flag in the getReferenceEx method. When this flag is set to true, the method will add unknown namespaces to the theNSNode.
For example, if you set theNSNode to be the global item node for Page1, and set the addNamespace flag to true, as shown:
dataNode.getReferenceEx(Null, pageGlobalNode, Null, true)
The method would return the reference to the <data:info> element, but would also modify the global item node to include the unknown data namespaces, as shown:
<global sid="global" xmlns:data="URI2">
You could then store the reference in that global item or any of its descendants, since the namespace is now properly defined.
<field sid="FIELD4" xmlns:processing="http://www.sample.uri/processing"> <processing:myValue>10</processing:myValue> <value>This is FIELD4</value> </field>
function testGetReferenceEx(theForm) {
var fieldNode, childNode;
var s, value;
s = "--- testGetReferenceEx results ---\n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.FIELD4", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(fieldNode != null) {
childNode = fieldNode.getChildren();
}
if(fieldNode == null | childNode == null) {
s += "Cannot find either PAGE1.FIELD4 or its first child node";
} else {
value = childNode.getReferenceEx(null, null, null, false);
s += " Test 1: " + value + "\n";
value = childNode.getReferenceEx(null, null, fieldNode, false);
s += " Test 2: " + value + "\n";
value = childNode.getReferenceEx(null, fieldNode.getParent(), null, false);
s += " Test 3: " + value + "\n";
value = childNode.getReferenceEx(null, fieldNode.getParent(), null, true);
s += " Test 4: " + value + "\n";
}
alert(s);
}
--- Results of getReferenceEx test --- Test 1: PAGE1.FIELD4.processing:myValue Test 2: processing:myValue Test 3: PAGE1.FIELD4.(null):myValue Test 4: PAGE1.FIELD4.processing:myValue
This method returns the name of the appropriate security engine for a given button or signature node. This is useful for determining which validation call you need to make to validate the signature.
| Expression | Type | Description |
|---|---|---|
| operation | Number | The operation that you want the security
engine for. Possible values are: FormNodeP.SEOPERATION_SIGN — the engine that is needed to sign the form. FormNodeP.SEOPERATION_VERIFY — the engine that is needed to verify the signature. FormNodeP.SEOPERATION_LISTIDENTITIES — the engine that is needed to generate a list of valid certificates for signing. |
The sample code retrieves the security engine name for each of the operations and displays the results in a JavaScript alert() window.
function testGetSecurityEngineName(theForm) {
var buttonNode;
var s, value;
s = "--- testGetSecurityEngineName results ---\n";
buttonNode = theForm.dereferenceEx(null, "PAGE1.BUTTON1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(buttonNode == null) {
s += "Cannot find PAGE1.BUTTON1";
} else {
value = buttonNode.getSecurityEngineName(
FormNodeP.SEOPERATION_SIGN);
s+= " Test 1: " + value + "\n";
value = buttonNode.getSecurityEngineName(
FormNodeP.SEOPERATION_VERIFY);
s+= " Test 2: " + value + "\n";
value = buttonNode.getSecurityEngineName(
FormNodeP.SEOPERATION_LISTIDENTITIES);
s+= " Test 3: " + value + "\n";
}
alert(s);
}
--- Results of getSecurityEngineName test --- Test 1: ClickWrap Test 2: ClickWrap Test 3: ClickWrap
This method returns the signature lock count of a node. If 0 is returned, the node is not signed by any digital signature, but it may have descendants that are signed.
The number of locks on the given node. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code retrieves the number of signature locks on PAGE1.FIELD1 and displays the result in a JavaScript alert() window.
function testGetSigLockCount(theForm) {
var fieldNode;
var s;
s = "--- testGetSigLockCount results ---\n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.FIELD1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(fieldNode == null) {
s += "Cannot find PAGE1.FIELD1";
} else {
s += " Signature lock count for PAGE1.FIELD1: "
+ fieldNode.getSigLockCount() + "\n";
}
alert(s);
}
--- Results of getSigLockCount test --- Signature lock count for PAGE1.FIELD1: 1
When called, this method checks to see if the digital signatures in a given form are valid.
a Number having one of the following values:
| Code | Status |
|---|---|
| FormNodeP.UFL_SIGS_OK | The signatures are valid. |
| FormNodeP.UFL_SIGS_NOTOK | One or more signatures are broken. |
| FormNodeP.UFL_SIGS_UNVERIFIED | One or more signatures are unverifiable. |
On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code determines the validity of the signatures on a form and displays the results in a JavaScript alert() window.
function testGetSignatureVerificationStatus(theForm) {
var s;
var status;
s = "--- Results of getSignatureVerificationStatus test ---\n";
status = theForm.getSignatureVerificationStatus();
switch (status) {
case FormNodeP.UFL_SIGS_OK:
s += " All signatures are valid.\n";
break;
case FormNodeP.UFL_SIGS_NOTOK:
s += " One or more signatures are broken.\n";
break;
case FormNodeP.UFL_SIGS_UNVERIFIED:
s += " One or more signatures are unverifiable.\n";
break;
default:
s += " Unknown status.\n";
break;
}
alert(s);
}
--- Results of getSignatureVerificationStatus test --- All signatures are valid.
Returns true if the node is signed, false if it is not. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code checks PAGE1.FIELD1 and PAGE1.FIELD2 for signatures. The results are displayed in a JavaScript alert() window.
function testIsSigned(theForm) {
var s;
var node;
s = "--- Results of isSigned test ---\n";
node = theForm.dereferenceEx(null, "PAGE1.FIELD1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(node == null) {
s += "Could not find FIELD1 on the form.\n";
} else {
s += " FIELD1 is ";
if(node.isSigned(true) == false) s += "not ";
s += "signed.\n";
}
node = theForm.dereferenceEx(null, "PAGE1.FIELD2", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(node == null) {
s += "Could not find FIELD2 on the form.\n";
} else {
s += " FIELD2 is ";
if(node.isSigned(true) == false) s += "not ";
s += "signed.\n";
}
alert(s);
}
--- Results of isSigned test --- FIELD1 is signed. FIELD2 is not signed.
This method returns the boolean result of whether a string is valid according to the setting of the node's format option.
| Expression | Type | Description |
|---|---|---|
| string | String | A string to be checked against the format. For example, to check 23.2 against a specific format, the string would be “23.2”. |
The method returns true if the string matches the format, but false if the string does not match the format. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code checks to see if the strings '42' and '20071001' are valid for PAGE1.FIELD1. The results are displayed in a JavaScript alert message.
function testIsValidFormat(theForm) {
var s;
var node;
s = "--- Results of isValidFormat test ---\n";
node = theForm.dereferenceEx(null, "PAGE1.FIELD1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(node == null) {
s += "Could not find FIELD1 on the form.\n";
} else {
s += " The value '42' is ";
if(node.isValidFormat("42") == false) s += "not ";
s += "a valid format for FIELD1.\n";
s += " The value '20071001' is ";
if(node.isValidFormat("20071001") == false) s += "not ";
s += "a valid format for FIELD1.\n";
}
alert(s);
}
--- Results of isValidFormat test --- The value '42' is not a valid format for FIELD1. The value '20071001' is a valid format for FIELD1.
This method determines whether a node belongs to the XFDL namespace.
Each namespace is defined in the form by a namespace declaration, as shown:
xmlns:xfdl="http://www.ibm.com/xmlns/prod/XFDL/7.5" xmlns:custom="http://www.ibm.com/xmlns/prod/XFDL/Custom"
Each namespace declaration defines both a prefix and a URI for the namespace. In this sample, the prefix for the XFDL namespace is xfdl and the URI is http://www.ibm.com/xmlns/prod/XFDL/7.5.
Tags within the form are assigned specific namespaces by using the defined prefix. For example, to declare that an option is in the custom namespace, use the prefix custom as shown:
<field sid="testField">
<custom:custom_option>value</custom:custom_option>
</field>
Returns true if the node is in the XFDL namespace, false if it is not. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code calls the isXFDL function on several nodes, starting with the global page node and moving down the hierarchy one child node at a time. The results are displayed in a JavaScript alert() window.
function testIsXFDL(theForm)
{
var fieldNode, tempNode;
var s;
s = "--- Results of isXFDL test ---\n";
fieldNode = theForm.dereferenceEx(null, "global", 0,
FormNodeP.UFL_PAGE_REFERENCE, null);
if(fieldNode == null) {
s += "Cannot find the global page on this form.\n";
} else {
tempNode = fieldNode;
while(tempNode != null) {
s += " The node '" + tempNode.getLocalName() + "' is ";
if(tempNode.isXFDL() != true) s += "NOT ";
s += "in the XFDL namespace.\n";
tempNode = tempNode.getChildren();
}
}
alert(s);
}
If the form is created in the designer (which adds the <designer:date> element to the global page) then the message displayed in the alert box should be similar to this:
--- Results of isXFDL test --- The node 'globalpage' is in the XFDL namespace. The node 'global' is in the XFDL namespace. The node 'date' is NOT in the XFDL namespace.
This method removes a specific attribute from a node. For example, the following XFDL represents a value node:
<value custom:myAtt="x"></value>
To remove the custom attribute from this node, you would use removeAttribute.
| Expression | Type | Description |
|---|---|---|
| uri | String | The namespace URI for the attribute.
For example: http://www.ibm.com/xmlns/prod/XFDL/7.5 |
| localName | String | The local name of the attribute. For example, compute, encoding, and so on. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
If an attribute is on a node in a non-XFDL namespace, and that attribute has no namespace prefix, then the attribute is in the null namespace. For example, the following node is the custom namespace, as is the first attribute, but since the second attribute does not have a namespace prefix, it is in the null namespace:
<custom:processing custom:stage="2" user="tjones">
When an attribute is the null namespace, you may either provide a null value for the namespace URI or use the namespace URI for the containing element.
For example, to indicate user attribute on the processing node, you could use the null namespace or the custom namespace URI.
If you refer to an attribute with a namespace prefix, removeAttribute first looks for a complete match, including both prefix and attribute name. If it does not find such a match, it will look for a matching attribute name that has no prefix but whose containing element has the same namespace.
For example, assume that the custom namespace and the test namespace both resolve to the same URI. In the following case, looking for the id attribute would locate the second attribute (test:id), since it has an explicit namespace declaration:
<a xmlns:custom="ABC" xmlns:test="ABC">
<custom:myElement id="1" test:id="2">
</a>
However, in the next case, the id attribute does not have an explicit namespace declaration. Instead, it inherits the custom namespace. However, since the inherited namespace resolves to the same URI, the id attribute is still located:
<custom:myElement id="1">
The sample code removes two attributes from PAGE1.LABEL1. Note that it is not an error to attempt to remove attributes that do not exist.
function testRemoveAttribute(theForm) {
var s;
var pageNode;
s = "--- Results of removeAttribute test ---\n";
pageNode = theForm.dereferenceEx(null, "PAGE1.LABEL1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(pageNode == null) {
s += " Could not find PAGE1.LABEL1 on the form.";
} else {
pageNode.removeAttribute("http://www.ibm.com/xmlns/prod/XFDL/Custom", "test");
pageNode.removeAttribute(null, "test");
s += " Attributes were removed from PAGE1.LABEL1\n";
}
alert(s);
}
--- Results of removeAttribute test --- Attributes were removed from PAGE1.LABEL1
This method will either remove an enclosure from a specific datagroup or delete the enclosure from the form. Call this method on the FormNodeP that contains the enclosure that you want to remove.
| Expression | Type | Description |
|---|---|---|
| dataGroup | String | The datagroup that contains the enclosed item. If null, the item will be removed from all datagroups. If an item no longer belongs to any datagroups, it is deleted from the form. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code locates a data node with dereferenceEx then removes it from the form with removeEnclosure. The results are displayed in a JavaScript alert box.
function testRemoveEnclosure(theForm) {
var s;
var groupNode;
s = "--- Results of encloseFile test ---\n";
groupNode = theForm.dereferenceEx(null, "PAGE1.xmldata", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(groupNode == null) {
s += " Could not find data group.";
} else {
groupNode.removeEnclosure(null);
s += " The enclosure was removed from the form";
}
alert(s);
}
--- Results of encloseFile test --- The enclosure was removed from the form
This method deregisters an event handling function that was previously registered with the addOnBlur method.
void removeOnBlur ( Function handler );
| Expression | Type | Description |
|---|---|---|
| handler | Function | The name of the function to deregister. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code removes an onBlur event handler from BUTTON1.
function deregisterButtonEvent(theForm) {
var buttonNode;
var s;
s = "--- Results of deregisterButtonEvent function call ---\n";
buttonNode = theForm.dereferenceEx(null, "PAGE1.BUTTON1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(buttonNode == null) {
s += " Could not find BUTTON1 on the form.\n";
} else {
buttonNode.removeOnBlur(button1OnBlur);
s += " Function button1OnBlur deregistered.\n";
}
alert(s);
}
--- Results of deregisterButtonEvent function call --- Function button1OnBlur deregistered.
This method deregisters an event handling function that was previously registered with the addOnChange method.
void removeOnChange ( Function handler );
| Expression | Type | Description |
|---|---|---|
| handler | Function | The name of the function to deregister. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code removes an onChange event handler from BUTTON1.
function deregisterButtonEvent(theForm) {
var buttonNode;
var s;
s = "--- Results of deregisterButtonEvent function call ---\n";
buttonNode = theForm.dereferenceEx(null, "PAGE1.BUTTON1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(buttonNode == null) {
s += " Could not find BUTTON1 on the form.\n";
} else {
buttonNode.removeOnChange(button1OnChange);
s += " Function button1OnChange deregistered.\n";
}
alert(s);
}
--- Results of deregisterButtonEvent function call --- Function button1OnChange deregistered.
This method deregisters an event handling function that was previously registered with the addOnClick method.
void removeOnClick ( Function handler );
| Expression | Type | Description |
|---|---|---|
| handler | Function | The name of the function to deregister. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code removes an onClick event handler from BUTTON1.
function deregisterButtonEvent(theForm) {
var buttonNode;
var s;
s = "--- Results of deregisterButtonEvent function call ---\n";
buttonNode = theForm.dereferenceEx(null, "PAGE1.BUTTON1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(buttonNode == null) {
s += " Could not find BUTTON1 on the form.\n";
} else {
buttonNode.removeOnClick(button1OnClick);
s += " Function button1OnClick deregistered.\n";
}
alert(s);
}
--- Results of deregisterButtonEvent function call --- Function button1OnClick deregistered.
This method deregisters an event handling function that was previously registered with the addOnFocus method.
void removeOnFocus ( Function handler );
| Expression | Type | Description |
|---|---|---|
| handler | Function | The name of the function to deregister. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code removes an onFocus event handler from BUTTON1.
function deregisterButtonEvent(theForm) {
var buttonNode;
var s;
s = "--- Results of deregisterButtonEvent function call ---\n";
buttonNode = theForm.dereferenceEx(null, "PAGE1.BUTTON1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(buttonNode == null) {
s += " Could not find BUTTON1 on the form.\n";
} else {
buttonNode.removeOnFocus(button1OnFocus);
s += " Function button1OnFocus deregistered.\n";
}
alert(s);
}
--- Results of deregisterButtonEvent function call --- Function button1OnFocus deregistered.
This method sets whether the computational system is active. When active, all computes in the form are evaluated on an on-going basis. When inactive, no computes are evaluated.
Note that turning the computational system on causes all computes in the form to be re-evaluated, which can be time consuming.
| Expression | Type | Description |
|---|---|---|
| activeFlag | boolean | Set to true to activate the compute system or false to deactivate the compute system. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code turns the compute system off before creating a compute on PAGE1.FIELD2 that copies the value of FIELD1. It then uses getLiteralByRefEx to store the value of FIELD2 before turning the compute system back on and making another call to getLiteralByRefEx. Finally, it displays the results in a JavaScript alert box.
function testSetActiveForComputationalSystem(theForm) {
var s;
var fieldNode;
s = "--- Results of setActiveForComputationalSystem test ---\n";
fieldNode = theForm.dereferenceEx(null, "PAGE1.FIELD2.value", 0,
FormNodeP.UFL_OPTION_REFERENCE, null);
if(fieldNode == null) {
s += " Could not find PAGE1.FIELD2.value on the form.";
} else {
theForm.setActiveForComputationalSystem(false);
fieldNode.setFormula("PAGE1.FIELD1.value");
s += theForm.getLiteralByRefEx(null, "PAGE1.FIELD2.value", 0, null) + "\n";
theForm.setActiveForComputationalSystem(true);
s += theForm.getLiteralByRefEx(null, "PAGE1.FIELD2.value", 0, null) + "\n";
}
alert(s);
}
--- Results of setActiveForComputationalSystem test --- This is field 1 This is field 2
This method sets the value of a specific attribute for a node. For example, the following XFDL represents a value node:
<value custom:myAtt="x"></value>
To change the custom attribute, you would use setAttribute. If the attribute does not already exist, setAttribute will create it and assign the appropriate value.
| Expression | Type | Description |
|---|---|---|
| uri | String | The namespace URI for the attribute.
For example: http://www.ibm.com/xmlns/prod/XFDL/7.5 |
| localName | String | The local name of the attribute. For example, encoding. |
| value | String | The value to assign to the attribute. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
If an attribute is on a node in a non-XFDL namespace, and that attribute has no namespace prefix, then the attribute is in the null namespace. For example, the following node is the custom namespace, as is the first attribute, but since the second attribute does not have a namespace prefix, it is in the null namespace:
<custom:processing custom:stage="2" user="tjones">
When an attribute is the null namespace, you may either provide a null value for the namespace URI or use the namespace URI for the containing element.
For example, to indicate user attribute on the processing node, you could use the null namespace or the custom namespace URI.
If you refer to an attribute with a namespace prefix, setAttribute first looks for a complete match, including both prefix and attribute name. If it does not find a match, it will look for a matching attribute name that has no prefix but whose containing element has the same namespace.
For example, assume that the custom namespace and the test namespace both resolve to the same URI. In the following case, looking for the id attribute would locate the second attribute (test:id), since it has an explicit namespace declaration:
<a xmlns:custom="ABC" xmlns:test="ABC">
<custom:myElement id="1" test:id="2">
</a>
However, in the next case, the id attribute does not have an explicit namespace declaration. Instead, it inherits the custom namespace. However, since the inherited namespace resolves to the same URI, the id attribute is still located:
<custom:myElement id="1">
The sample code adds two attributes to PAGE1.LABEL1. The first attribute is in the custom namespace, and the second attribute is in the null namespace.
function testSetAttribute(theForm) {
var s;
var pageNode;
s = "--- Results of setAttribute test ---\n";
pageNode = theForm.dereferenceEx(null, "PAGE1.LABEL1", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(pageNode == null) {
s += " Could not find PAGE1.LABEL1 on the form.";
} else {
pageNode.setAttribute(
"http://www.ibm.com/xmlns/prod/XFDL/Custom",
"test", "value");
pageNode.setAttribute(null, "test", "value");
s += " Attributes were added to PAGE1.LABEL1\n";
}
alert(s);
}
--- Results of setAttribute test --- Attributes were added to PAGE1.LABEL1
| Expression | Type | Description |
|---|---|---|
| formula | String | The formula to assign to the node. If null, the formula is assigned as null. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code adds a simple compute to the PAGE1.FIELD3.value node. The compute copies the value of PAGE1.FIELD1 into the value of PAGE1.FIELD3.
function testSetFormula(theForm) {
var s;
var node;
s = "--- Results of setFormula test ---\n";
node = theForm.dereferenceEx(null, "PAGE1.FIELD3.value", 0,
FormNodeP.UFL_OPTION_REFERENCE, null);
if(node == null) {
s += " Could not find PAGE1.FIELD3.value on the form.";
} else {
node.setFormula("PAGE1.FIELD1.value");
s += " Compute was added to PAGE1.FIELD3.value\n";
}
alert(s);
}
--- Results of setFormula test --- Compute was added to PAGE1.FIELD3.value
This method finds a particular FormNodeP as specified by a reference string. Once the FormNodeP is found, its literal will be set as specified. If the FormNodeP does not exist, this method will create it, but only if the FormNodeP would be an option or argument node.
If necessary, this method can create several nodes at once. For example, if you set the literal for the second argument of an itemlocation, this method will create the itemlocation option node and the two argument nodes and then set the literal for the second argument node.
The node that you call this method on is used as the starting point for the search.
void setLiteralByRefEx( String scheme, String reference, Number referenceCode, FormNodeP NSNode, String literal );
| Expression | Type | Description |
|---|---|---|
| scheme | String | Reserved. This must be null. |
| reference | String | A string that contains the reference. |
| referenceCode | Number | Reserved. Must be 0. |
| NSNode | FormNodeP | A node that is used to resolve the namespaces in theReference parameter (see “Determining Namespace” in the Notes section below). Use null if the node that you are calling this method on has inherited the necessary namespaces. |
| literal | String | The string that will be assigned to the literal. If null, any existing literal is removed. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
Before you decide which FormNodeP to use this method on, be sure you understand the following:
For more information about creating a reference, see About references.
Do not set a node that is digitally signed. Doing so will break the digital signature and produce an error.
In some cases, you may want to use the setLiteralByRefEx method to set the value for a node that does not have a globally defined namespace. For example, consider the following form:
<label sid="Label1">
<value>Field1.processing:myValue</value>
</label>
<field sid="Field1" xmlns:processing="URI">
<value></value>
<processing:myValue>10<processing:myValue>
</field>
In this form, the processing namespace is declared in the Field1 node. Any elements within Field1 will understand that namespace; however, elements outside of the scope of Field1 will not.
In cases like this, you will often start your search at a node that does not understand the namespace of the node you are trying to locate. For example, you might want to locate the node referenced in the value of Label1. In this case, you would first locate the Label1 value node and get its literal. Then, from the Label1 value node, you would attempt to locate the processing:myValue node as shown:
Label1Node.setLiteralByRefEx(null, "Field1.processing:myValue", 0,
null, null, "20")
In this example, the setLiteralByRefEx method would fail. The method cannot properly resolve the processing namespace because this namespace is not defined for the Label1 value node. To correct this, you must also provide a node that understands the processing namespace (in this case, any node in the scope of Field1) as a parameter in the method:
Label1Node.setLiteralByRefEx(null, "Field1.processing:myValue", 0,
null, Field1Node, "20")
The sample code sets several values on the node PAGE1.FIELD3 then displays a success or failure message in an alert box.
function testSetLiteralByRefEx(theForm) {
var s;
var node;
s = "--- Results of setLiteralByRefEx test ---\n";
node = theForm.dereferenceEx(null, "PAGE1.FIELD3", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(node == null) {
s += " Cannot locate PAGE1.FIELD3 on the form.\n";
} else {
node.setLiteralByRefEx(null, "fontinfo[fontname]", 0, null, "Verdana");
node.setLiteralByRefEx(null, "fontinfo[fontsize]", 0, null, "10");
node.setLiteralByRefEx(null, "bgcolor", 0, null, "#ff0000");
node.setLiteralByRefEx(null, "fontcolor", 0, null, "white");
node.setLiteralByRefEx(null, "value", 0, null, "This is field 3");
s += " New properties added to PAGE1.FIELD3.\n";
}
}
alert(s);
}
--- Results of setLiteralByRefEx test --- New properties added to PAGE1.FIELD3.
This method sets the literal of a node. You should only set the literal for option or argument nodes.
| Expression | Type | Description |
|---|---|---|
| literal | String | The literal to assign to the node. If null, any existing literal is removed. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code moves PAGE1.FIELD3 to a new location.
function testSetLiteralEx(theForm) {
var s;
var nodeX, nodeY;
s = "--- Results of setLiteralEx test ---\n";
nodeX = theForm.dereferenceEx(null, "PAGE1.FIELD3.itemlocation[x]", 0,
FormNodeP.UFL_ARRAY_REFERENCE, null);
nodeY = theForm.dereferenceEx(null, "PAGE1.FIELD3.itemlocation[y]", 0,
FormNodeP.UFL_ARRAY_REFERENCE, null);
if(nodeX == null || nodeY ==null) {
s += " Could not find PAGE1.FIELD3.itemlocation[x] or [y] on the form.\n";
} else {
nodeX.setLiteralEx("150");
nodeY.setLiteralEx("350");
s += " The node 'PAGE1.FIELD3' has been relocated.\n";
}
alert(s);
}
--- Results of setLiteralEx test --- The node 'PAGE1.FIELD3' has been relocated.
Updates the XForms model by inserting data anywhere within the XForms instance data, or by replacing it entirely. Call this method on the root node of the form or an instance node.
Typically, the default behavior of updateXFormsInstance is to automatically update the XForms data model once a change has been made. However, for forms that are opened using the method with the UFL_XFORMS_INITIALIZE_ONLY flag, the UFL_SERVER_SPEED_FLAGS flag, or the UFL_SERVER_SPEED_FLAGS_WITH_XFORMS flag, the default behavior of updateXFormsInstance is to mark the model for a deferred update. You can override these default settings using the updateType parameter.
void updateXFormsInstance( String modelID, String nodeRef, FormNodeP NSNode, String data, Number updateType );
| Expression | Type | Description |
|---|---|---|
| modelID | String | The ID of the affected model. You must use null to use the default model. |
| nodeRef | String | An XPath reference to a node in the instance that you want to update. An empty string indicates the document node of the default instance of the selected model. |
| NSNode | FormNodeP | A node that inherits the namespaces used in the reference. This node defines the namespaces for the method. Use null if the node that this method is operating on has inherited the necessary namespaces. |
| data | String | The XML data that will be inserted into the XForms instance. |
| updateType | Number | One of the following constants:
XFDL.UFL_XFORMS_UPDATE_REPLACE — Replaces the node that is referenced by theNodeRef with the input instance data. XFDL.UFL_XFORMS_UPDATE_REPLACE_TEXT — Replaces the text of the node that is referenced by theNodeRef with the input data. XFDL.UFL_XFORMS_UPDATE_APPEND — Adds the input data as the last child node of the node that is referenced by theNodeRef. XFDL.UFL_XFORMS_UPDATE_INSERT_ BEFORE — Adds the input data as a sibling of the node that is referenced by theNodeRef. You cannot insert before the root element of the instance. XFDL.UFL_XFORMS_UPDATE_DELETE — Deletes the node that is referenced by theNodeRef. You cannot delete the entire instance. XFDL.UFL_XFORMS_DEFER_MODEL_UPDATE — Marks the XForms model for update, instead of updating the model immediately after data has been changed. XFDL.UFL_XFORMS_SUPPRESS_MODEL_UPDATE — Prevents any automatic updating of the XForms model. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The updateXFormsInstance and the extractXFormsInstance methods are the only methods that are intended to modify the XForms data model.
The sample code inserts the city Moscow into an existing instance, and replaces Paris with Montreal. It then displays the new instance data in a JavaScript alert box.
Instance data:
<xformsmodels>
<xforms:model>
<xforms:instance id="instance1" xmlns="">
<document>
<cities>
<city>Paris</city>
<city>Beijing</city>
</cities>
</document>
</xforms:instance>
</xforms:model>
</xformsmodels>
Sample code:
function testUpdateXFormsInstance(theForm) {
var s, sData;
s = "--- Results of updateXFormsInstance test ---\n\n";
sData = "<city>Moscow</city>"
theForm.updateXFormsInstance(null,
"instance('instance1')/cities",
null, sData, XFDL.UFL_XFORMS_UPDATE_APPEND);
sData = "<city>Montreal</city>"
theForm.updateXFormsInstance(null,
"instance('instance1')/cities/city[1]",
null, sData, XFDL.UFL_XFORMS_UPDATE_REPLACE);
s += "The updated XForms instance:\n";
s += theForm.extractXFormsInstance(null, "", true, true, null);
alert(s);
}
--- Results of updateXFormsInstance test ---
The updated XForms instance:
<document>
<cities>
<city>Montreal</city>
<city>Beijing</city>
<city>Moscow</city>
</cities>
</document>
This method verifies the correctness of all digital signatures in a given form whose root node is provided. It finds all items of type signature and calls verifySignature for each signature. Errors are logged for all non valid signatures.
This method checks the following conditions for each signature:
| Expression | Type | Description |
|---|---|---|
| reportAsErrorsFlag | boolean | Set to true if you want errors about the signatures to be reported by the error reporting system, or false if you want the error code to be only returned through the return value. |
One of the following values:
| Code | Status |
|---|---|
| FormNodeP.UFL_SIGS_OK | The signatures are valid. |
| FormNodeP.UFL_SIGS_NOTOK | One or more signatures are broken. |
| FormNodeP.UFL_SIGS_UNVERIFIED | One or more signatures are unverifiable. |
| FormNodeP.UFL_SIGS_VERIFIEDBUTNOTAUTHENTICATED | This value will only be returned on items that have an HMAC signature. It means that the data is valid, but the shared secret could not be checked for validity. |
If one or more of the signatures is not valid and the reportAsErrorsFlag is true, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code verifies all of the signatures on the form then displays the results in a JavaScript alert box.
function testVerifyAllSignatures(theForm) {
var s;
s = "--- Results of verifyAllSignatures test ---\n";
switch(theForm.verifyAllSignatures(false)) {
case FormNodeP.UFL_SIGS_OK:
s += " All signatures on the form are valid.\n";
break;
case FormNodeP.UFL_SIGS_NOTOK:
s += " One or more signatures are broken.\n";
break;
case FormNodeP.UFL_SIGS_UNVERIFIED:
s += " One or more signatures cannot be verified.\n";
break;
default:
}
alert(s);
}
--- Results of verifyAllSignatures test --- All signatures on the form are valid.
This method verifies the correctness of the given digital signature. You supply the root of the form that contains the signature you want to verify. This method checks the following conditions:
A plain text representation of the form (filtered by the signature item's filter) is constructed and the result is hashed. This hash value must match the hash value stored in the signature.
short verifySignature( FormNodeP signatureItem, StringHolder theCertChain, boolean reportAsErrorsFlag );
| Expression | Type | Description |
|---|---|---|
| signatureItem | FormNodeP | The signature to verify. |
| reportAsErrorsFlag | boolean | Set to true if you want errors about the signatures to be reported by the error reporting system or false if you want the error code to be returned through the return value. |
A Number having one of the following values, depending on the status of the signature:
| Code | Status |
|---|---|
| FormNodeP.UFL_DS_OK | The signature is verified. |
| FormNodeP.UFL_DS_ALGORITHMUNAVAILABLE | The appropriate verification engine for the signature is not available. |
| FormNodeP.UFL_DS_CERTEXPIRED | The certificate has expired. |
| FormNodeP.UFL_DS_CERTNOTFOUND | The certificate cannot be located. |
| FormNodeP.UFL_DS_CERTNOTTRUSTED | The certificate is not trusted. |
| FormNodeP.UFL_DS_CERTREVOKED | The certificate has been revoked. |
| FormNodeP.UFL_DS_CRLINVALID | The certificate revocation list is invalid. |
| FormNodeP.UFL_DS_F2MATCHSIGNER | The certificate does not match the signer's name. |
| FormNodeP.UFL_DS_HASHCOMPFAILED | The document has been tampered with. |
| FormNodeP.UFL_DS_ISSUERCERTEXPIRED | The issuer's certificate has expired. |
| FormNodeP.UFL_DS_ISSUERINVALID | The issuer is invalid for the certificate used to sign. |
| FormNodeP.UFL_DS_ISSUERKEYUSAGE UNACCEPTABLE | The issuer certificate's key usage extension does not match what the key was used for. |
| FormNodeP.UFL_DS_ISSUERNOTCA | The certificate's issuer is not a Certificate Authority. |
| FormNodeP.UFL_DS_ISSUERNOTFOUND | The issuer's certificate was not located. |
| FormNodeP.UFL_DS_ISSUERSIGFAILED | Verification of the issuer's certificate failed. |
| FormNodeP.UFL_DS_KEYREVOKED | The key used to create the signature has been revoked. |
| FormNodeP.UFL_DS_KEYUSAGEUNACCEPTABLE | The certificate's key usage extension does not match what the key was used for. |
| FormNodeP.UFL_DS_KRLINVALID | The Key Revocation List is invalid. |
| FormNodeP.UFL_DS_NOSIGNATURE | There is no signature. |
| FormNodeP.UFL_DS_NOTAUTHENTICATED | The signer cannot be authenticated. |
| FormNodeP.UFL_DS_POLICYUNACCEPTABLE | The certificate's policy extension does not match the acceptable policies. |
| FormNodeP.UFL_DS_SIGNATUREALTERED | The signature has been tampered with. |
| FormNodeP.UFL_DS_UNEXPECTED | An unexpected error occurred. |
| FormNodeP.UFL_DS_UNVERIFIABLE | The signature cannot be verified. |
If the signature is not valid and the reportAsErrorsFlag is true, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code attempts to verify the signature item PAGE1.BUTTON1_SIGNATURE_405824760, and checks for a subset of the possible return values. The results are displayed in an alert box.
function testVerifySignature(theForm) {
var sigNode;
var s;
s = "--- Results of verifySignature test ---\n";
sigNode = theForm.dereferenceEx(null, "PAGE1.BUTTON1_SIGNATURE_405824760", 0,
FormNodeP.UFL_ITEM_REFERENCE, null);
if(sigNode == null) {
s +=" Could not find the signature item.";
} else {
switch(theForm.verifySignature(sigNode, false)) {
case FormNodeP.UFL_DS_OK:
s += " The signature is verified.\n";
break;
case FormNodeP.UFL_DS_ALGORITHMUNAVAILABLE:
s += " Appropriate verification engine is not available.\n";
break;
case FormNodeP.UFL_DS_CERTEXPIRED:
s += " The certificate has expired.\n";
break;
case FormNodeP.UFL_DS_UNEXPECTED:
s += " An unexpected error occured.\n";
break;
case FormNodeP.UFL_DS_UNVERIFIABLE:
s += " The signature cannot be verified.\n";
break;
default:
s += " Signature not valid for unknown reason.\n";
}
}
alert(s);
}
--- Results of verifySignature test --- The signature is verified.
This method updates the XML data model in the form. This is necessary if computes have changed the structure of the data model in some way, such as changing or adding bindings. These sorts of changes do not take effect until the xmlModelUpdate method is called.
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code uses setLiteralByRefEx to change the binding in the form, then calls xmlModelUpdate so that the XML data model reflects the change.
function testXMLModelUpdate(theForm) {
var s;
s = "--- Results of verifySignature test ---\n";
theForm.setLiteralByRefEx(null,
"global.global.xmlmodel[bindings][0][boundoption]",
0, null, "PAGE1.FIELD3.value");
theForm.xmlModelUpdate();
s += " Bound option changed.";
alert(s);
}
--- Results of verifySignature test --- Bound option changed.
The XFDL object contains functions to register and deregister forms in a Web page. You must include the script file LF_XFDL.js at the top of each page that uses the JavaScript API.
Although typed parameters are not used in JavaScript, they are included in the method descriptions to indicate the types that are expected by each method. You declare variables for these parameters using the normal JavaScript var statement.
The getCurrentForm method returns a reference to the form that contains your web page.
The getCurrentForm method is applicable only when getting a reference to the form that is a parent of your web page. To obtain a reference to a form that is a child of your web page, use the ibmForms[] array.
FormNodeP XFDL.getCurrentForm()
This method has no parameters.
The FormNodeP object that represents the form, or Null if a form cannot be found.
The sample code retrieves the version of the form and converts it to a string for display in a JavaScript alert window.
function testGetCurrentForm() {
var version, s;
s = "--- Results of getCurrentForm test ---\n";
version = XFDL.getCurrentForm().getFormVersion().toString(16);
s += " Form Version: " + version;
alert(s);
}
A typical message displayed in the alert window might look like this message, depending on the version of your form:
--- Results of getCurrentForm test --- Form Version: 8000300
This method registers a custom function that handles exceptions thrown by the JavaScript API.
void XFDL.registerAPIExceptionHandler( Function handler );
| Expression | Type | Description |
|---|---|---|
| handler | Function | The name of the function that will be called when a JavaScript API exception is thrown. |
Nothing
Exceptions thrown by the underlying processing code are intercepted by the error handling mechanism of the JavaScript API. Because of this, they cannot be caught with the normal JavaScript try-catch mechanism. Instead, they are either displayed as an error in a JavaScript alert box, or passed to the custom exception handler that you register with the XFDL.registerAPIExceptionHandler method.
function customHandler(ex) {
var s;
s = "Details of the error:\n"
s += "Name: " + ex.name + "\n"
s += "Description: " + ex.message + "\n"
alert(s);
}
The sample code registers a custom error handler. The function is given the name customHandler, but you can use any name that you want.
function OnLoadForm() {
/* web page initialization goes here */
XFDL.registerAPIExceptionHandler(customHandler);
}
An HTML page can host one or more XFDL forms. Use the registerForm method to add the forms to the ibmForms[] forms array.
Call this method after the HTML page has been loaded. After you add a form to the ibmForms[] array, the form becomes accessible to the JavaScript API.
void XFDL.registerForm( FormNodeP theForm, String objectID );
| Expression | Type | Description |
|---|---|---|
| theForm | FormNodeP | The FormNodeP that represents the form to be registered. |
| objectID | String | The id of the HTML object element that contains the Viewer ActiveX control. |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
alert(ibmForms["Main"].getFormVersion().toString(16));
The sample code creates a new FormNodeP object, then registers the form.
function OnLoadForm () {
var theForm = new FormNodeP(objectID);
XFDL.registerForm(theForm, objectID);
/* web page initialization code goes here */
}
This method removes a previously registered form from memory. After calling this method, the form is no longer available to the JavaScript API.
void XFDL.deregisterForm( FormNodeP theForm );
| Expression | Type | Description |
|---|---|---|
| theForm | FormNodeP | The FormNodeP that represents the form to be deregistered |
Nothing. On error, the custom error handler registered by the XFDL.registerAPIExceptionHandler method is called with the details of the error. If no handler is registered, the details of the error are displayed in a JavaScript alert() message.
The sample code deregisters the form that is passed in as the parameter.
function deregister() {
XFDL.deregisterForm(ibmForms[objectID]);
}
References allow you to identify a specific page, item, option, or argument by providing a "path" to that element. This means that you can access an element directly without having to locate any of its ancestors. The syntax of a reference follows this general pattern:
page.item.option[argument]
Each element of the reference is constructed as follows:
Arguments can also have any depth. For example, you might have an argument that contains arguments. You can reference additional levels of depth by adding another bracketed reference. For example, to refer to the first argument in the first argument of the printsettings option, you could use either [0][0] or the tag names in brackets, such as [pages][filter].
You can create references to any level of the node hierarchy. For example, the following table illustrates a number of references starting at different levels of the form:
| Start At | Ref to Page | Ref to Item | Ref to Option | Ref to Argument |
|---|---|---|---|---|
| Page | Page1 | Page1.Field1 | Page1.Field1.format | Page1.Field1.format[message] |
| Item | — | Field1 | Field1.format | Field1.format[message] |
| Option | — | — | format | format[message] |
| Argument | — | — | — | [message] |
Webform Server unterstützt fast alle XFDL-Optionen.
| Option | Unterstützt |
|---|---|
| acclabel | Y |
| activated | Y |
| active | Y |
| bgcolor | Y |
| border | Y |
| borderinfo | Y |
| colorinfo | Y |
| coordinates | Y |
| cursortype | Y |
| data | Y |
| datagroup | Y |
| delay | Y |
| direction | Y |
| dirtyflag | Y |
| display | Y |
| enclosuresettings | Y |
| excludedmetadata | Y |
| filename | Y |
| first | Y |
| focused | N4 |
| focuseditem | N4 |
| fontcolor | Y |
| fontinfo | Y |
| format | Y |
| formid | Y |
| fullname | Y |
| gradient | Y |
| group | Y |
| help | Y |
| image | Y |
| imagemode | N1 |
| itemfirst | Y |
| itemlast | Y |
| itemlocation | Y |
| itemnext | Y |
| itemprevious | Y |
| justify | Y |
| keypress | N |
| label | Y |
| labelbgcolor | Y |
| labelborder | Y |
| labelfontcolor | Y |
| labelfontinfo | Y |
| last | Y |
| layoutflow | Y |
| layoutinfo | N |
| linespacing | Y2 |
| mimedata | Y |
| mimetype | Y |
| mouseover | N |
| next | Y |
| numericshaping | Y |
| orderingscheme | Y |
| orientation | Y |
| padding | Y |
| pagefirst | Y |
| pageid | Y |
| pagelast | Y |
| pageloading | Y |
| pagenext | Y |
| pageprevious | Y |
| previous | Y |
| printbgcolor | Y |
| printfontcolor | Y |
| printing | Y |
| printlabelbgcolor | Y |
| printlabelfontcolor | Y |
| printsettings | N3 |
| printvisible | Y |
| publicdata | Y |
| readonly | Y |
| requirements | N |
| rowpadding | Y |
| rtf | N |
| saveformat | Y |
| scrollhoriz | Y |
| scrollvert | Y |
| signature | Y |
| signatureimage | Y |
| signdatagroups | Y |
| signdetails | N |
| signer | Y |
| signformat | Y |
| signgroups | Y |
| signinstance | Y |
| signitemrefs | Y |
| signitems | Y |
| signnamespaces | Y |
| signoptionrefs | Y |
| signoptions | Y |
| signpagerefs | Y |
| size | Y |
| suppresslabel | Y |
| texttype | N |
| thickness | Y |
| transmitdatagroups | Y |
| transmitformat | Y |
| transmitgroups | Y |
| transmititemrefs | Y |
| transmititems | Y |
| transmitnamespaces | Y |
| transmitoptionrefs | Y |
| transmitoptions | Y |
| transmitpagerefs | Y |
| triggeritem | Y |
| type | Y |
| ufv_settings | Y5 |
| url | Y |
| value | Y |
| visible | Y |
| writeonly | Y |
| xformsenabled | Y |
| xformsreadonly | Y |
| xformsrequired | Y |
| xformsvalid | Y |
| <custom option> | Y |
1Die Option imagemode übernimmt nur die Standardeinstellung resize.
2Wird für die Option linespacing ein zu kleiner Wert festgelegt, führt dies zu einer Textüberschneidung. Wenn Sie diese Option verwenden, müssen Sie das Formular testen.
3Mit der Optionprintsettings können Sie nur die zu druckenden Seiten festlegen. Diese Option übernimmt keine Dialogfenster- oder Rahmeneinstellungen.
4Standardmäßig werden die Optionen focused und focuseditem nicht unterstützt. Änderungen bei der Hervorhebung werden nicht an den Server weitergeleitet und Sie können keine Berechnungen verwenden, um die Hervorhebung dynamisch festzulegen. Wenn Sie die Datei translator.properties ändern (indem Sie für focusNotificationItems die Einstellung all vornehmen), leitet das Formular Änderungen bei der Hervorhebung an den Server weiter. Dies führt jedoch zu einem übermäßigen Datenaustausch über das Netz.
5Die Option ufv_settings wird nur teilweise unterstützt. Die Einstellungen helpcursor, scrollfieldsonzoom und validoverlap werden von Webform Server nicht unterstützt.
Die vorliegenden Informationen wurden für Produkte und Services entwickelt, die auf dem deutschen Markt angeboten werden.
Möglicherweise bietet IBM die in dieser Dokumentation beschriebenen Produkte, Services oder Funktionen in anderen Ländern nicht an. Informationen über die gegenwärtig im jeweiligen Land verfügbaren Produkte und Services sind beim IBM Ansprechpartner erhältlich. Hinweise auf IBM Lizenzprogramme oder andere IBM Produkte bedeuten nicht, dass nur Programme, Produkte oder Services von IBM verwendet werden können. An Stelle der IBM Produkte, Programme oder Services können auch andere, ihnen äquivalente Produkte, Programme oder Services verwendet werden, solange diese keine gewerblichen oder andere Schutzrechte der IBM verletzen. Die Verantwortung für den Betrieb von Produkten, Programmen und Services anderer Anbieter liegt beim Kunden.
Für in diesem Handbuch beschriebene Erzeugnisse und Verfahren kann es IBM Patente oder Patentanmeldungen geben. Mit der Auslieferung dieses Handbuchs ist keine Lizenzierung dieser Patente verbunden. Lizenzanforderungen sind schriftlich an folgende Adresse zu richten (Anfragen an diese Adresse müssen auf Englisch formuliert werden):
IBM Director of Licensing
IBM Corporation
Europe, Middle East & Africa
Tour Descartes
2, avenue Gambetta
92066 Paris La Defense
France
Trotz sorgfältiger Bearbeitung können technische Ungenauigkeiten oder Druckfehler in dieser Veröffentlichung nicht ausgeschlossen werden. Die Angaben in dieser Veröffentlichung werden in regelmäßigen Zeitabständen aktualisiert. Die Änderungen werden in Überarbeitungen oder in Technical News Letters (TNLs) bekannt gegeben. IBM kann jederzeit Verbesserungen und/oder Änderungen an den in dieser Veröffentlichung beschriebenen Produkten und/oder Programmen vornehmen.
Verweise in diesen Informationen auf Websites anderer Anbieter werden lediglich als Service für den Kunden bereitgestellt und stellen keinerlei Billigung des Inhalts dieser Websites dar. Das über diese Websites verfügbare Material ist nicht Bestandteil des Materials für dieses IBM Produkt. Die Verwendung dieser Websites geschieht auf eigene Verantwortung.
Werden an IBM Informationen eingesandt, können diese beliebig verwendet werden, ohne dass eine Verpflichtung gegenüber dem Einsender entsteht.
Lizenznehmer des Programms, die Informationen zu diesem Produkt wünschen mit der Zielsetzung: (i) den Austausch von Informationen zwischen unabhängig voneinander erstellten Programmen und anderen Programmen (einschließlich des vorliegenden Programms) sowie (ii) die gemeinsame Nutzung der ausgetauschten Informationen zu ermöglichen, wenden sich an folgende Adresse:
IBM Corporation
5 Technology Park Drive
Westford Technology Park
Westford, MA 01886
U.S.A.
Die Bereitstellung dieser Informationen kann unter Umständen von bestimmten Bedingungen - in einigen Fällen auch von der Zahlung einer Gebühr - abhängig sein.
Die Lieferung des in diesem Dokument aufgeführten Lizenzprogramms sowie des zugehörigen Lizenzmaterials erfolgt auf der Basis der IBM Rahmenvereinbarung bzw. der Allgemeinen Geschäftsbedingungen von IBM, der IBM Internationalen Nutzungsbedingungen für Programmpakete oder einer äquivalenten Vereinbarung.
IBM, das IBM Logo, ibm.com, Lotus und Notes sind Marken oder eingetragene Marken der IBM Corporation in den USA und/oder anderen Ländern. Sind diese und weitere Markennamen von IBM bei ihrem ersten Vorkommen in diesen Informationen mit einem Markensymbol (® or ™) gekennzeichnet, bedeutet dies, dass IBM zum Zeitpunkt der Veröffentlichung dieser Informationen Inhaber der eingetragenen Marken oder der Common-Law-Marken (common law trademarks) in den USA war. Diese Marken können auch eingetragene Marken oder Common-Law-Marken in anderen Ländern sein. Eine aktuelle Liste der IBM Marken finden Sie auf der Webseite http://www.ibm.com/legal/copytrade.shtml
Java und alle auf Java basierenden Marken und Logos sind Marken oder eingetragene Marken der Oracle Corporation und/oder ihrer verbundenen Unternehmen.
Linux ist eine eingetragene Marke von Linus Torvalds in den USA und/oder anderen Ländern.
Microsoft und Windows sind Marken der Microsoft Corporation in den USA und/oder anderen Ländern.
UNIX ist eine registrierte Marke von The Open Group in den USA und anderen Ländern.
Weitere Unternehmens-, Produkt- oder Servicenamen können Marken anderer Hersteller sein.