Xforms enable too late

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Xforms enable too late

Shaw, Richard A
Xforms enable too late

I have an xforms page which contains a large map image generated from a map server and rather annoyingly this sometimes takes a few seconds to be fetched.

The issue I have is that the xforms controls don't work until this image has been received. I am guessing this is because the xforms are enabled in the onLoad function which doesn't complete until all resources have been received.

Is my guess correct ?

Is there an acepted way to get around this ?

My xform has a list of map layers with tick boxes, you tick the layers you want and press update. But any ticks that I make before the map resource is loaded are ignored when you press update even though they appear ticked on the page. I assume this is because the ajax hasn't run and told the server that I have ticked them because I have done it before the events have been added to the controls.



Richard Shaw

¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤

Richard Shaw  
Technical Design Authority - Information Solutions Consultancy  
Intelligent Transport Systems

Atkins Highways and Transportation
Woodcote Grove, Ashley Road, Epsom, Surrey, KT18 5BW

Tel: +44 (0) 1372 756407 
Fax: +44 (0) 1372 740055
Mob: 07740 817586 
E-mail: [hidden email]

www.atkinsglobal.com/its



This email and any attached files are confidential and copyright protected. If you are not the addressee, any dissemination of this communication is strictly prohibited. Unless otherwise expressly agreed in writing, nothing stated in this communication shall be legally binding.



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Xforms enable too late

Alessandro  Vernet
Administrator
Hi Richard,

Yes, your interpretation is correct. We perform the XForms
initialization when the browser dispatches the "load"  event. This
happens when the page is loaded and all the external resources used by
the page (images, JavaScript, CSS) are loaded as well. I guess we
would need to have just the JavaScript loaded, but I don't think there
is a special event we can listen to to be notified of when *just* the
JavaScript has been loaded.

What you could do is to generate in your page a <img id="my-imagemap"
src="empty.png"/>, pointing to a dummy image that loads quickly. Then
add to the page some JavaScript that actually points the src to the
correct image onload:

    function setImagemap() {
        document.getElementById("my-imagemap").src = "real.png";
    }

    if (window.addEventListener) {
        window.addEventListener("load", setImagemap, false);
    } else {
        window.attachEvent("onload", handler);
    }

Note that I haven't tested this, so consider this as pseudo-code :).

Alex

On 5/23/06, Shaw, Richard A <[hidden email]> wrote:

>
>
>
> I have an xforms page which contains a large map image generated from a map
> server and rather annoyingly this sometimes takes a few seconds to be
> fetched.
>
> The issue I have is that the xforms controls don't work until this image has
> been received. I am guessing this is because the xforms are enabled in the
> onLoad function which doesn't complete until all resources have been
> received.
>
> Is my guess correct ?
>
> Is there an acepted way to get around this ?
>
> My xform has a list of map layers with tick boxes, you tick the layers you
> want and press update. But any ticks that I make before the map resource is
> loaded are ignored when you press update even though they appear ticked on
> the page. I assume this is because the ajax hasn't run and told the server
> that I have ticked them because I have done it before the events have been
> added to the controls.
>
>
>
> Richard Shaw
>
> ¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤
>
> Richard Shaw
> Technical Design Authority - Information Solutions Consultancy
> Intelligent Transport Systems
>
> Atkins Highways and Transportation
> Woodcote Grove, Ashley Road, Epsom, Surrey, KT18 5BW
>
> Tel: +44 (0) 1372 756407
> Fax: +44 (0) 1372 740055
> Mob: 07740 817586
> E-mail: [hidden email]
>
> www.atkinsglobal.com/its
>
>
>
> This email and any attached files are confidential and copyright protected.
> If you are not the addressee, any dissemination of this communication is
> strictly prohibited. Unless otherwise expressly agreed in writing, nothing
> stated in this communication shall be legally binding.
>
> --
> You receive this message as a subscriber of the [hidden email]
> mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>

--
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

RE: Xforms enable too late

Shaw, Richard A
In reply to this post by Shaw, Richard A
Yes, I'd thought about that too - the only problem is that we are running within Liferay portal and the image is in another portal, so I don't have the option of modifying it's code.

The only other thing I was thinking about was to start all the xforms controls disabled and then enable them as part of the onLoad so that it stop the users pressing the buttons too soon. Still doesn't help the impatient browser who wants to move on without waiting for the images to load, but at least it would fix the checkbox issue mentioned before.

Where would I add this type of code ? Is it a reasonable idea ?

Richard Shaw

¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤

Richard Shaw  
Technical Design Authority - Information Solutions Consultancy  
Intelligent Transport Systems

Atkins Highways and Transportation
Woodcote Grove, Ashley Road, Epsom, Surrey, KT18 5BW

Tel: +44 (0) 1372 756407
Fax: +44 (0) 1372 740055
Mob: 07740 817586
E-mail: [hidden email]

www.atkinsglobal.com/its

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Alessandro Vernet
Sent: 23 May 2006 17:54
To: [hidden email]
Subject: Re: [ops-users] Xforms enable too late

Hi Richard,

Yes, your interpretation is correct. We perform the XForms initialization when the browser dispatches the "load"  event. This happens when the page is loaded and all the external resources used by the page (images, JavaScript, CSS) are loaded as well. I guess we would need to have just the JavaScript loaded, but I don't think there is a special event we can listen to to be notified of when *just* the JavaScript has been loaded.

What you could do is to generate in your page a <img id="my-imagemap"
src="empty.png"/>, pointing to a dummy image that loads quickly. Then add to the page some JavaScript that actually points the src to the correct image onload:

    function setImagemap() {
        document.getElementById("my-imagemap").src = "real.png";
    }

    if (window.addEventListener) {
        window.addEventListener("load", setImagemap, false);
    } else {
        window.attachEvent("onload", handler);
    }

Note that I haven't tested this, so consider this as pseudo-code :).

Alex

On 5/23/06, Shaw, Richard A <[hidden email]> wrote:

>
>
>
> I have an xforms page which contains a large map image generated from
> a map server and rather annoyingly this sometimes takes a few seconds
> to be fetched.
>
> The issue I have is that the xforms controls don't work until this
> image has been received. I am guessing this is because the xforms are
> enabled in the onLoad function which doesn't complete until all
> resources have been received.
>
> Is my guess correct ?
>
> Is there an acepted way to get around this ?
>
> My xform has a list of map layers with tick boxes, you tick the layers
> you want and press update. But any ticks that I make before the map
> resource is loaded are ignored when you press update even though they
> appear ticked on the page. I assume this is because the ajax hasn't
> run and told the server that I have ticked them because I have done it
> before the events have been added to the controls.
>
>
>
> Richard Shaw
>
> ¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤
>
> Richard Shaw
> Technical Design Authority - Information Solutions Consultancy
> Intelligent Transport Systems
>
> Atkins Highways and Transportation
> Woodcote Grove, Ashley Road, Epsom, Surrey, KT18 5BW
>
> Tel: +44 (0) 1372 756407
> Fax: +44 (0) 1372 740055
> Mob: 07740 817586
> E-mail: [hidden email]
>
> www.atkinsglobal.com/its
>
>
>
> This email and any attached files are confidential and copyright protected.
> If you are not the addressee, any dissemination of this communication
> is strictly prohibited. Unless otherwise expressly agreed in writing,
> nothing stated in this communication shall be legally binding.
>
> --
> You receive this message as a subscriber of the
> [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page:
> http://www.objectweb.org/wws
>
>
>

--
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/



This message has been scanned for viruses by MailControl - (see http://bluepages.wsatkins.co.uk/?4318150)



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Xforms enable too late

Alessandro  Vernet
Administrator
Richard,

The initialization code needs to run once all the JavaScript files
have been loaded. So instead of listening on the load event, I guess
we could run some code that checks if the other files are loaded: if
they are, then run the init code, otherwise wait for 100ms and try
again. The JavaSript files define functions or objects when they are
loaded. So checking if a file is loaded means checking if those
functions/objects are declared. With this method, the end-user could
use the form before all the images are loaded.

Another way to do it, is like you say to disable all the form
controls. So at the end of the form (maybe just before the
</xhtml:body>) you would put some JavaScript that disabled all the
controls, and registers a listener on the load event which enables all
the controls.

Alex

On 5/24/06, Shaw, Richard A <[hidden email]> wrote:

> Yes, I'd thought about that too - the only problem is that we are running within Liferay portal and the image is in another portal, so I don't have the option of modifying it's code.
>
> The only other thing I was thinking about was to start all the xforms controls disabled and then enable them as part of the onLoad so that it stop the users pressing the buttons too soon. Still doesn't help the impatient browser who wants to move on without waiting for the images to load, but at least it would fix the checkbox issue mentioned before.
>
> Where would I add this type of code ? Is it a reasonable idea ?
>
> Richard Shaw
>
> 內躬偕爻,虜,齯滌`偕爻內躬偕爻,虜,齯滌`偕爻內躬偕爻,虜,齯
>
> Richard Shaw
> Technical Design Authority - Information Solutions Consultancy
> Intelligent Transport Systems
>
> Atkins Highways and Transportation
> Woodcote Grove, Ashley Road, Epsom, Surrey, KT18 5BW
>
> Tel: +44 (0) 1372 756407
> Fax: +44 (0) 1372 740055
> Mob: 07740 817586
> E-mail: [hidden email]
>
> www.atkinsglobal.com/its
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On Behalf Of Alessandro Vernet
> Sent: 23 May 2006 17:54
> To: [hidden email]
> Subject: Re: [ops-users] Xforms enable too late
>
> Hi Richard,
>
> Yes, your interpretation is correct. We perform the XForms initialization when the browser dispatches the "load"  event. This happens when the page is loaded and all the external resources used by the page (images, JavaScript, CSS) are loaded as well. I guess we would need to have just the JavaScript loaded, but I don't think there is a special event we can listen to to be notified of when *just* the JavaScript has been loaded.
>
> What you could do is to generate in your page a <img id="my-imagemap"
> src="empty.png"/>, pointing to a dummy image that loads quickly. Then add to the page some JavaScript that actually points the src to the correct image onload:
>
>     function setImagemap() {
>         document.getElementById("my-imagemap").src = "real.png";
>     }
>
>     if (window.addEventListener) {
>         window.addEventListener("load", setImagemap, false);
>     } else {
>         window.attachEvent("onload", handler);
>     }
>
> Note that I haven't tested this, so consider this as pseudo-code :).
>
> Alex
>
> On 5/23/06, Shaw, Richard A <[hidden email]> wrote:
> >
> >
> >
> > I have an xforms page which contains a large map image generated from
> > a map server and rather annoyingly this sometimes takes a few seconds
> > to be fetched.
> >
> > The issue I have is that the xforms controls don't work until this
> > image has been received. I am guessing this is because the xforms are
> > enabled in the onLoad function which doesn't complete until all
> > resources have been received.
> >
> > Is my guess correct ?
> >
> > Is there an acepted way to get around this ?
> >
> > My xform has a list of map layers with tick boxes, you tick the layers
> > you want and press update. But any ticks that I make before the map
> > resource is loaded are ignored when you press update even though they
> > appear ticked on the page. I assume this is because the ajax hasn't
> > run and told the server that I have ticked them because I have done it
> > before the events have been added to the controls.
> >
> >
> >
> > Richard Shaw
> >
> > 內躬偕爻,虜,齯滌`偕爻內躬偕爻,虜,齯滌`偕爻內躬偕爻,虜,齯
> >
> > Richard Shaw
> > Technical Design Authority - Information Solutions Consultancy
> > Intelligent Transport Systems
> >
> > Atkins Highways and Transportation
> > Woodcote Grove, Ashley Road, Epsom, Surrey, KT18 5BW
> >
> > Tel: +44 (0) 1372 756407
> > Fax: +44 (0) 1372 740055
> > Mob: 07740 817586
> > E-mail: [hidden email]
> >
> > www.atkinsglobal.com/its
> >
> >
> >
> > This email and any attached files are confidential and copyright protected.
> > If you are not the addressee, any dissemination of this communication
> > is strictly prohibited. Unless otherwise expressly agreed in writing,
> > nothing stated in this communication shall be legally binding.
> >
> > --
> > You receive this message as a subscriber of the
> > [hidden email] mailing list.
> > To unsubscribe: mailto:[hidden email]
> > For general help: mailto:[hidden email]?subject=help
> > ObjectWeb mailing lists service home page:
> > http://www.objectweb.org/wws
> >
> >
> >
>
>
> --
> Blog (XML, Web apps, Open Source):
> http://www.orbeon.com/blog/
>
>
>
> This message has been scanned for viruses by MailControl - (see http://bluepages.wsatkins.co.uk/?4318150)
>
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>

--
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Xforms enable too late

Alessandro  Vernet
Administrator
Richard,

Someone found a trick to get around this this problem in the
JavaScript code. So it looks like we'll be able to resolve the problem
you mentioned by implementing this "trick". I have created an entry to
track this:

http://forge.objectweb.org/tracker/index.php?func=detail&aid=305546&group_id=168&atid=350207

Alex

On 5/25/06, Alessandro Vernet <[hidden email]> wrote:

> Richard,
>
> The initialization code needs to run once all the JavaScript files
> have been loaded. So instead of listening on the load event, I guess
> we could run some code that checks if the other files are loaded: if
> they are, then run the init code, otherwise wait for 100ms and try
> again. The JavaSript files define functions or objects when they are
> loaded. So checking if a file is loaded means checking if those
> functions/objects are declared. With this method, the end-user could
> use the form before all the images are loaded.
>
> Another way to do it, is like you say to disable all the form
> controls. So at the end of the form (maybe just before the
> </xhtml:body>) you would put some JavaScript that disabled all the
> controls, and registers a listener on the load event which enables all
> the controls.
>
> Alex
>
> On 5/24/06, Shaw, Richard A <[hidden email]> wrote:
> > Yes, I'd thought about that too - the only problem is that we are running within Liferay portal and the image is in another portal, so I don't have the option of modifying it's code.
> >
> > The only other thing I was thinking about was to start all the xforms controls disabled and then enable them as part of the onLoad so that it stop the users pressing the buttons too soon. Still doesn't help the impatient browser who wants to move on without waiting for the images to load, but at least it would fix the checkbox issue mentioned before.
> >
> > Where would I add this type of code ? Is it a reasonable idea ?
> >
> > Richard Shaw
> >
> > 內躬偕爻,虜,齯滌`偕爻內躬偕爻,虜,齯滌`偕爻內躬偕爻,虜,齯
> >
> > Richard Shaw
> > Technical Design Authority - Information Solutions Consultancy
> > Intelligent Transport Systems
> >
> > Atkins Highways and Transportation
> > Woodcote Grove, Ashley Road, Epsom, Surrey, KT18 5BW
> >
> > Tel: +44 (0) 1372 756407
> > Fax: +44 (0) 1372 740055
> > Mob: 07740 817586
> > E-mail: [hidden email]
> >
> > www.atkinsglobal.com/its
> >
> > -----Original Message-----
> > From: [hidden email] [mailto:[hidden email]] On Behalf Of Alessandro Vernet
> > Sent: 23 May 2006 17:54
> > To: [hidden email]
> > Subject: Re: [ops-users] Xforms enable too late
> >
> > Hi Richard,
> >
> > Yes, your interpretation is correct. We perform the XForms initialization when the browser dispatches the "load"  event. This happens when the page is loaded and all the external resources used by the page (images, JavaScript, CSS) are loaded as well. I guess we would need to have just the JavaScript loaded, but I don't think there is a special event we can listen to to be notified of when *just* the JavaScript has been loaded.
> >
> > What you could do is to generate in your page a <img id="my-imagemap"
> > src="empty.png"/>, pointing to a dummy image that loads quickly. Then add to the page some JavaScript that actually points the src to the correct image onload:
> >
> >     function setImagemap() {
> >         document.getElementById("my-imagemap").src = "real.png";
> >     }
> >
> >     if (window.addEventListener) {
> >         window.addEventListener("load", setImagemap, false);
> >     } else {
> >         window.attachEvent("onload", handler);
> >     }
> >
> > Note that I haven't tested this, so consider this as pseudo-code :).
> >
> > Alex
> >
> > On 5/23/06, Shaw, Richard A <[hidden email]> wrote:
> > >
> > >
> > >
> > > I have an xforms page which contains a large map image generated from
> > > a map server and rather annoyingly this sometimes takes a few seconds
> > > to be fetched.
> > >
> > > The issue I have is that the xforms controls don't work until this
> > > image has been received. I am guessing this is because the xforms are
> > > enabled in the onLoad function which doesn't complete until all
> > > resources have been received.
> > >
> > > Is my guess correct ?
> > >
> > > Is there an acepted way to get around this ?
> > >
> > > My xform has a list of map layers with tick boxes, you tick the layers
> > > you want and press update. But any ticks that I make before the map
> > > resource is loaded are ignored when you press update even though they
> > > appear ticked on the page. I assume this is because the ajax hasn't
> > > run and told the server that I have ticked them because I have done it
> > > before the events have been added to the controls.
> > >
> > >
> > >
> > > Richard Shaw
> > >
> > > 內躬偕爻,虜,齯滌`偕爻內躬偕爻,虜,齯滌`偕爻內躬偕爻,虜,齯
> > >
> > > Richard Shaw
> > > Technical Design Authority - Information Solutions Consultancy
> > > Intelligent Transport Systems
> > >
> > > Atkins Highways and Transportation
> > > Woodcote Grove, Ashley Road, Epsom, Surrey, KT18 5BW
> > >
> > > Tel: +44 (0) 1372 756407
> > > Fax: +44 (0) 1372 740055
> > > Mob: 07740 817586
> > > E-mail: [hidden email]
> > >
> > > www.atkinsglobal.com/its
> > >
> > >
> > >
> > > This email and any attached files are confidential and copyright protected.
> > > If you are not the addressee, any dissemination of this communication
> > > is strictly prohibited. Unless otherwise expressly agreed in writing,
> > > nothing stated in this communication shall be legally binding.
> > >
> > > --
> > > You receive this message as a subscriber of the
> > > [hidden email] mailing list.
> > > To unsubscribe: mailto:[hidden email]
> > > For general help: mailto:[hidden email]?subject=help
> > > ObjectWeb mailing lists service home page:
> > > http://www.objectweb.org/wws
> > >
> > >
> > >
> >
> >
> > --
> > Blog (XML, Web apps, Open Source):
> > http://www.orbeon.com/blog/
> >
> >
> >
> > This message has been scanned for viruses by MailControl - (see http://bluepages.wsatkins.co.uk/?4318150)
> >
> >
> >
> >
> > --
> > You receive this message as a subscriber of the [hidden email] mailing list.
> > To unsubscribe: mailto:[hidden email]
> > For general help: mailto:[hidden email]?subject=help
> > ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
> >
> >
> >
>
>
> --
> Blog (XML, Web apps, Open Source):
> http://www.orbeon.com/blog/
>

--
Blog (XML, Web apps, Open Source):
http://www.orbeon.com/blog/


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet