I have a complex application. It routinely creates and opens windows into a windowArea by calling a "create window" function. The "create window" function works fine, but backbase throws a mysterious "b has no properties" error each time it executes. After much trial and error I started thinking there might be some kind of thread execution or timing problem. So I wrapped the "create window" function call inside a javascript "setTimeout" command and voila, the problem was solved.
But now whenever I try to create/open a window (by double clicking a b:treeBranch, which calls the "create window" function) I get the message "could not lookup namespace for prefix b". And indeed, the "create window" function does have a reference to the b namespace. Needless to say that namespace has been declared. Unfortunately, in this case backbase seems to have lost the ability to resolve any namespaces. If I remove the reference to the b namespace, it just fails to resolve a different namespace, etc.
Worst of all, if I create/open a window by using drag drop from the b:tree (instead of double click)
1) the window opens with no errors
2) subsequent attempts to open windows by double clicking the b:treeBranch throw no errors
And, of course, the dragDrop handler calls the exact same "window create" function that the dblClick handler calls.
I'm mystified.
Has anyone seen this error before?
Any hints, guesses, or suggestions about how to find a workaround?

Could you post your create
10 July, 2008 - 01:17 — tordonaCould you post your create window function? Perhaps is something you missed or overlooked.
RE: create function
10 July, 2008 - 17:54 — mwrI don't think the problem is the create-window function. Here is a simplified version of the function (which still produces the "could not lookup namespace" error).
<e:body type="application/xml">
<!-- get temporary unique id for the window -->
<e:variable name="iWindowNumber" select="javascript:impact.getNextId()" />
<c:create destination="id('desktop')/b:windowArea" mode="appendChild">
<b:window open="false">
<c:attribute name="window-number" select="$iWindowNumber" />
</b:window>
</c:create>
<e:return select="id('desktop')/b:windowArea/b:window[@window-number eq $iWindowNumber]" />
</e:body>
</e:function>
Windows open properly without the error when:
1) I single click a toolbar icon. The toolbar icon's click handler calls the window create function. Everything OK.
2) I drag drop a b:treeBranch into the windowArea. The windowArea's dragDrop handler calls the window create function. Everything OK. (In addition this somehow "fixes" the problem noted below, so that subsequent dblClicks on treeBranch items are OK.)
The error is produced when:
I dblClick a b:treeBranch. The b:treeBranch's dblClick handler calls the window create function. The window opens with the correct content but the error message is displayed (unless I have first opened a window by dragDropping a b:treeBranch into the windowArea, as noted above).
Maybe something about double-clicking?
That's an interesting case.
10 July, 2008 - 18:18 — tordonaThat's an interesting case. Have you tried changing the event to a single click and test your theory?
or tried explictly declaring the b namespace on the window creation? Not sure the XEL for that, but in JS would look something like:
<![CDATA[
bb.command.create('<b:window xmlns:b="http://www.backbase.com/2006/btl">window content here</b:window>', bb.getProperty(this,'parentNode'));
]]>
</e:handler>
RE: interesting case
10 July, 2008 - 19:27 — mwrUnfortunately error still happens even when I use single click on b:treeBranch and click handler. Blast!
Explicitly declaring the b:namespace doesn't work either. I tried declaring the namespace on the b:window, the c:create, the e:body, and even the b:windowArea (destination of create).
BTW, when this error occurs, Backbase loses the ability to resolve any namespace, not just the "b" namespace.
Oh, and I am using BB 4.1.2
Only time I've seen a
11 July, 2008 - 17:44 — tordonaOnly time I've seen a similar case (Backbase losing the ability to resolve any namespace) is with custom widgets and namespace. Not with b namespace. Sorry can't help much.
RE: only time I've seen a
11 July, 2008 - 19:17 — mwrIt's still a mystery to me, but I think the culprit might be a custom publish/subscribe behavior. Various components in my application use this behavior to report state changes to observer components (e.g. a master controller). In this case the b:tree is publishing a SELECTED message to a master controller. The master controller responds by calling the create/open window function, etc. The point is, if I avoid using the publish/subscribe behavior, and just call the create/open window function directly, all my problems go away.
Unfortunately the publish/subscribe behavior is only about 30 lines of code, and I can't really see what is wrong with it. And not using it breaks compartmentalization or SoC.
Anyway, thanks for your help. It led me to eliminate some possibilities and see the problem a bit more clearly.
I'm going to try to
11 July, 2008 - 19:31 — jbrantlyI'm going to try to reproduce it on my own a little later (traveling today), but I have doubts that I'll be able to. If you could put together a very small, complete example that still exhibits this behavior I think that would be immensely helpful. It also might help you track down the cause of the problem.
- James Brantly
RE: reproducible "could not lookup namespace" error.
11 July, 2008 - 20:07 — mwrJames,
I think it will be possible to reproduce this behavior in a simple test case. I just need to strip out enough code. But I have a deadline to meet, so I won't get to this for a couple of days. Meanwhile, you might take a look at my publish/subscribe behavior and see if anything strikes you as wrongish. The notify-listeners method seems to be the troublemaker.
xmlns:e="http://www.backbase.com/2006/xel"
xmlns:d="http://www.backbase.com/2006/tdl"
xmlns:c="http://www.backbase.com/2006/command"
xmlns:my="http://www.mycompany.com/my">
<d:namespace name="http://www.mycompany.com/my">
<d:behavior name="observable">
<d:property name="listeners" type="array" />
<d:handler event="construct" type="text/javascript">
if (!this._._listeners) {
this._._listeners = []
}
</d:handler>
<d:method name="register-listener">
<d:argument name="listenerName" required="true" type="string" />
<d:argument name="controllerObj" type="object" />
<d:body type="text/javascript">
<![CDATA[
if (typeof controllerObj == "undefined") {
this._._listeners.push({'controller':null,'name':listenerName})
} else {
this._._listeners.push({'controller':controllerObj,'name':listenerName})
}
]]>
</d:body>
</d:method>
<d:method name="register-singleton-listener">
<d:argument name="listenerName" required="true" type="string" />
<d:argument name="controllerObj" type="object" />
<d:body type="text/javascript">
<![CDATA[
this._._listeners = []
bb.callMethod(this,"register-listener",[listenerName,controllerObj])
]]>
</d:body>
</d:method>
<d:method name="remove-listener">
<d:argument name="listenerName" required="true" type="string" />
<d:argument name="controllerObj" type="object" />
<d:body type="text/javascript">
<![CDATA[
var listeners = bb.getProperty(this,"listeners")
for (var n=0; n<listeners.length; n++) {
var listener = listeners[n]
if (listener.controller == null && listener.name == listenerName) {
listeners.splice(n,1)
break
} else if (listener.controller == controllerObj && listener.name == listenerName) {
listeners.splice(n,1)
break
}
}
]]>
</d:body>
</d:method>
<d:method name="notify-listeners">
<d:argument name="message" default="no message" type="string" />
<d:argument name="context" type="variant" />
<d:body type="text/javascript">
<![CDATA[
var listeners = bb.getProperty(this,"listeners")
for (var n=0; n<listeners.length;n++) {
var listener = listeners[n]
if (listener.controller == null) {
// using following line results in "b has no properties" errors in javascript debugger
bb.callFunction(listener.name,[message,context])
// using following line results in "could not lookup namespace" error in backbase debugger
//setTimeout(function(name,args){bb.callFunction(name,args)},0,listener.name,[message,context])
} else {
bb.callMethod(listener.controller,listener.name,[message,context])
//setTimeout(function(context,name,args){bb.callMethod(context,name,args)},0,listener.controller,listener.name,[message,context])
}
}
]]>
</d:body>
</d:method>
</d:behavior>
</d:namespace>
</d:tdl>
Test case for "Could not lookup namespace" error
25 July, 2008 - 21:27 — mwrI have finally managed to reduce my application to a simple test case that demonstrates this error in bb4.1.2. Could some one confirm whether this is a Backbase bug or just a mysterious "feature"?
What's in the test case:
index.html contains the application GUI (a b:windowArea and b:taskBar), some functions for creating windows, opening windows, and listening to windows, and some custom behaviors, chiefly the "observable" (publish/subscribe) behavior.
object-selector.xml is just a b:tree that represents an object selector. It has some drag behaviors for loading objects by either 1) dragging their corresponding b:treeBranch onto the browser or 2) double-clicking on the corresponding b:treeBranch
test-response.xml is just some static content which serves as a stand-in for a complex object.
How to reproduce the error:
Run the application. Drag any of the branches of the b:tree away from the b:tree window and drop it into the windowArea. A new window will open that contains the object representation. Close the window. Now double-click any of the branches of the b:tree. You will see the error message "XPATH: could not lookup namespace for prefix 'b'."
What's going on here:
Both drag-and-drop and double-click cause the same function ("load-object") to be executed. However, the b:windowArea dragDrop handler calls this function directly. The b:treeBranch dblClick handler calls the function indirectly by calling the notify-listeners method of the observable behavior, which calls the load-object function using a javascript setTimeout command.
Workaround:
I can avoid this bug by simply changing notify-listeners so that it does not use a setTimeout command. However
The test case:
*** The index.html file ***
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Backbase 4.1.2 Test Case</title>
<!-- The engine. -->
<script type="text/javascript" src="/Backbase/4_1_2/engine/boot.js"></script>
<!-- The application styles. -->
<style type="text/css">
html,
body {
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
#desktop {
width:100%;
height:100%;
background-color:#CCFFCC;
margin:5px 5px 0 5px;
padding-right:10px;
padding-bottom:7px;
}
</style>
</head>
<body>
<!-- The script element that contains the GUI. -->
<script type="text/backbase+xml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:b="http://www.backbase.com/2006/btl"
xmlns:c="http://www.backbase.com/2006/command"
xmlns:d="http://www.backbase.com/2006/tdl"
xmlns:e="http://www.backbase.com/2006/xel"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:my="http://www.mycompany.com/my"
style="height:100%;width:100%">
<!-- include BTL widgets -->
<xi:include href="/Backbase/4_1_2/bindings/config.xml" />
<!-- *********************************************************************************************** -->
<!-- CUSTOM BEHAVIORS -->
<!-- *********************************************************************************************** -->
<d:tdl>
<d:namespace name="http://www.mycompany.com/my">
<d:behavior name="observable">
<d:property name="listeners" type="array" />
<d:handler event="construct" type="text/javascript">
if (!this._._listeners) {
this._._listeners = []
}
</d:handler>
<d:method name="register-listener">
<d:argument name="listenerName" required="true" type="string" />
<d:argument name="controllerObj" type="object" />
<d:body type="text/javascript">
<![CDATA[
if (typeof controllerObj == "undefined") {
this._._listeners.push({'controller':null,'name':listenerName})
} else {
this._._listeners.push({'controller':controllerObj,'name':listenerName})
}
]]>
</d:body>
</d:method>
<d:method name="notify-listeners">
<d:argument name="message" default="no message" type="string" />
<d:argument name="context" type="variant" />
<d:body type="text/javascript">
<![CDATA[
var listeners = bb.getProperty(this,"listeners")
for (var n=0; n<listeners.length;n++) {
var listener = listeners[n]
if (listener.controller == null) {
// bb.callFunction(listener.name,[message,context])
setTimeout(function(name,args){bb.callFunction(name,args)},0,listener.name,[message,context])
} else {
// bb.callMethod(listener.controller,listener.name,[message,context])
setTimeout(function(context,name,args){bb.callMethod(context,name,args)},0,listener.controller,listener.name,[message,context])
}
}
]]>
</d:body>
</d:method>
</d:behavior>
<d:behavior name="desktop" extends="b:dragTarget">
<d:attribute name="dragReceive" default="*" />
<d:handler event="DOMNodeInsertedIntoDocument">
<e:call function="start-application" />
</d:handler>
<d:handler event="dragDrop" defaultAction="cancel">
<e:variable name="source" select="$event/property::dragManager/property::source" />
<e:variable name="dropX" select="javascript:vars['event'].dragManager.lastPoint.x - vars['event'].dragManager.offsetLeft + 4" />
<e:variable name="dropY" select="javascript:vars['event'].dragManager.lastPoint.y - vars['event'].dragManager.offsetTop + 4" />
<e:call function="load-object" />
</d:handler>
<d:handler event="dragEnd" defaultAction="cancel">
<c:alert select="'dragEnd'" />
</d:handler>
</d:behavior>
</d:namespace>
</d:tdl>
<!-- *********************************************************************************************** -->
<!-- APPLICATION LOGIC -->
<!-- *********************************************************************************************** -->
<e:xel>
<e:function name="start-application">
<e:body type="application/xml">
<!-- loading any file into a variable before loading the object-selector triggers -->
<!-- a bug; uncomment this code to produce the "cannot lookup namespace b" error -->
<!--<e:variable name="temp"><c:load method="get" url="test-response.xml" /></e:variable>-->
<!-- load the object selector -->
<e:variable name="theWindow"><e:call function="create-window" type="'Object Selector'" top="'100px'" left="'50px'" width="'250px'" height="'440px'" /></e:variable>
<c:load url="object-selector.xml" destination="$theWindow" mode="replaceChildren" />
<c:setAttribute with="$theWindow" name="open" select="'true'" />
<!-- register listener with the object selector -->
<e:call with="$theWindow//div[@id eq 'object-selector']" method="register-listener">
<e:with-argument name="listenerName" select="'object-selector-listener'" />
</e:call>
</e:body>
</e:function>
<e:function name="create-window">
<e:argument name="type" />
<e:argument name="top" />
<e:argument name="left" />
<e:argument name="width" />
<e:argument name="height" />
<e:body type="application/xml">
<c:create destination="id('desktop')/b:windowArea" mode="appendChild">
<b:window open="false">
<c:attribute name="label" select="$type" />
<c:attribute name="top" select="$top" />
<c:attribute name="left" select="$left" />
<c:attribute name="width" select="$width" />
<c:attribute name="height" select="$height" />
</b:window>
</c:create>
<e:return select="id('desktop')/b:windowArea/b:window[@label eq $type]" />
</e:body>
</e:function>
<e:function name="load-object">
<e:body type="application/xml">
<!-- create a new window -->
<e:variable name="theWindow">
<e:call function="create-window" type="'Object Template'" top="'100px'" left="'400px'" width="'440px'" height="'440px'" />
</e:variable>
<!-- load test content -->
<c:load async="false" url="test-response.xml" destination="$theWindow" mode="replaceChildren" />
<!-- open window -->
<c:setAttribute with="$theWindow" name="open" select="'true'" />
</e:body>
</e:function>
<e:function name="object-selector-listener">
<e:argument name="message" type="string" />
<e:argument name="context" type="variant" />
<e:body type="application/xml">
<e:choose>
<e:when test="$message eq 'OBJECT_SELECTED'">
<e:call function="load-object" />
</e:when>
</e:choose>
</e:body>
</e:function>
</e:xel>
<!-- *********************************************************************************************** -->
<!-- APPLICATION GUI -->
<!-- *********************************************************************************************** -->
<div id="desktop" e:behavior="my:desktop">
<b:windowArea height="100%" width="100%">
<b:taskBar windowArea="id('desktop')/b:windowArea[1]" />
</b:windowArea>
</div>
</script>
</body>
</html>
*** The "object-selector.xml" file ***
<div xmlns="http://www.w3.org/1999/xhtml"
xmlns:b="http://www.backbase.com/2006/btl"
xmlns:c="http://www.backbase.com/2006/command"
xmlns:d="http://www.backbase.com/2006/tdl"
xmlns:e="http://www.backbase.com/2006/xel"
xmlns:my="http://www.mycompany.com/my"
id="object-selector"
e:behavior="my:observable">
<d:tdl>
<d:namespace name="http://www.mycompany.com/my">
<d:uses behavior="observable" src="observable.xml" />
<d:behavior name="selector-tree-branch" extends="b:drag b:dragTarget">
<d:attribute name="dragMode" default="symbol" />
<d:handler event="dblclick" propagate="stop">
<!-- notify listeners that user double-clicked on a change request -->
<e:call with="id('object-selector')" method="notify-listeners">
<e:with-argument name="message" select="'OBJECT_SELECTED'" />
</e:call>
<!-- Note: Following code is one workaround for the "could not lookup -->
<!-- namespace for prefix b" bug that is triggered by the code above. -->
<!--<e:call function="load-object" />-->
</d:handler>
</d:behavior>
</d:namespace>
</d:tdl>
<div purpose="object-selector-tree">
<b:tree purpose="object-selector-tree" selectType="single" overflow="visible" style="position:static">
<b:treeBranch label="Object Type1" e:behavior="my:selector-tree-branch">
<b:treeLeaf label="not" e:behavior="my:selector-tree-branch" />
<b:treeLeaf label="implemented" e:behavior="my:selector-tree-branch" />
<b:treeLeaf label="yet" e:behavior="my:selector-tree-branch" />
</b:treeBranch>
<b:treeBranch label="Object Type2" e:behavior="my:selector-tree-branch">
<b:treeLeaf label="not" e:behavior="my:selector-tree-branch" />
<b:treeLeaf label="implemented" e:behavior="my:selector-tree-branch" />
<b:treeLeaf label="yet" e:behavior="my:selector-tree-branch" />
</b:treeBranch>
<b:treeBranch label="Object Type3" e:behavior="my:selector-tree-branch">
<b:treeLeaf label="not" e:behavior="my:selector-tree-branch" />
<b:treeLeaf label="implemented" e:behavior="my:selector-tree-branch" />
<b:treeLeaf label="yet" e:behavior="my:selector-tree-branch" />
</b:treeBranch>
</b:tree>
</div>
</div>
*** The "test-response.xml" file ***
<div xmlns="http://www.w3.org/1999/xhtml">
<ol>
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
<li>Five</li>
<li>Six</li>
<li>Seven</li>
<li>Eight</li>
<li>Nine</li>
<li>Ten</li>
<li>Eleven</li>
<li>Twelve</li>
<li>Thirteen</li>
<li>Fourteen</li>
<li>Fifteen</li>
<li>Sixteen</li>
<li>Seventeen</li>
<li>Eighteen</li>
<li>Nineteen</li>
<li>Twenty</li>
</ol>
</div>