1. #21
    Sencha User
    Join Date
    Jan 2008
    Location
    Toronto, Canada
    Posts
    480
    Vote Rating
    4
    elishnevsky is on a distinguished road

      0  

    Default


    Does my TestApplication work for you?

  2. #22
    Ext JS Premium Member
    Join Date
    Nov 2008
    Location
    Warsaw area, Poland
    Posts
    64
    Vote Rating
    1
    nightwatch is on a distinguished road

      0  

    Default


    No, it doesn't. This code:
    Code:
    string json = "{\"action\":\"DirectRPC\",\"method\":\"Test1\",\"data\":[\"ziutek\"],\"type\":\"rpc\",\"tid\":2}";
                var listOfRequests = JsonConvert.DeserializeObject<List<DirectRequest>>(json);
                var singleRequest = JsonConvert.DeserializeObject<DirectRequest>(json);
    fails with the same exception as in my original post. So the problem is probably caused by different version of Newtonsoft.Json I'm using. Anyway, even if your version doesn't throw an exception, it doesn't deserialize DirectRequest correctly (returns an empty array instead), so the current DirectProvider will not work with this example. I'm using Newtonsoft.Json 3.5 beta 4 (because the rest of my application relies on this version).
    R

  3. #23
    Sencha User
    Join Date
    Jan 2008
    Location
    Toronto, Canada
    Posts
    480
    Vote Rating
    4
    elishnevsky is on a distinguished road

      0  

    Default


    Ok, newer version of Json .NET was released on July 6. It's 3.5 beta 4. My app is running on 3.5 beta 3. I guess the author of Json .NET changed the way deserializer works. I am going to download it later today and fix my app. Will post the update here.

  4. #24
    Ext JS Premium Member
    Join Date
    Nov 2008
    Location
    Warsaw area, Poland
    Posts
    64
    Vote Rating
    1
    nightwatch is on a distinguished road

      0  

    Default


    Thanks, hope the next version of Newtonsoft.Json will not break it again

  5. #25
    Sencha User
    Join Date
    Jan 2008
    Location
    Toronto, Canada
    Posts
    480
    Vote Rating
    4
    elishnevsky is on a distinguished road

      0  

    Default


    Quote Originally Posted by nightwatch View Post
    Thanks, hope the next version of Newtonsoft.Json will not break it again
    Yeah, let's hope so In the meantime you can use 3.5 beta 3.

  6. #26
    Sencha User
    Join Date
    Jan 2008
    Location
    Toronto, Canada
    Posts
    480
    Vote Rating
    4
    elishnevsky is on a distinguished road

      0  

    Default


    Quote Originally Posted by elishnevsky View Post
    Ok, newer version of Json .NET was released on July 6. It's 3.5 beta 4. My app is running on 3.5 beta 3. I guess the author of Json .NET changed the way deserializer works. I am going to download it later today and fix my app. Will post the update here.
    Fixed. Please get the updated version from the first post.

  7. #27
    Ext JS Premium Member
    Join Date
    Nov 2008
    Location
    Warsaw area, Poland
    Posts
    64
    Vote Rating
    1
    nightwatch is on a distinguished road

      0  

    Default


    Great, I have tested it and my original problem is gone. However, I have found another issue to keep you busy:
    I want to pass a json object directly to controller method, either as a JObject from Newtonsoft.Json library, or a dictionary - here are the examples:
    Code:
    public class DirectRPCController : Ext.Direct.Mvc.DirectController
        {
            public DirectResult Execute(JObject job)
            {
                return Direct("nie ma tu nic");
            }
    
            public DirectResult Execute2(Dictionary<string, object> job)
            {
                return Direct("nie ma tu nic");
            }
    
            public DirectResult Execute3(IDictionary job)
            {
                return Direct("nie ma tu nic");
            }
    }
    The problem is none of the above methods gets the correct value of input parameter. Client side looks like this:
    Code:
    DirectRPC.Execute({'ala':'ma kota', 'kot':'ma 2 lata'});
    DirectRPC.Execute2({'ala':'ma kota', 'kot':'ma 2 lata'});
    DirectRPC.Execute3({'ala':'ma kota', 'kot':'ma 2 lata'});
    And the JSON (ignore the backslashes):
    Code:
    "{\"action\":\"DirectRPC\",\"method\":\"Execute3\",\"data\":[{\"ala\":\"ma kota\",\"kot\":\"ma 2 lata\"}],\"type\":\"rpc\",\"tid\":2}"
    Upon deserialization in DirectProvider the DirectRequest.Data field contains an object (exactly of type System.Object), so all the json fields are lost. And when the method invocation is done first method (Execute) gets an empty JObject, second method gets an empty dictionary and the third one gets null.
    What is the correct method of passing any dictionary or any javascript object structure to a method?
    Best regards,
    Rafal

  8. #28
    Ext JS Premium Member
    Join Date
    Nov 2008
    Location
    Warsaw area, Poland
    Posts
    64
    Vote Rating
    1
    nightwatch is on a distinguished road

      0  

    Default


    Update: serialization doesn't work also for other custom object types, like:

    Code:
    public class Alice
        {
            public string ala { get; set; }
            public string kot { get; set; }
        }
    
        public class DirectRPCController : Ext.Direct.Mvc.DirectController
        {
            public DirectResult Execute4(Alice job)
            {
                return Direct("nie ma tu nic");
            }
    }
    If you invoke this method with the following js:
    Code:
    DirectRPC.Execute4({'ala':'ma kota', 'kot':'ma 2 lata'});
    the 'job' parameter will be null on invocation

    R

  9. #29
    Sencha User
    Join Date
    Jan 2008
    Location
    Toronto, Canada
    Posts
    480
    Vote Rating
    4
    elishnevsky is on a distinguished road

      0  

    Default


    I am afraid there is nothing I can do about it. Currently Ext.Direct doesn't support passing object literals as arguments. Here's a quote from Ext.Direct Remoting Specification:
    Each transaction can contain

    * action – The class to use
    * method – The method to execute
    * data – The arguments to be passed to the method – array (Ext.Direct will support named arguments in the future and thefore an object literal here)
    * type - “rpc” for all remoting requests
    * tid – Transaction ID to associate with this request. If there are multiple transactions in a single POST these will be different.
    If you want to pass complex type object you have to pass it as a string and then manually transform it into whatever object you want on the server. Simply encode your object literal to a string using Ext.encode() and pass the result to your method call. For an example look how I do it in my test application (file: SampleTestPanel.js, method: onEchoPerson())

  10. #30
    Ext JS Premium Member
    Join Date
    Nov 2008
    Location
    Warsaw area, Poland
    Posts
    64
    Vote Rating
    1
    nightwatch is on a distinguished road

      0  

    Default


    Ow, that would be a serious limitation. But I understand the specification differently:
    * data – The arguments to be passed to the method – array (Ext.Direct will support named arguments in the future and thefore an object literal here)

    For me it means that Ext.Direct passes method arguments in an array and not in object literal - that's perfectly OK, I don't want to pass arguments by name. I just want to pass more complex object structures as method arguments, and there's nothing in spec that would suggest it's not possible (actually, handling just simple value types would defeat the whole purpose of Json-RPC).
    And it actually does handle complex Json on client side - see my posts above and the Json string - it is delivered to the server, but the server-side code does not deserialize it properly. I think it could be greatly improved if your code used the type information from method parameters to deserialize Json to proper data types, not just System.Object which is useless.

    Best regards
    R

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."