Java applets from a extension directly embedded in a XUL document (via a HTML-Namespace) seem to be a difficult thing to achieve. They are not only close to impossible to reference (Java plugin obviously doesn’t know
chrome://-URIs) but also seem to be restricted to 300x300px. Not good. As our project depends strongly on data exchange between an applet and XUL code I searched the dark alleys of old forum entries and found a different approach yesterday and implemented it:
- The applet is embedded not in XUL but in a HTML page that is contained in an
- The applet may access the embedding HTML by
- In HTML a script generates a custom
DOMElement, puts the data to hand over to the extension JSONified in an attribute x and finally fires a custom
EventA, which is bubbling up through all parent nodes, …
- … until the listening extension captures this custom
EventA. Data is read from the attribute x, handled and return values are written in another attribute y of said
DOMElement. Then the extension itself fires another custom
EventB from the Element.
- The script in the HTML listens to
EventB, and — when fired — reads the returned value from attribute y and passes it to the applet.
Easy, isn’t it?
So much hoops to jump through to solve such a seemingly simple task! And that only because the Java / Firefox bridges are mostly ropeways…
Communication between HTML and extension works so far, source code will be posted tomorrow. When I finished tackling the applet-to-HTML-thingy I will update, promised.