1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Vote Rating
    jksnu is on a distinguished road


    Default Json to Java Deserialization problem


    I am using DirectJNgine along with ExtDirect but I am badly stuck in a problem. We have a requirement of calling a serverside method in clientside. Ex.

    ClientSide method:

    ServerMethod.resolver(jsonDaaaata,"abcde", function(result, e) 
      var t = e.getTransaction();
    Serverside direct method is :

     public void resolver(JsonElement companies, String commandName)
      System.out.println("we r in resolver method of client = ");
    Now in clientside method, "jsonDaaaata" may be any simple, complex, very complex json object or may be json array at run time and in serverside the method must have first parameter of some special datatype which can accept all types of Json object sent from the clientside.

    I have allready used following datatypes as a parameter on serverside method, but got following issues:
    JsonObject: Control goes into the serverside method but while watching "companies " in resolver() method in debug mode, it does not have value sent from the client side.
    JsonElement: Unable to invoke no-args constructor for class com.google.gson.JsonElement.
    JsonArray: Control is not coming in the serverside method i.e. resolver().

    So, please is there any datatype that we can use as a parameter in serverside method like resolver() so that it can accept any json data sent from client.

  2. #2
    Ext JS Premium Member
    Join Date
    May 2009
    Barcelona (Spain)
    Vote Rating
    pagullo will become famous soon enough pagullo will become famous soon enough



    Read the User's Guide -either for 1.3 or 2.0 alpha 1.

    There is a "Handling JSON data directly" chapter there, it might help.
    Pedro Agulló, Barcelona (Spain) - pagullo.soft.dev at gmail.com
    Agile team building, consulting, training & development
    DirectJNgine: http://code.google.com/p/directjngine - Log4js-ext: http://www.softwarementors.com/projects/p/log4js-ext/

Thread Participants: 1