[Laszlo-user] Applying modifications to a dataset.

Dave Miller dwmiller at umich.edu
Tue May 27 14:40:02 PDT 2008


On May 27, 2008, at 1:14 PM, Frederic Osterrath wrote:

> Hi All,
>
> I am trying to apply modifications to a dataset back to the XML file  
> it was read from, without success.
>
> The file is read locally such as : <dataset name="dset"  
> src="resources/phonebook.xml"/>
>
> Modifications to the dataset are done with datapath.updateData();  
> calls.
>
> All examples given in the laszlo doc seem to only affect run-time  
> data.
>
> Is there a particular binding I should specify? I dont think there  
> are permission issues. What could I be missing here?

You might  be missing the fact that the data is not bound to the copy  
on the server.  If you want the file on the server to be modified, you  
have to have a server-side script to do that.

Here's the code that lives in a script block in the lzx file for an  
app I use to modify an XML file. This is called by a "save" button.

function writedata() {
		var d = canvas.datasets.Actions;
		var p = new LzParam();
		p.addValue('model', 'data', true);
		p.addValue('action', 'write', true);
		dp = canvas.datasets.MainData.getPointer();
		var data = dp.xpathQuery('rsp/data');
		p.addValue('contents', data.serialize(), true);
		d.setQueryString(p);
		d.sendRequest();
	}


My 'Actions' dataset has the parameter src = "http://www.foo.com/main.php 
"

Inside that php file I have a function that reads the "contents"  
parameter of the POSTed data and writes it to my data.xml file.

HTH,

Dave


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.openlaszlo.org/pipermail/laszlo-user/attachments/20080527/fc7dd6ef/attachment.html


More information about the Laszlo-user mailing list