PDA

View Full Version : Duplicate datasets?


kipsta
11-09-2004, 03:56 AM
Can anyone lend me a hand with a dataset issue... my forehead is sore from beating it against my monitor all night. ;)

Essentially the problem is I have a view which contains N instances of a custom class named 'Engine'. These engines are self-updating by querying data from a servlet. To get this 'working' properly (maybe working isn't the right word at the moment. :P ), I define the dataset in the oninit for the custom classes with the following code:

<method event="oninit">
var tmpDataset = new LzDataset("myDatasource", {name: 'engineDataset'});
tmpDataset.setSrc("/servlet/enginedata/getData");
tmpDataset.setAttribute('type', 'http');
tmpDataset.setQueryString({userID: queryUserID, engineID: queryEngineID});

this.engineDataset = tmpDataset;

this.setDatapath('engineDataset:/engine');

this.timerDelegate = new LzDelegate( this, "loadData" );
LzTimer.addTimer ( this.timerDelegate, 500 );

loadData();

enginePosition.select( enginePosition.currentPosTab );
</method>

This works beautifully if I have one instance of said class loaded, but if I have more than one, each one contains the same data and I get the following message in the debug window:

WARNING: a dataset already exists with the name 'engineDataset':LzDataset :engineDataset - use explicit datasources in your datapaths.

I tried defining a datasource inside the class object as well as creating one inside the oninit, but nothing seems to allow me to have unique data for each of these engine objects. I have to be doing something wrong but for the life of me I have no idea what.

If someone could help me, I'd be a very happy camper (and owe you a beer or something if you're in Boston ;) )

kipsta
11-09-2004, 07:56 AM
Well... after some more head->monitor action, it seems to have solved itself. ;)

For those interested, the solution that worked is to put an expression-typed attribute inside the class which represents the dataset. Then when creating the datasets, give each one a unique name based on the ID of the object I'm using and set that dataset to the attribute for later use (since I need to keep refreshing the data).

Seems to work now. Maybe all I needed to do was the post it. ;)

hipik
07-09-2007, 05:51 AM
nice post I owe you a beer !!!!