Announcement

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

    DMI.call requestParams

    Can you confirm if this would be the recommended approach for accessing DMI.call(...) requestParams (i.e. additional properties on RPC request).

    It appears to function as expected, however, I couldn't see a getter for "ctx.request", so I have a feeling this might not be the recommended approach. The RPCRequest doesn't seem to have a getHttpServletRequest() method like DSRequest.getHttpServletRequest().

    Thanks

    Client:

    Code:
    RPCRequest requestParams = new RPCRequest();
    Map<String, String> params = new HashMap<String, String>();
    params.put("param", "paramValue");
    requestParams.setParams(params);
    
    DMI.call(xxx, xxx, xxx, xxx, xxx, requestParams);
    Server:

    Code:
    handleRPCRequest(RPCRequest req, RPCManager mgr, RequestContext ctx) {
        String parameter = ctx.request.getParameter("param");
    }
    Last edited by stonebranch2; 23 May 2014, 08:32.

    #2
    What you're setting with your client-side code is an HTTP parameter, so yes, you are accessing it correctly.

    Comment


      #3
      Thank you.

      One additional question here with respect to RPCManager.doCustomResponse().

      I am wondering what to return with respect to the response from handleRPCRequest after calling RPCManager.doCustomResponse() and performing a custom response.

      Is A, B, or C the appropriate way to handle the response being returned from handleRPCRequest.

      Thanks again.

      Code:
          @Override
          public RPCResponse handleRPCRequest(RPCRequest req, RPCManager mgr, RequestContext ctx) throws Exception {
              ...
              if (somecondition) {
                  mgr.doCustomResponse();
                  ctx.response.sendError(...);
      
                  A)
                  return mgr.getResponse(req);
      
                  B)
                  return null;
      
                  C)
                  return new DSResponse();
              }
              ...
              return super.handleRPCRequest(req, mgr, ctx);
          }

      Comment


        #4
        Doesn't matter. Once you've indicated you're doing a custom response, your return value is going to be ignored because all remaining processing is skipped.

        Comment


          #5
          Great, Thx.

          I noticed "ctx.session" is null; I had to use "ctx.request.getSession()" to access the HttpSession. Is there something I should be aware of with respect to "ctx.session"?

          Regards

          Comment


            #6
            It will be null unless you enable a framework feature that would have a reason to use the session (because we don't want to force session usage if your app doesn't need it).

            Comment


              #7
              OK.
              Thanks again for the feedback.

              Comment

              Working...
              X