View Full Version : polling a dataset
How can I get a dataset to notice that the source XML has changed and to update the display?
antun
09-29-2003, 05:01 PM
That should happen automatically if views are bound to that data. Is it not happening?
-Antun
I have a dataset that is bound to an http file. The http file will get updated periodically. Are you saying that that http file will automatically be polled for changes?
antun
09-29-2003, 06:52 PM
If it's an xml file on the server, then that data will be compiled into the app at the time of the app's download. If you then change that data in the file, the app will not know about it at all.
However if you use HTTP data:
<dataset name="foo" type="http" src="mydata.jsp" />
Then you can re-request the data using the dataset's doRequest() method:
http://www.laszlosystems.com/developers/learn/documentation/lzxref/dataset.php#meth-doRequest
-Antun
I have:
<dataset name="opmldata" autorequest="true" type="http" src="http://pt.withy.org/ptalk/trackinfo.xml"/>
and I am updating trackinfo.xml, but see no change in my app's display.
antun
09-29-2003, 09:20 PM
Hmmm this works for me:
<canvas>
<dataset name="opmldata" autorequest="true" type="http"
src="test.xml"/>
<simplelayout axis="y" spacing="5" />
<button>doRequest()
<method event="onclick">
opmldata.doRequest();
</method>
</button>
<view datapath="opmldata:/dwarves">
<simplelayout axis="y" spacing="5" />
<text datapath="dwarf/@name" />
</view>
</canvas>
I used the attached file as a data source. If you play with the order of the nodes in the XML, then hit the doRequest() button - it updates.
Can you confirm that this works for you, and if so, post some code that does not work with the data source you're using.
-Antun
Oh! You missed the point of my question. I am sure that if I request an update, I will get one. I was asking if there is any way to have updating be automatic. I (perhaps foolishly) was thinking that 'autorequest' might mean something like that. Apparently it does not. I guess I need to set up some sort of timer to issue a doRequest every so often?
antun
09-30-2003, 07:03 AM
Aaahhh. Now I understand what you were asking. No "autorequest" only determines whether the dataset will poll oninit or hold off until doRequest() is called.
The best thing, as you suggested, would be to set up a timer to call doRequest() every now and again.
See here on how to do that:
http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=138&highlight=lztimer
-Antun
Hi,
I wanted to do a similar thing and thought I should share my solution (I basically done what Antun suggests and wrapped it in a new class). I'm new to all this so I welcome feedback and suggestions for improvement.
To solve the polling problem I have created a new class:
<class name="polling">
<attribute name="datasetName" type="string"/>
<attribute name="rate" value="60"/>
<method event="oninit">
this.pollDelegate = new LzDelegate (this, 'pollDataSource');
LzTimer.addTimer(this.pollDelegate, rate*1000);
</method>
<method name="pollDataSource">
canvas.datasets[datasetName].doRequest();
LzTimer.resetTimer(this.pollDelegate, rate*1000);
</method>
</class>
An example of how to use this class is:
<dataset name="dset"
autorequest="true"
type="http"
src="http://www.somedomain.com/somefile.xml"/>
<polling rate="3" datasetName="dset"/>
In the example I call the new class and set the rate at which the data is to be polled in seconds and the name of the dataset to be polled.
Dan
aeava
03-31-2006, 06:52 PM
We fixed it by using the same dataset for SELECT and INSERT/UPDATE/DELETE, including a parameter for action.
Using the same dataset, ensures that regardless of what operation is performed on the data, the data returned is always updated.
A.-
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.