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

loadoverlay and remote app issue

16 views
Skip to first unread message

LF

unread,
Aug 14, 2007, 10:43:55 AM8/14/07
to
I'm new to XUL and I'm trying to get loadoverlay working in a remote
test.

Below there is the skeleton of the code. Observer says "Overlay loaded
successfully" but I don't see anything. If I call the overlay directly
I get the tabbox I'm trying to add.

I've read many things about security and remote app but I didn't
understand really what's possible and what's not. Everything come from
the same remote source.

Any help?

best regards,
Lorenzo Fiorini

In the caller I have:
...
<box id="overlay" />
...
function buttonLoadOvlPressed(event)
{
var callback = {
observe : function (subject, topic, data) {
if (topic == 'xul-overlay-merged') {
alert("Overlay loaded successfully");
}
}
};
window.document.loadOverlay("http://host:8085/
overlay", callback);
}
...
document.getElementById("loadovlbutton").addEventListener('command',
buttonLoadOvlPressed, true);
...

>From the http://host:8085/overlay I get:

<?xml version="1.0"?>

<overlay id="toverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/
there.is.only.xul">

<box id="overlay">
<tabbox id="Tab1" selectedIndex="2">
<tabs id="Tab1Tabs">
<tab label="A First tab"/>
<tab label="Second tab"/>
<tab label="Another tab"/>
<tab label="Last tab"/>
</tabs>
<tabpanels id="Tab1Panels">
<tabpanel><!-- tabpanel First elements go here --></
tabpanel>
<tabpanel><!-- tabpanel Second elements go here --
></tabpanel>
<tabpanel><button label="Click me"/></tabpanel>
<tabpanel><!-- tabpanel Fourth elements go here --
></tabpanel>
</tabpanels>
</tabbox>
</box>
</overlay>

Christophe Charron

unread,
Aug 14, 2007, 11:12:52 AM8/14/07
to
> >From thehttp://host:8085/overlayI get:

>
> <?xml version="1.0"?>
>
> <overlay id="toverlay"
> xmlns="http://www.mozilla.org/keymaster/gatekeeper/
> there.is.only.xul">
>
> <box id="overlay">
> <tabbox id="Tab1" selectedIndex="2">
> <tabs id="Tab1Tabs">
> <tab label="A First tab"/>
> <tab label="Second tab"/>
> <tab label="Another tab"/>
> <tab label="Last tab"/>
> </tabs>
> <tabpanels id="Tab1Panels">
> <tabpanel><!-- tabpanel First elements go here --></
> tabpanel>
> <tabpanel><!-- tabpanel Second elements go here --></tabpanel>
>
> <tabpanel><button label="Click me"/></tabpanel>
> <tabpanel><!-- tabpanel Fourth elements go here --></tabpanel>
>
> </tabpanels>
> </tabbox>
> </box>
> </overlay>

I tried and failed !!!

http://test03.christophe-charron.org/public/xul/2006_09_07_tests_01/test_about_loadoverlay.html

Best regards,
Christophe Charron

LF

unread,
Aug 14, 2007, 11:23:53 AM8/14/07
to
On Aug 14, 5:12 pm, Christophe Charron
<christophe.charron....@gmail.com> wrote:

> I tried and failed !!!
>

> http://test03.christophe-charron.org/public/xul/2006_09_07_tests_01/t...

Many thanks.

Is there any other method to merge controls on demand to a window?

best regards,
Lorenzo Fiorini

Christophe Charron

unread,
Aug 14, 2007, 1:18:12 PM8/14/07
to

I don't know if it's possible for all controls but you can create a
lot of them with javascript.

Best regards,
Christophe Charron
>
> best regards,
> Lorenzo Fiorini


Question

unread,
Aug 14, 2007, 11:13:11 PM8/14/07
to dev-te...@lists.mozilla.org
Hi,
Here is my experience, maybe helpful.

First, I've tried to add some script tag for XUL to load javascript. Failed.
Because this is not HTML.
And then under the instruction of Neil ,I tried loadOverlay for remote
applications and it does not work for security.
Finally, I use XHR to load the script and eval them.

> _______________________________________________
> dev-tech-xul mailing list
> dev-te...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-xul
>
>


--
>: ~

Christophe Charron

unread,
Aug 15, 2007, 3:13:10 AM8/15/07
to
On 15 août, 05:13, Question <wanli...@gmail.com> wrote:
> Hi,
> Here is my experience, maybe helpful.
>
> First, I've tried to add some script tag for XUL to load javascript. Failed.
> Because this is not HTML.
> And then under the instruction of Neil ,I tried loadOverlay for remote
> applications and it does not work for security.
> Finally, I use XHR to load the script and eval them.
>
I don't reaaly understand the difference beetween first and third
tries. Could you explain ?

Best regards,
Christophe Charron

> On 8/15/07, Christophe Charron <christophe.charron....@gmail.com> wrote:
>
>
>
>
>
> > On 14 août, 17:23, LF <lorenzo.fior...@gmail.com> wrote:
> > > On Aug 14, 5:12 pm, Christophe Charron
>
> > > <christophe.charron....@gmail.com> wrote:
> > > > I tried and failed !!!
>
> > > >http://test03.christophe-charron.org/public/xul/2006_09_07_tests_01/t.
> > ..
>
> > > Many thanks.
>
> > > Is there any other method to merge controls on demand to a window?
>
> > I don't know if it's possible for all controls but you can create a
> > lot of them with javascript.
>
> > Best regards,
> > Christophe Charron
>
> > > best regards,
> > > Lorenzo Fiorini
>
> > _______________________________________________
> > dev-tech-xul mailing list

> > dev-tech-...@lists.mozilla.org
> >https://lists.mozilla.org/listinfo/dev-tech-xul
>
> --
>
> >: ~


Question

unread,
Aug 15, 2007, 5:43:51 AM8/15/07
to dev-te...@lists.mozilla.org
The first one:
In HTML, you can use document.createElement('script') and set "src"
attribute for it and append it to document tree. The browser will load the
script automatically ( I don't know if it's the same with the XHR), you can
addEventListener to it and do your work after loaded.

The third one:
You must new an XHR object to fetch the script content and eval them. And
you may not get the scripts in different domains.

On 8/15/07, Christophe Charron <christophe....@gmail.com> wrote:
>

Christophe Charron

unread,
Aug 15, 2007, 8:25:01 AM8/15/07
to
On 15 août, 11:43, Question <wanli...@gmail.com> wrote:
> The first one:
> In HTML, you can use document.createElement('script') and set "src"
> attribute for it and append it to document tree. The browser will load the
> script automatically ( I don't know if it's the same with the XHR), you can
> addEventListener to it and do your work after loaded.
>
Can't you use document.createElementNS(...) and ...appendChild to
create all kind of elements in xul ?

> The third one:
> You must new an XHR object to fetch the script content and eval them. And
> you may not get the scripts in different domains.
>

LF

unread,
Aug 15, 2007, 3:34:17 PM8/15/07
to
On Aug 15, 5:13 am, Question <wanli...@gmail.com> wrote:

> Finally, I use XHR to load the script and eval them.

Sorry, I've googled for xul remote xmlhttprequest eval but I sill
can't figure it out.

Could you kindly post an example or point me to a resource?

best regards,
Lorenzo Fiorini


LF

unread,
Aug 15, 2007, 3:37:54 PM8/15/07
to
On Aug 15, 2:25 pm, Christophe Charron
<christophe.charron....@gmail.com> wrote:

> Can't you use document.createElementNS(...) and ...appendChild to
> create all kind of elements in xul ?

Wouldn't we loose the "declarative" nature of XUL in this way?

best regards,
Lorenzo

Question

unread,
Aug 15, 2007, 9:47:40 PM8/15/07
to dev-te...@lists.mozilla.org
On 8/15/07, Christophe Charron <christophe....@gmail.com> wrote:
>
> On 15 août, 11:43, Question <wanli...@gmail.com> wrote:
> > The first one:
> > In HTML, you can use document.createElement('script') and set "src"
> > attribute for it and append it to document tree. The browser will load
> the
> > script automatically ( I don't know if it's the same with the XHR), you
> can
> > addEventListener to it and do your work after loaded.
> >
> Can't you use document.createElementNS(...) and ...appendChild to
> create all kind of elements in xul ?


Of course you can create script element in xul, but the problem is xul will
not load its' source automatically.

Question

unread,
Aug 15, 2007, 10:07:07 PM8/15/07
to dev-te...@lists.mozilla.org
var XHR = new XMLHttpRequest();
XHR.open('GET', script_url, false); // init;
XHR.onreadystatechange = function () // set callback, you can also use
onload
{
... // if readyState = 4 && status == 200 then do your callback here, for
example, callback(XHR);
}
XHR.send(''); // if method == "POST" set post data here;

function callback(XHR) // callback
{
var script = XHR.responeseText; // Here is the script you got.
window.eval(script); // Now here may have a trick, make sure you are using
window.eval NOT eval, because of the variable scope problem.
}

These codes are the main work flow, you can complete it yourself. Any way,
there are still a lot of enhancement can be made, for example, a mechanism
to notify the scripts are loaded successful, maintain an array to store
which file had been loaded and ...

John J. Barton

unread,
Aug 16, 2007, 1:09:47 AM8/16/07
to
Question wrote:
> var XHR = new XMLHttpRequest();
> XHR.open('GET', script_url, false); // init;
> XHR.onreadystatechange = function () // set callback, you can also use
> onload
> {
> ... // if readyState = 4 && status == 200 then do your callback here, for
> example, callback(XHR);
> }
> XHR.send(''); // if method == "POST" set post data here;
>
> function callback(XHR) // callback
> {
> var script = XHR.responeseText; // Here is the script you got.
> window.eval(script); // Now here may have a trick, make sure you are using
> window.eval NOT eval, because of the variable scope problem.
> }

You'll probably want to consider evalInSandbox:
http://developer.mozilla.org/en/docs/Components.utils.evalInSandbox

LF

unread,
Aug 16, 2007, 1:35:02 AM8/16/07
to
On Aug 16, 4:07 am, Question <wanli...@gmail.com> wrote:

> var XHR = new XMLHttpRequest();

> ...


> which file had been loaded and ...

Many thanks.

best regards,
Lorenzo Fiorini

LF

unread,
Aug 16, 2007, 2:04:13 AM8/16/07
to
On Aug 14, 5:12 pm, Christophe Charron
<christophe.charron....@gmail.com> wrote:

> I tried and failed !!!

Christophe an all, sorry it was a bug in my code. I had misplaced the
box declaration position.
The code in the top post works as expected.

But why so many reports about not working xul remote? They are quite
misleading.

Is there any "official" resource about "actual" status and "future"
directions of xul platform?

However this issue has showed me that xul community is alive and gives
much help to newbies.

Many thanks again.

best regards,
Lorenzo Fiorini

Christophe Charron

unread,
Aug 16, 2007, 3:35:03 AM8/16/07
to
On 16 août, 08:04, LF <lorenzo.fior...@gmail.com> wrote:
> On Aug 14, 5:12 pm, Christophe Charron
>
> <christophe.charron....@gmail.com> wrote:
> > I tried and failed !!!
>
> Christophe an all, sorry it was a bug in my code. I had misplaced the
> box declaration position.
> The code in the top post works as expected.
>
Do you mean that remote overlay works ?
Could I see a full code example ?

> Is there any "official" resource about "actual" status and "future"
> directions of xul platform?

Have a look here but it's not about xul, just about FF :
http://wiki.mozilla.org/Firefox:Home_Page


Best regards,
Christophe Charron

Neil

unread,
Aug 16, 2007, 4:32:11 AM8/16/07
to
John J. Barton wrote:

> Question wrote:
>
>> var XHR = new XMLHttpRequest();
>> XHR.open('GET', script_url, false); // init;
>> XHR.onreadystatechange = function () // set callback, you can also use
>> onload
>> {
>> ... // if readyState = 4 && status == 200 then do your callback
>> here, for
>> example, callback(XHR);
>> }
>> XHR.send(''); // if method == "POST" set post data here;
>>
>> function callback(XHR) // callback
>> {
>> var script = XHR.responeseText; // Here is the script you got.
>> window.eval(script); // Now here may have a trick, make sure you
>> are using
>> window.eval NOT eval, because of the variable scope problem.
>> }
>
> You'll probably want to consider evalInSandbox:

Doubtful, as he's remote XUL loading his own scripts from his own site.

--
Warning: May contain traces of nuts.

LF

unread,
Aug 16, 2007, 5:04:03 AM8/16/07
to
On Aug 16, 9:35 am, Christophe Charron
<christophe.charron....@gmail.com> wrote:

> Do you mean that remote overlay works ?
> Could I see a full code example ?

...
<button id="loadovlbutton" label="LoadOvl"/>


<box id="overlay" />
...
function buttonLoadOvlPressed(event)
{

// Load an overlay file


var callback = {
observe : function (subject, topic, data) {
if (topic == 'xul-overlay-merged') {
alert("Overlay loaded successfully");
}
}
};

// Load the current file as an overlay
window.document.loadOverlay("http://intranethost:
8085/overlay", callback);
}
...

I'm evaluating xul and I'm working inside my intranet with Linux and
Windows hosts.

Neil, do you mean that it will not work if I'll move the code on
another domain?

best regards,
Lorenzo Fiorini

Christophe Charron

unread,
Aug 21, 2007, 3:01:17 AM8/21/07
to
Hi,

On 16 août, 11:04, LF <lorenzo.fior...@gmail.com> wrote:
> On Aug 16, 9:35 am, Christophe Charron
>
> <christophe.charron....@gmail.com> wrote:
> > Do you mean that remote overlay works ?
> > Could I see a full code example ?
>
> ...
> <button id="loadovlbutton" label="LoadOvl"/>
> <box id="overlay" />
> ...
> function buttonLoadOvlPressed(event)
> {
> // Load an overlay file
> var callback = {
> observe : function (subject, topic, data) {
> if (topic == 'xul-overlay-merged') {
> alert("Overlay loaded successfully");
> }
> }
> };
> // Load the current file as an overlay
> window.document.loadOverlay("http://intranethost:
> 8085/overlay", callback);
> }
> ...
I suppose I didn't understand everything in your code, but it doest
work with me. Is all the code here ?
Best regards

LF

unread,
Aug 21, 2007, 3:17:08 AM8/21/07
to
On Aug 21, 9:01 am, Christophe Charron
<christophe.charron....@gmail.com> wrote:

> I suppose I didn't understand everything in your code, but it doest
> work with me. Is all the code here ?
> Best regards

Do you mean it works also from a different domain?

best regards,
Lorenzo Fiorini

Christophe Charron

unread,
Aug 21, 2007, 12:46:45 PM8/21/07
to

It doesn't work at all !!!

LF

unread,
Aug 21, 2007, 1:35:53 PM8/21/07
to
On Aug 21, 6:46 pm, Christophe Charron
<christophe.charron....@gmail.com> wrote:

> It doesn't work at all !!!

Sorry I read "doest" as "does" instead of "doesn't".

I use a custom made http application server so I can't post exactly
the code I use but here are the "responses" to the browser:
Simply replacing http://<%cHost%>/overlay should work. I use
application/vnd.mozilla.xul+xml mime type for demo3 and text/xml for
overlay.
I've tested it with Fedora Core 7 using FireFox 2.0.0.5 and with a
Windows XP Home notebook using FireFox 2.0.0.6.

best regards,
Lorenzo Fiorini

demo3 remote procedure:

<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<window id="demo3" title="Demo3" sizemode="maximized"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/
there.is.only.xul">


<button id="loadovlbutton" label="LoadOvl"/>
<box id="overlay" />

<script>


function buttonLoadOvlPressed(event)
{
// Load an overlay file
var callback = {
observe : function (subject, topic, data) {
if (topic == 'xul-overlay-merged') {
alert("Overlay loaded successfully");

document.getElementById("clickbutton").addEventListener('command',
buttonClickPressed, true);


}
}
};
// Load the current file as an overlay

window.document.loadOverlay("http://<%cHost%>/overlay",
callback);
}
function buttonClickPressed(event)
{
alert("clicked!");


}

document.getElementById("loadovlbutton").addEventListener('command',
buttonLoadOvlPressed, true);

</script>
</window>

calling http://<%cHost%>/overlay this code is sent:

<?xml version="1.0"?>

<overlay id="toverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/
there.is.only.xul">

<box id="overlay">
<tabbox id="Tab1" selectedIndex="2">
<tabs id="Tab1Tabs">
<tab label="A First tab"/>
<tab label="Second tab"/>
<tab label="Another tab"/>
<tab label="Last tab"/>
</tabs>
<tabpanels id="Tab1Panels">
<tabpanel><!-- tabpanel First elements go here --></
tabpanel>
<tabpanel><!-- tabpanel Second elements go here --
></tabpanel>

<tabpanel><button id="clickbutton" label="Click me"/

Christophe Charron

unread,
Aug 22, 2007, 5:25:21 AM8/22/07
to
On 21 août, 19:35, LF <lorenzo.fior...@gmail.com> wrote:
> On Aug 21, 6:46 pm, Christophe Charron
>
> <christophe.charron....@gmail.com> wrote:
> > It doesn't work at all !!!
>
> Sorry I read "doest" as "does" instead of "doesn't".
Sorry too !!
It works perfectly !!
I didn't try to to a cross domain load but I suppose It doesn't work.
Maybe with FF 3. I think that XHR will be cross domain so why not
loadOverlay.
I tried to use removeelement attribute (seen here
http://developer.mozilla.org/en/docs/XUL_Tutorial:Overlays#Removing_elements
) but it seems to work after 2 tries ??

A complete example here :
http://test03.christophe-charron.org/public/xul/2007_08_22/demo3.xul

Best regards,
Christophe Charron

Question

unread,
Aug 22, 2007, 6:12:24 AM8/22/07
to Christophe Charron, dev-te...@lists.mozilla.org
Http://.. is restricted URI
Your code may work as chrome(or local) but will not work on the net.

On 8/22/07, Christophe Charron <christophe....@gmail.com> wrote:
>
> On 21 août, 19:35, LF <lorenzo.fior...@gmail.com> wrote:
> > On Aug 21, 6:46 pm, Christophe Charron
>
>
>

> _______________________________________________
> dev-tech-xul mailing list
> dev-te...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-xul
>

> --
> >: ~

Christophe Charron

unread,
Aug 22, 2007, 7:47:48 AM8/22/07
to wanl...@gmail.com
On 22 août, 12:12, Question <wanli...@gmail.com> wrote:
> Http://.. is restricted URI
> Your code may work as chrome(or local) but will not work on the net.
>

heu ... this one works with both xul and php made overlays

http://test03.christophe-charron.org/public/xul/2007_08_22/demo3.xul

Doesn't it work for you ?

--
Best regards,
Christophe Charron

> On 8/22/07, Christophe Charron <christophe.charron....@gmail.com> wrote:
>
>
>
> > On 21 août, 19:35, LF <lorenzo.fior...@gmail.com> wrote:
> > > On Aug 21, 6:46 pm, Christophe Charron
>
> > _______________________________________________
> > dev-tech-xul mailing list

Tei

unread,
Aug 22, 2007, 9:50:10 PM8/22/07
to dev-te...@lists.mozilla.org
On 8/22/07, Christophe Charron <christophe....@gmail.com> wrote:
> On 22 août, 12:12, Question <wanli...@gmail.com> wrote:
> > Http://.. is restricted URI
> > Your code may work as chrome(or local) but will not work on the net.
> >
>
> heu ... this one works with both xul and php made overlays
>
> http://test03.christophe-charron.org/public/xul/2007_08_22/demo3.xul
>
> Doesn't it work for you ?

It don't work here:
Windows. FF 2.0.0.6
load php overlay and load js overlay generate the protection error

0 new messages