Need help! Add data to model on the fly

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Need help! Add data to model on the fly

jwhitten

Hello,

I need some help please! I have been banging my head on this all day.

I have set up a form and rpc object and have it all working splendidly. When the Save button is pressed on the form, it calls "_handleSubmit" which sets up the RPC params and then calls the RPC function. The "getService" function simply returns the name of the "service" I want to call on the back-end. (Yes, I know I'm using RPC _sync_... :-) Here is a brief snippet from my code. (I don't think an entire app is necessary to understand my question. If it is, I'll cruft something up and post it again.)


                _callRpcSync : function(service, url, params) // synchronous model
                {
                        var rpc = new qx.io.remote.Rpc(url, service);

                        try {
                                var results = rpc.callSync(service, qx.util.Serializer.toUriParameter(params));
                                return results;
                                }
                        catch (exc) {
                                qx.core.Init.getApplication().debug("RPC-SYNC Exception: " + exc);
                                }
                },

                _handleSubmit : function(e)
                {
                        var item = e.getData();
                        var url = "http://myUrl_blahblah";
                        var service = this._getService(item);
                        this._callRpcSync(service, url, item.getModel());
                }


So, the "item.getModel()" part has the data from the form elements in it. Like I said before, this works, no issues. What I want to do that I'm having problems with, is I want to INJECT a couple of additional items into the model just before I send it off to the RPC call. Something like this:

                _handleSubmit : function(e)
                {
                        var item = e.getData();
                        var url = "http://myUrl_blahblah";
                        var service = this._getService(item);
                        var model = item.getModel();
                        ...SOMEHOW_ADD( { crudMode: "new", crudName: "myName" } )_TO_MODEL...
                        this._callRpcSync(service, url, item.getModel());
                }


I've tried doing this just about every way I can think of. I've combed the Internet for hours and hours and read every snippet I can find on the Qooxdoo list that even remotely seems relevant, and nothing I try seems to work. I can create an array object, merge it with the model and get the NEW items but not the model items, even though they seemed to have merged. I can merge the MODEL items with the new items and get the MODEL items, but not the new items. I've tried half a dozen different things-- this seems like it should be such a SIMPLE thing to do... but nothing works!

Can somebody help me please?

THANKS!!!

John