[Xsltforms-support] [PATCH] No usefull message for non-existent bind-ids
Brought to you by:
alain-couthures
From: Kostis A. <ank...@gm...> - 2010-04-07 22:06:20
|
When a control's 'bind' attrribute refers to an xf:bind that does not exist, the javascript just fails with Null-Pointer message on browser console instead of reporting the bad bind-id. Reported against rev383, all browsers. The simple xform below reproduces the problem, and the following patch just issues a useful alert-window for each non-existent bind-id: Regards, Kostis file: nonExistentBindId.xml: ------------------ <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet href="xsltforms/xsltforms.xsl" encoding="UTF-8" type="text/xsl"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.w3.org/2002/xforms http://www.w3.org/MarkUp/Forms/2007/XForms-11-Schema.xsd " > <head> <title>Control with non-existent bind-id</title> </head> <body> The output control's binding below silently fails (with an un-helpful null-pointer err-message visible only on the browser's console). <xf:output bind="missing-bind-id" /> <xf:output bind="missing-bind-id2" /> </body> </html> file: nonExistentBindId.diff ---------------- Index: src/js/main/Binding.js.xml =================================================================== --- src/js/main/Binding.js.xml (revision 383) +++ src/js/main/Binding.js.xml (working copy) @@ -48,7 +48,14 @@ var result = null; if (this.bind) { if (typeof this.bind == "string") { - this.bind = $(this.bind).xfElement; + var idel = $(this.bind); + if (!idel) { + alert("Non-Existent bind-id: "+this.bind); + + // Do not fail here, to search for more missing ids. + return ''; + } + this.bind = idel.xfElement; } result = this.bind.nodes; copyArray(this.bind.depsNodes, depsNodes); |