Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to pass AdvanceCriteria argument using DMI from client to service method

    SmartClient Version: v9.1p_2014-03-18/Pro Deployment (built 2014-03-18)

    How can I pass a client side AdvancedCriteria (com.smartgwt.client.data.AdvancedCriteria) via a DMI call to a service implemented using the gwt server framework.

    It looks like the DSRequest parameter may be intended for this but on the server side the AdvancedCriteria retrieved from the DSRequest is of type (com.isomorphic.criteria.AdvancedCriteria) and no "magic" is performing the conversion on the DMI request.

    Bottom line is I want to have an AdvancedCriteria argument on my DMI service. Problem I'm having is converting from client side (smargwt) AdvancedCriteria to a serverside (isomorphic) criteria.

    Thanks

    #2
    When you pass AdvancedCriteria to a client-side API such as fetchData(), it is automatically delivered to the server, and an AdvancedCriteria object can be retrieved server-side in a DMI by calling dsRequest.getAdvancedCriteria() (where a DSRequest would be declared as the DMI parameter).

    Note that by design, the client-side and server-side AdvancedCriteria classes differ. But they provide access to the same data structure.

    Comment


      #3
      How to pass AdvanceCriteria argument using DMI from client to service method

      Isomorphic - thanks for the quick reply. I understand your response and in fact thought that's was how to do it based on your documentation, so I'm guessing I have something wrong in the implementation.

      Following is the relevant client/server side (pseudo) code

      ****************** Client Side pseudo code is:
      Code:
      import com.smartgwt.client.data.AdvancedCriteria
      import com.smartgwt.client.data.DSRequest
      
      ...
      
      // create advanced criteria
      AdvancedCriteria criteria = new AdvancedCriteria(  OperatorId.OR
         new Criterion []  new Criterion("field1",OperatorId.CONTAINS,"123"),
         blah, blah, blah ...);
      
      // ds request to contain advanced criteria
      DSRequest dsRequest = new DSRequest();
      dsRequest.setCriteria(criteria);
      
      // DMI Call passing AdvancedCriteria in dsRequest
      DMI.call(appID,className,methodName,callback,
                   new Object[] dsRequest);
      
      
      ******************  Server side pseudo code is:
      import com.isomorphic.datasource.DSRequest
      import com.isomorphic.datasource.AdvancedCriteria
      
      // Service method
      public  List<LinkedMap> methodName(SDRequest request)  {
           
          AdvancedCriteria c = request.getAdvancedCriteria();
      
          // -- AT THIS POINT ON THE SVC SIDE THE ADVANCED CRITERIA 
             -- C IS NOT CORRECT.  
             -- THE CODE DOES NOT COMPLAIN BUT IT PRODUCES NO FILTERING
             -- WHEN USED IN A SUBSEQUENT DS FETCH, 
             -- AND USING THE DEBUGGER ITS CLEAR C IS NOT CORRECT
      
             -- FOR the record if I construct the AdvancedCriteria in the service 
             -- method the fetch works so the problem is isolate to the
             -- AdvancedQuery object passed as a argument
      THANKS

      Comment


        #4
        No one can help you when all you are saying is that the behavior is not correct, with no details :)

        Please see the FAQ for the information you need to provide.

        Comment


          #5
          How to pass AdvanceCriteria argument using DMI from client to service method

          Thanks again for the quick reply.

          So I was hoping you could look at the 10 lines of pseudo code and possibly verify that the general approach is correct. Am I using the API correctly? Am I missing something on the implementation side? Does something have to be configured to get DMI argument conversion ? Does the code I provided look correct ?

          By not correct I meant that if I look at the Advanced Criteria on the server side using the debugger it does not contain any of the criteria I expected to see. It didn't contain anything that to me resembled a meaningful criteria AND when used with a DS fetch no filtering was performed. So my feeling is that this is probably a symptom of improper argument (The advanced criteria) serialization/deserialization from the client to the server.

          Its hard to provide details other than the code because I have no idea whats happening between the DMI call and the server invocation.

          Thanks

          Comment


            #6
            Its hard to provide details other than the code because I have no idea whats happening between the DMI call and the server invocation.
            Have you read the FAQ?

            It explains what you need to provide. It's very very easy to gather.

            Comment


              #7
              How to pass AdvanceCriteria argument using DMI from client to service method

              Thanks again for your response.

              I assume you are referring to I think "I found a bug in Smart GWT. What do I do?" in the Faq ?

              That is

              your GWT version & Smart GWT version
              -- Provided

              whether you were in GWT Hosted / Development mode or a normal browser
              browser version and operating system

              -- Problem occurring in Development mode, that the only way I have tested it

              what you expected to happen, and, if applicable, the Smart GWT documentation
              that led you to believe your approach would work.

              -- I provided more on this earlier. Expected AdvancedCriteria to be serialized, passed in DSRequest arg to service method, and deserialized for use in DS fetch. Looks to me like it not being properly serialized/deserialized. Not sure what documentation source(s) I pulled this from but I believe my approach was consistent with you original reply.

              Note the debugger shows the AdvancedCriteria received by the service to be " [and:[]]" which is nothing like the criteria passed in as a DMI arg (See the sample code provided in earlier post)


              1. the *complete* SmartGWT or SmartClient version from the lower left-hand corner of the Developer Console (see FAQ for how to open Developer Console), for example, \"v8.2p_2012-04-18/PowerEdition Deployment\"

              - I PROVIDE THIS

              2. browser(s) and version(s) involved

              - FIREFOX 13.0

              3. for a server-side problem, the *complete* logs generated during processing of the failing request (do *not* trim to just the error message)

              - I CANNOT SEND YOU THE LOGS, BUT I DON' T SEE ANY ENTRIES ON THE CONSOLE OR ERROR LOG DURING THE TIME PERIOD THE OPERATION IS RUN

              4. for any problem processing a server response, the actual response as shown in the RPC tab in the Developer Console

              - NOT APPLICABLE

              5. if there is a JavaScript error, the stack trace logged in the Developer Console (see FAQ)

              - NOT APPLICABLE

              6. sample code if applicable

              - I CANNOT SEND THE ACTUAL CODE - I SENT THE RELEVANT CODE PORTIONS EARLIER

              Posts with incomplete information are much more likely to be ignored.


              Have I missed something, thank for continuing to work with me on this

              Comment


                #8
                Wow, many steps needed to get to step 1...

                We don't know why you think the requests and responses from the RPC log would be inapplicable - that's applicable and needed.

                We need the server logs as well. You've just stated "I CANNOT SEND YOU THE LOGS" without giving any reason, well, they are required, no one can help you without seeing basics like this.

                Comment


                  #9
                  I'm not trying to be difficult but I'm working in a secure enviroment, getting logs or anything else out is pratically impossible. The reason I said they were N/A is that I saw nothing in the logs corresponding to the time when I executed the code in question. But I get your point. At any rate I'm not asking you to debug my code, just provide me with some guidance on how to pass an Advanced Criteria in a Client DMI call or take a look at the 5 lines of code I provided and see it it looks correct. A desk check if you will. My assumption is that my problem is probably incorrect API use not a gwt bug. Your response from earlier addresses the issue but I'm trying to pass the DSRequest via the DMI.call method and I dont think the automatic delivery you mentioned in your response is happening.

                  I have 4 relevant lines of code on there client side and 1 line of code on the server side (show below) Could you possibly tell me if these 5 lines looks correct ? Or point me to a code sample or explicit documentaion as to how I should be doing this.

                  Thanks for you patience

                  **************** CLIENT SIDE ***************
                  import com.smartgwt.client.data.DSRequest

                  ...

                  // create advanced criteria
                  AdvancedCriteria criteria = new AdvancedCriteria( OperatorId.OR
                  new Criterion [] new Criterion("field1",OperatorId.CONTAINS,"123"),
                  blah, blah, blah ...);

                  // ds request to contain advanced criteria
                  DSRequest dsRequest = new DSRequest();
                  dsRequest.setCriteria(criteria);

                  // DMI Call passing AdvancedCriteria in dsRequest
                  DMI.call(appID,className,methodName,callback,
                  new Object[] dsRequest);


                  ****************** SERVER SIDE *******

                  import com.isomorphic.datasource.DSRequest
                  import com.isomorphic.datasource.AdvancedCriteria

                  // Service method
                  public List<LinkedMap> methodName(SDRequest request) {

                  AdvancedCriteria c = request.getAdvancedCriteria();

                  // -- AT THIS POINT ON THE SVC SIDE THE ADVANCED CRITERIA
                  -- C IS NOT CORRECT, In debgger looks like " [and:[]]"
                  -- THE CODE DOES NOT COMPLAIN BUT IT PRODUCES NO FILTERING
                  -- WHEN USED IN A SUBSEQUENT DS FETCH,
                  -- AND USING THE DEBUGGER ITS CLEAR C IS NOT CORRECT

                  -- FOR the record if I construct the AdvancedCriteria in the service
                  -- method the fetch works so the problem is isolate to the
                  -- AdvancedQuery object passed as a argument
                  THANKS

                  Your response (in quotes below)
                  [quote]
                  When you pass AdvancedCriteria to a client-side API such as fetchData(), it is automatically delivered to the server, and an AdvancedCriteria object can be retrieved server-side in a DMI by calling dsRequest.getAdvancedCriteria() (where a DSRequest would be declared as the DMI parameter).
                  [quote]

                  Comment


                    #10
                    Customers working in a secure environment is a routine thing. Either:

                    1. Have a second environment that doesn't involve secure data where you can try things out

                    OR

                    2. Establish a Support relationship with Isomorphic, including NDAs or other legal documents enabling secure sharing of diagnostics

                    Or both. But again, just declining to share diagnostics at all won't work.

                    Note that among other reasons we need the logs:

                    1. It shows the criteria inbound to the server (your attempt to look in the debugger seems to have been botched)

                    2. It would clarify what you mean by "subsequent fetch" - this is too vague

                    Comment


                      #11
                      Can you possibly provide or point me to an example of passing an AdvancedCriteria as a argument in a DMI call "DMI.call(". It would really help to know if I have coded it correctly.

                      Thanks

                      Comment


                        #12
                        How to pass AdvanceCriteria argument using DMI from client to service method

                        Can you possibly provide or point me to an example of passing an AdvancedCriteria as a argument in a DMI call "DMI.call(". It would really help to know if I have coded it correctly.

                        Thanks

                        Comment


                          #13
                          How to pass AdvanceCriteria argument using DMI from client to service method

                          Let me ask this question another way.

                          Your documentation at
                          http://www.smartclient.com/smartgwtee/javadoc/com/smartgwt/client/docs/DmiOverview.html (shown in the code block below) has an example of passing arguments using RPC DMI. That's exactly what I am doing however I would like to add an argument of AdvancedCriteria type to the method signature.

                          Can you tell me how to go about this.

                          I'm guessing that I may need to handle the serialization/deserialization and conversion from client side to server side representation of this argument ? Or perhaps there is some capability in smartgwt RPC DMI to do this automatically ?


                          Code:
                          RPC DMIs work slightly differently. Unlike DataSource DMIs, RPC DMIs can have an arbitrary number of required arguments, and also some optional context arguments. For example, let's say you call a method from the client like so : 
                          
                             List someList = new ArrayList();
                             someList.add(1);
                             someList.add(2);
                             DMI.call("myApp", "com.sample.MyClass", "doSomething", new RPCCallback() {
                              
                              @Override
                              public void execute(RPCResponse response, Object rawData, RPCRequest request) {
                               
                               SC.say("raw data from server method:" + rawData.toString());
                               
                               
                              }
                             }, new Object[] {1, "zoo", someList});

                          Comment

                          Working...
                          X