*TA DAH!!! Here is the WORKING solution !!!*  

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

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

               
//----------------------------------------------------------------------
*                _objToArray : function(obj)
                {
                        var arry = {};
                        var properties =
qx.util.PropertyUtil.getAllProperties(obj.constructor);
                        for (var name in properties) {
                                if (properties[name].group != undefined) {
                                        continue;
                                        }
                                var value = obj["get" +
qx.lang.String.firstUp(name)]();
                                arry[name] = value;
                                }
                        return arry;
                },*

               
//----------------------------------------------------------------------
                _handleSubmit : function(e)
                {
                        var item = e.getData();
                        var service = this._getService(item);
                        var model = item.getModel();
*                        var arry = this._objToArray(model);
                        arry.crudMode = this.getCrudMode();
                        arry.crudName = this.getCrudName();
                        var new_model = qx.data.marshal.Json.createModel(
arry, true );*
                        this._callRpcSync(service, this.getUrl(),
new_model);
                }


*Here is the final result !!*

<http://qooxdoo.678.n2.nabble.com/file/n7581656/10-10-2012_9-35-21_PM.png> 


To be sure, this is somewhat of a hack, but it was definitely not just
dealing with some "simple JSON". The code that does the Uri construction is
calling the constructor of the object which is returning the original items
over and over, irrespective of any NEW "properties" which may have been
added subsequently. Similarly, attempting to merge two objects using
qx.lang.Object.mergeWith() didn't quite work either for the same reason--
the Serializer code was calling the constructor. So whichever object was set
to be the "target" object, that's the object whose constructor was called
and thus which "properties" were included. The only way (I have been able to
figure out) to do it is to create a plain array, iterate the form model's
properties-- so as to create a plain JSON object-- and then to add the new
properties-- the "crud" values-- into that and then hoist it into a new
model object with qx.data.marshal.Json.createModel( json_data ). Then when
that is submitted to the Serializer, its constructor contains all of the
needed properties.


*From: Qooxdoo's Serializer.js: *


    toUriParameter : function(object, qxSerializer, dateFormat)
    {
      var result = "";
      *var properties =
qx.util.PropertyUtil.getAllProperties(object.constructor);*

*      for (var name in properties) {
        // ignore property groups
        if (properties[name].group != undefined) {
          continue;
        }
        var value = object["get" + qx.lang.String.firstUp(name)]();*

        // handle arrays
        if (qx.lang.Type.isArray(value)) {
          var isdataArray = qx.data && qx.data.IListData &&
            qx.Class.hasInterface(value && value.constructor,
qx.data.IListData);
          for (var i = 0; i < value.length; i++) {
            var valueAtI = isdataArray ? value.getItem(i) : value[i];
            result += this.__toUriParameter(name, valueAtI, qxSerializer);
          };
        } else if (qx.lang.Type.isDate(value) && dateFormat != null) {
          result += this.__toUriParameter(
            name, dateFormat.format(value), qxSerializer
          );
        } else {
          result += this.__toUriParameter(name, value, qxSerializer);
        }
      }
      return result.substring(0, result.length - 1);
    },





--
View this message in context: 
http://qooxdoo.678.n2.nabble.com/Need-help-with-Models-please-tp7581630p7581656.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to