PDA

View Full Version : how can i put a function that will autorefresh the page in 10seconds?


kolera
06-29-2006, 12:59 PM
how can i put a function that will autorefresh the page in 10seconds?

i think there is a function like that.. who knows the name and usage??

bfagan
06-30-2006, 08:52 AM
You probably want to use the LzTimer class.

Use LzTimer to set a function to make a doRequest call on a dataset. In an ondata event for a dataset, set the timer to call the function requesting the dataset again.

clillo
07-14-2006, 06:21 AM
example LzTimer:

<method name="refresh">
this.refreshDelegate = new LzDelegate( this, "refreshData" );
LzTimer.addTimer( this.refreshDelegate, 10000 );
</method>

<method name="refreshData">
Debug.write( "== Refreshing window =======" )
datasetNAME.doRequest();
</method>

rcyeager
07-14-2006, 02:16 PM
At the end of the refreshData() method you need to reset the timer...

clillo
07-16-2006, 03:28 PM
You are correct;
one way to restart the timer is to run the function within the dataset ondata event:

<dataset src="..." type="http" ondata="refresh()" />

bfagan
07-16-2006, 06:04 PM
Incidentally, you may want to add an abort() function in your refreshData() function.

dmccay
01-10-2007, 10:08 PM
Hi
Could someone Please Please tell (show) us the correct way to code this, I have been tearing my hair out searching these forums for the solution.
I have read lots of other peoples queries regarding the refreshing of data from a dataset and all the solutions seem to say the same thing ie; LzTimer.
However when you use the examples using the LzTimer calls all that happens is that Flash Player (9) and or (8) crash and give you the old "A Script is causing Flash Player to run Slowly do you want to............."

I have been looking for a solution to this issue here and on JIRA and on Google etc etc am going crazy trying to solve this one completely as my app just falls over whenever I use the LzTimer Snippets from here and there.

Is there a BUG in LzTimer ????
I watch the Task Manager Memeory useage going up and up until you get the Flash warning, if I click NO then the app still works normally but hey can we really expect a non-developer to understand this dramatic error...

Would it be possible to have one of the very knowledgable (and patient) Laszlo Guru's post a solution to this apparently very common question in this forum..Please Please pretty Please

Jump right in folks..

rcyeager
01-10-2007, 11:33 PM
Doesn't this work for you, as above?


<method name="refresh">
this.refreshDelegate = new LzDelegate( this, "refreshData" );
LzTimer.addTimer( this.refreshDelegate, 10000 );
</method>

<method name="refreshData">
Debug.write( "== Refreshing window =======" )
datasetNAME.doRequest();
</method>


This is how I do it...

Robert

dmccay
01-11-2007, 12:32 AM
Hi Robert
Well it does do the refresh but causes the Flash Errors after a few minutes
Dont you get the same??
I am running lps-4.0b1rc1 but it seems to have been an issue for some time now here....

And I have to change the <method name="refresh"> to
<method event="oninit"> to get it to do that..

I guess I must be missing something?
Could you show us all the code you use if it is succeessfully running without causing the errors...


Dave

bfagan
01-11-2007, 06:01 AM
How large is your dataset?

rcyeager
01-11-2007, 08:40 AM
I recommend avoiding LPS4 for any serious work.

If you want something that actually functions correctly, use LPS3.

Robert

dmccay
01-11-2007, 01:17 PM
:cool: Robert
Thanks very much for your advice re LPS4 I have now installed LPS3.3.3 and everything seems to be good :)
Although I could not get the above method to work and I have gone back to my original code:

<method event="oninit">
this.refreshDelegate = new LzDelegate( this, "doRefresh" );
LzTimer.addTimer ( this.refreshDelegate, 60000 );
</method>

<method name="doRefresh">
dset.doRequest();
LzTimer.resetTimer( this.refreshDelegate, 60000 );
</method>

Everything seems to be functioning as expected now....
Is there any problems you can forsee in my code?
Oh and my dataset is not very large (yet) maybe this will present a problem as it grows.

Great suggestion thanks again.
Dave

rcyeager
01-11-2007, 01:43 PM
Hi Dave,

Your code is exactly like I have for my Cooqy widgets, so I anticipate you should have no problems on LPS3. Not sure about the dataset size as far as the refresh goes, but Cooqy's datasets are sometimes 100KB...the trick is not so much the time to update the dataset itself, it is with all the views that may be attached to the data. For large datasets, data pooling is essential. Do a search for "data pooling" in this forum and you will find a posting I wrote with some useful tips.

You can see here my thoughts on LPS4: http://www.cooqy.com/blog/2006/12/28/openlaszlo-4-legals-train-wreck-in-slow-motion/

LPS4 has a lot of promise and will eventually be great technology, but not anytime soon IMO.

Robert

laszfellow
02-08-2007, 08:15 AM
<method name="doRefresh">
dset.doRequest();
LzTimer.resetTimer( this.refreshDelegate, 60000 );
</method>


What should I set the src of dset to?

Let's say the url of my lzx is
http://localhost:8080/Whoopi/Goldberg.lzx

and the launching html is
http://localhost:8080/Whoopi/Goldberg.html

I had

<dataset name='dset' src='http://localhost:8080/Whoopi/Goldberg.lzx' ....


I also had

<dataset name='dset' src='http://localhost:8080/Whoopi/Goldberg.html' ....


At the juncture dset.doRequest() is triggered, the page is not refreshed and Debug window shows errors like

<link should be followed by ....


I decided I had enough of trying refresh thro doRequest, so I successfully did this instead:


<method name="reloadpage">
LzBrowser.loadJS( "location.reload();" );
</method>


QEF

rcyeager
02-08-2007, 08:25 AM
Looks like you need to read section 5 in the Developer's Guide to learn how datasets work.

The dataset should be loading the XML data to be displayed, not your LZX app or the HTML page wrapper.

laszfellow
02-08-2007, 08:52 AM
The dataset should be loading the XML data to be displayed, not your LZX app or the HTML page wrapper.

Exactly.

how can i put a function that will autorefresh the page in 10seconds?


Therefore, my misunderstanding the question, which should be

how can i autorefresh the data displayed on a page in 10seconds?


Otherwise, to refresh the whole page (lzx, stock & barrel) is there an alternate way to browser javascript location.reload()? Is there any facility within OpenLaszlo to refresh the page without directly refering to browser javascript?

rcyeager
02-08-2007, 10:17 AM
To refresh data within an OL app, just delete the dataset's contents and issue another request to load the dataset's data again.

Not sure why you would want to reload the entire HTML page containing the LZX application...doesn't seem what you want to accomplish.

laszfellow
02-08-2007, 11:34 AM
Not sure why you would want to reload the entire HTML page containing the LZX application...doesn't seem what you want to accomplish.

http://forum.openlaszlo.org/showthread.php?p=27499#post27499

Any suggestions to my time-out problem?

rcyeager
02-08-2007, 11:44 AM
No, can't help with the timeout issue.

With regards to reloading the entire wrapper page, I can only think to use Javascript as you have done.

nodrogx
09-07-2012, 10:16 AM
"However when you use the examples using the LzTimer calls all that happens is that Flash Player (9) and or (8) crash and give you the old "A Script is causing Flash Player to run Slowly do you want to.............""

This is happening to me with OL 4.9.0 and swf8. Is the fix still to go back to OL3 "for any serious work"?

thank-you