[CLOSED] How to handle the result of DirectMethod?

  1. #1

    [CLOSED] How to handle the result of DirectMethod?

    Hi,

    How should I handle the result of a DirectMethod if I need to return some extra parameters to the client? The return type should probably be DirectResponse and then its ExtraParamsResponse property should be set. However, I'm confused by the fact that ExtraParamsResponse is string and not a collection type as in DirectEvents.
    Could you please provide a little code sample or an example link how to do this properly?

    <RowSelect Handler="X.DirectMethodTest(param1, 
                            {
                                eventMask: { showMask: true },
                                success: function (result) {
                                    var response = result.extraParamsResponse;
                                    // How to retrieve the return parameter??
                                    //var retParam1=response.get('retParam1');
                                },
                                failure: function (message) {
                                    Ext.Msg.show({
                                        msg: message,
                                        buttons: Ext.Msg.OK,
                                        title: 'Application Error',
                                        icon: Ext.Msg.ERROR,
                                        closable: false
                                    });
                                }
                            });" />
                            
    [DirectMethod]
    public DirectResponse DirectMethodTest(int param1)
    {
        // How to set the return parameters properly??
        DirectResponse result = new DirectResponse();
        string extraParamsResponse="retParam1=1;";
        result.ExtraParamsResponse=extraParamsResponse;
        
        return result;
    }
    Last edited by Daniil; Sep 17, 2012 at 4:20 PM. Reason: [CLOSED]
  2. #2
  3. #3
    Quote Originally Posted by Daniil View Post
    Thanks Daniil,

    From these examples, I suppose the recommended way of returning several parameters to the client is by using a custom object as a proxy. ExtraParamsResponse doesn't seem to be very functional.
  4. #4
    ExtraParamsResponse is for DirectEvents.

    In the case with DirectMethod please just return an object. It will be serialized with JSON.Serialize().
  5. #5
    Quote Originally Posted by Daniil View Post
    ExtraParamsResponse is for DirectEvents.

    In the case with DirectMethod please just return an object. It will be serialized with JSON.Serialize().
    Thanks for your suggestions Daniil! Please mark this question as resolved.

Similar Threads

  1. Replies: 4
    Last Post: Jun 13, 2014, 12:54 PM
  2. How to compute the result for the numberfields?
    By MagicWang in forum 1.x Help
    Replies: 1
    Last Post: Mar 02, 2012, 8:17 AM
  3. Replies: 3
    Last Post: Mar 25, 2011, 12:49 PM
  4. [CLOSED] Difference between DirectMethod , DirectEvent, Static DirectMethod
    By syllabusarq in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 01, 2011, 11:37 AM
  5. Replies: 1
    Last Post: Dec 09, 2010, 11:52 AM

Tags for this Thread

Posting Permissions