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

Dynamic Objects in Toolbar

21 views
Skip to first unread message

Matthew Smith

unread,
Nov 3, 2006, 1:04:10 AM11/3/06
to dev-te...@lists.mozilla.org
Hi All

I am something of a XUL newbie, so please bear with me... I have been
unable to determine via Google whether the following is feasible.

Is it possible to have a toolbar that generates on-the-fly using
XMLHttpRequest?

To be more specific, what I would like to achieve is a menupopup where
the menuitem elements are generated from data from an XMLHttpRequest,
when the toolbar is loaded (ie when Firefox is started). It would be
even nicer if this could be refreshed "live", but I am very doubtful
that this would be possible.

If this is possible, can anyone point me to an example? If it is not
possible, any equivalents or work-arounds?

Cheers

M

--
Matthew Smith
IT Consultancy & Web Application Development
Business: http://www.kbc.net.au/
Personal: http://www.smiffysplace.com/
LinkedIn: http://www.linkedin.com/in/smiffy

Nickolay Ponomarev

unread,
Nov 3, 2006, 4:12:41 AM11/3/06
to Matthew Smith, dev-te...@lists.mozilla.org
On 11/3/06, Matthew Smith <ma...@kbc.net.au> wrote:
> Is it possible to have a toolbar that generates on-the-fly using
> XMLHttpRequest?
>
Yes, sure.

> To be more specific, what I would like to achieve is a menupopup where
> the menuitem elements are generated from data from an XMLHttpRequest,
> when the toolbar is loaded (ie when Firefox is started).

Live bookmarks work like this, although I don't know if they use
XMLHttpRequest under the hood. You could try looking at the part of
firefox source that deals with live bookmarks.

Off the top of my head, I see a few ways to implement this
1) By building your menupopup from an RDF datasource, which could be
generated on the server. I dislike RDF, so I personally probably
wouldn't use it.
2) By getting data (e.g. JSON string) from the server, parsing it on
client, and building the menupopup using DOM methods (such as
document.createElementNS).
3) By getting data as XML from the server.
- server can just send the XUL code to use for popup
- alternatively it can send generic XML describing the attributes of
the items in the menu and you generate the XUL on client by applying
an XSLT transform.

Nickolay

Neil

unread,
Nov 3, 2006, 6:12:18 AM11/3/06
to
Nickolay Ponomarev wrote:

> 3) By getting data as XML from the server.
> - server can just send the XUL code to use for popup
> - alternatively it can send generic XML describing the attributes of
> the items in the menu and you generate the XUL on client by applying
> an XSLT transform.

Does this work? I know some parts of our DOM dislike being added to
documents that don't own them.

--
Warning: May contain traces of nuts.

Nickolay Ponomarev

unread,
Nov 3, 2006, 6:27:12 AM11/3/06
to Neil, dev-te...@lists.mozilla.org
Not sure. I myself have doubts on this, but seem to recall that
someone had this working.

Nickolay

Igor Tandetnik

unread,
Nov 3, 2006, 10:36:32 AM11/3/06
to

XSLTProcessor.transformToFragment takes as a parameter a document
object. The result is a document fragment owned by that document. One
then can use DOM methods to merge the fragment into the document.

Igor Tandetnik


0 new messages