PDA

View Full Version : Ext.data.Writer question



KJD
1 Jan 2010, 5:23 PM
I have the Ext.data.Reader working in my project. I want to update an XML record when I click the Save button now. I didn't see any examples of how to do this though, can anyone offer a simple example? Thanks!

Condor
2 Jan 2010, 1:25 AM
Update an XML record? Are you trying to update an .xml file? You can't do that on the client, because javascript doesn't allow file access.

You either need a server application that can modify your .xml file or you need another client runtime environment (e.g. Adobe AIR).

KJD
2 Jan 2010, 8:17 AM
Hi Condor -
I have an embedded web server that is running my Ext application. Along with this is an XML file which stores data. When the server shows the web page and a change is made there is a button for them to save this change. I need to be able to update the XML file residing on the server with this information. Currently the data is read from the XML file and shows up in the application so I can read it but I need to understand how to update a record in the XML file.

Condor
2 Jan 2010, 9:55 AM
You collect the changes and send it in an Ext.Ajax.request (or you could use Ext.direct) to the server.
The application server (PHP, J2EE, .NET) needs code that updates the .xml file. A simple HTTP server won't work (unless you write a .cgi application)!

KJD
2 Jan 2010, 4:10 PM
Hi Condor -
So basically the browser can only read data then correct. The browser (application) has to request the data be changed and the server can change it and save it to XML then the browser simply updates the page.
In my application the data is shown in a grid and can have up to 300 records. is there any pointers on the best way to handle this other than XML?
Thanks for your help!

Condor
3 Jan 2010, 11:55 PM
What type of application is this supposed to be?

Should it be a local application? In that case you could try Adobe AIR or Google Gears so you can address a local SQL database in javascript.

Or should it be a distributed application? In that case you need an application server (PHP, J2EE, .NET etc.) that can handle update requests for the data.

Mike Robinson
4 Jan 2010, 7:36 AM
They call this technique client-server. The client is ExtJS, and its responsibility is basically "the user interface display." It draws pretty grids and combo boxes and responds to things like mouse clicks.

Objects like "data stores" and their associated "readers" and "writers" are used to communicate, via HTTP, with the server. Most of these requests are CRUD: "Create, Read, Update, Destroy." As the user does things with records, the javascript objects fire appropriate requests to the host, and handle the results (success or failure).

The server does all the 'real' work with regards to whatever data is being manipulated. It sends the requested slices of information to the clients ("Read"), and performs the requested updates, creates, and destroys. Manipulation of your XML file would be done on the host, which would be treating the XML file as, in effect, a small database.