Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Code under <implementation> never gets run

1 view
Skip to first unread message

stechz

unread,
Apr 14, 2008, 8:17:24 PM4/14/08
to
I'm working on a Firefox extension. I was trying the MDC tutorial
located here: http://developer.mozilla.org/en/docs/XUL_Tutorial:XBL_Example.
The widgets show up fine, but the slideshow constructor is not getting
called and the method setPage does not exist when I try to call it, so
nothing under the implementation node seems to be parsed. Thoughts?
Here is what my XBL file looks like:

<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/
there.is.only.xul">

<binding id="slideshow">
<content>
<xul:vbox flex="1">
<xul:deck xbl:inherits="selectedIndex" selectedIndex="0"
flex="1">
<children/>
</xul:deck>
<xul:hbox>
<xul:button xbl:inherits="label=previoustext"

oncommand="parentNode.parentNode.parentNode.page--;"/>
<xul:description flex="1"/>
<xul:button xbl:inherits="label=nexttext"
oncommand="parentNode.parentNode.parentNode.page+
+;"/>
</xul:hbox>
</xul:vbox>
</content>

<implementation>
<constructor>
alert('nice');
var totalpages=this.childNodes.length;
document.getAnonymousNodes(this)
[0].childNodes[1].childNodes[1]
.setAttribute("value",(this.page+1)+" of
"+totalpages);
</constructor>

<property name="page"
onget="return parseInt(document.getAnonymousNodes(this)
[0].childNodes[0].getAttribute('selectedIndex'));"
onset="return this.setPage(val);"/>

<method name="setPage">
<parameter name="newidx"/>
<body>
<![CDATA[
var thedeck=document.getAnonymousNodes(this)
[0].childNodes[0];
var totalpages=this.childNodes.length;

if (newidx<0) return 0;
if (newidx>=totalpages) return totalpages;
thedeck.setAttribute("selectedIndex",newidx);
document.getAnonymousNodes(this)
[0].childNodes[1].childNodes[1]
.setAttribute("value",(newidx+1)+" of
"+totalpages);
return newidx;
]]>
</body>
</method>
</implementation>
</binding>
</bindings>

I have an overlay into the browser that looks like:

<?xml version="1.0"?>
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/
there.is.only.xul">
<window id="main-window" style="-moz-binding: url(chrome://
myextension/path/to/xbl.xml#slideshow);">
<box height="100" class="slideshow"/>
</window>
</overlay>

stechz

unread,
Apr 15, 2008, 2:17:17 PM4/15/08
to
For anyone who needs the answer someday: I had put my XBL file in the
extension's skin directory instead of content. After that, everything
worked fine.

Boris Zbarsky

unread,
Apr 16, 2008, 12:58:15 AM4/16/08
to
stechz wrote:
> For anyone who needs the answer someday: I had put my XBL file in the
> extension's skin directory instead of content.

Ah, yeah. No script allowed in skin XBL. That should probably be documented
somewhere...

-Boris

0 new messages