PDA

View Full Version : Persist Store to server?



deitch
16 Oct 2007, 10:35 AM
So I have been looking at the Store, and wondering if it is really one-way only, or I am missing something. Specifically, I can easily define a Store, have it load up its data via an HttpProxy (or some other), and interpret the data via a Reader class.

Now I am trying to do the reverse. Throughout any user interaction, it is possible (likely?) that the data in the Store will be changed. Simplest example is an EditorGrid, where text data is changed. Now we want the reverse: a relatively simple way that the data in the grid can be *sent* to the server, mirroring the read.

I didn't see this anywhere. The only thing I could see was to separately extract the data from the Store, then send it using Ext.Ajax or the like. Is there some method in store to persist it? Obviously, there are some complex questions around it. We would need something like the following on the store:

writer - config: a Writer object that defines how to convert the objects into a raw format understood by the server and transmittable via HTTP.
writeUrl - config: a url that is used to POST the data
write(boolean changes) - method: to use the writer to write the data into a format that can be POSTed. changes determines if we transmit changed data only or all data.


Of course, the manner of POSTing opens a can of worms, since each server side process can use different formats. Nonetheless, if there isn't one there now, I would assume that it is better to have something decent rather than nothing? Besides, all that can be built into the Writer.

Is there something in place or in the works for this?
Thanks.

tryanDLS
16 Oct 2007, 10:41 AM
There is nothing built in, but a search of this forum and the Examples forum should give a number of threads that discuss options for doing this.

deitch
16 Oct 2007, 10:48 AM
Thanks, Tim. I found some stuff around xmlSerialize, as well as some around saving the state of the grid itself, but nothing direct.

Anything hidden in 2.0, or is this a call to try and create it?

tryanDLS
16 Oct 2007, 11:41 AM
AFAIK know there is not. My thought would be that b/c the implementation would be so back-end and application-specific, that it wouldn't be worth trying to build a generic method.

deitch
16 Oct 2007, 11:43 AM
I need to create a persistence engine for my store anyways. Might as well try to make it as generic as possible. If it ends up being remotely close enough to worth posting, I will definitely share.

What is the standard process for doing so? Just post it here?

tryanDLS
16 Oct 2007, 11:48 AM
In the User Extensions forum.

deitch
16 Oct 2007, 11:49 AM
Look before you ask, right? :s

Thanks, Tim.

deitch
18 Oct 2007, 6:16 AM
If you look at the source to Ext.data.Store, there are parallels to load and loadResponse with update and updateResponse. They are blank, though, and no mention in 2.0 either. I will keep plowing ahead...