1. #221
    Ext JS Premium Member
    Join Date
    Aug 2009
    Posts
    112
    Vote Rating
    1
    Whatty is on a distinguished road

      0  

    Default Ext.Direct v2.0.50727

    Ext.Direct v2.0.50727


    Good afternoon,

    I am using the above version of the Ext.Direct Router with ExtJS 4.0 and am having problems with the following
    Code:
    "{\"action\":\"AppPreferencesActionImpl\",\"method\":\"updateAppPreferences\",\"data\":[{\"reviewDateRangeID\":2,\"requireSufficientFunds\":0}],\"type\":\"rpc\",\"tid\":2}"
    This is initiated from a model.save on the client side

    The problem is that the data
    Code:
    \"data\": [{\"reviewDateRangeID\":2,\"requireSufficientFunds\":0}]
    is being converted to a dynamic object when the request is being deserialized in the
    Code:
    DirectProcessorImpl
    however the direct action is expecting the RAW JSON string

    Code:
    {\"reviewDateRangeID\":2,\"requireSufficientFunds\":0}
    Now we have verified that the existing code works if we wrap the data element with quotes, such as

    Code:
    \"data\": ["{\"reviewDateRangeID\":2,\"requireSufficientFunds\":0}"]
    Is this a known issue with ExtJS 4.0 and the older versions of the library - if so I am assuming that the newer versions have addressed this issue.

    Now we are supporting both ExtJS 3.x and ExtJS 4.0 in the same application - until such a time as when the entire application gets converted - are the new Ext.Direct 4.0 libraries backwards compatible with ExtJS 3.x clients.

    Please advise!!!

    Whatty

  2. #222
    Sencha User
    Join Date
    Apr 2011
    Posts
    3
    Vote Rating
    0
    romarybachok is on a distinguished road

      0  

    Default


    Hi everybody, I am newcomer in Ext Direct. How can I receive data like in chat - after clicking on button the typed text will be sent for all pages of my asp net application in every opened tab.
    Here is my JS file:

    Code:
    Ext.onReady(function () {
        Ext.ns('Ext.ss');
        Ext.ss.APIDesc=
        {
            "url": "Router.cs",
            "namespace": "MyApp",
            "type": "remoting",
            "actions": {              
                "MyClass": [       
                {
                "name": "GetString", 
                "len": 1
            }]
        }    
    };
    
    Ext.QuickTips.init();
    
    var form = new Ext.form.FormPanel({
        renderTo: 'container',
        hideLabels: true,
        bodyStyle: 'padding: 20px;',
        width: 400,
        height: 150,
        items: {
            itemId: 'input',
            xtype: 'textfield',
            value: '123'
        },
        buttons: [{
            text: 'send',
            handler: function () {
                var text = form.getComponent('input').getValue();
                MyApp.MyClass.GetString(text, function (data) {
                    form.getComponent('input').setValue(data);
                });
            }
        }]
    });
    });
    and here is my c# class:

    Code:
    using System;
    
    namespace MyApp
    {
        public class MyClass
        {
            public String GetString(String s)
            {
                return s+" after server-side";
            }
        }
    }
    And I also need help with configuration of my router... It should be realized as http handler? I don't need a stack, I need simple example using 1 server method. THX)

  3. #223
    Sencha User
    Join Date
    Apr 2011
    Posts
    31
    Vote Rating
    0
    Dengqiao Huang is on a distinguished road

      0  

    Default


    I use store in ExtJS 4.
    I added two records, and then synchronize.
    The post data:
    Code:
    {
        "action":"Product",
        "method":"Add",
        "data":[
            [
                {
                    "ProductID":0,
                    "ProductName":"Computer",
                    "SupplierID":1,
                    "CategoryID":1,
                    "QuantityPerUnit":"",
                    "UnitPrice":3000,
                    "UnitsInStock":10,
                    "UnitsOnOrder":10,
                    "ReorderLevel":0,
                    "Discontinued":false
                },
                {
                    "ProductID":0,
                    "ProductName":"Computer",
                    "SupplierID":1,
                    "CategoryID":1,
                    "QuantityPerUnit":"",
                    "UnitPrice":3000,
                    "UnitsInStock":10,
                    "UnitsOnOrder":10,
                    "ReorderLevel":0,
                    "Discontinued":false
                }
            ]
        ],
        "type":"rpc",
        "tid":2
    }
    The result:
    Code:
    [
        {
            "type":"exception",
            "tid":2,
            "action":"Product",
            "method":"Add",
            "message":"Parameters length does not match"
        }
    ]
    The Store Config:
    Code:
    var store=Ext.create(Ext.data.Store,{
        model:'Products',
        autoLoad:true,
        pageSize:20,
        remoteFilter:true,
        remoteSort:true,
        storeId:"ProductStore",
        proxy:{
            type:"direct",
            //directFn:Ext.app.Product.List1,
            api:{
                read:Ext.app.Product.List,
                create:Ext.app.Product.Add,
                update:Ext.app.Product.Edit,
                destroy:Ext.app.Product.Delete
            },
            reader:{
                type:"json",
                root:"data"
            },
            writer:{
                type:"json",
                //allowSingle:false
            }
        }
    })

  4. #224
    Ext JS Premium Member
    Join Date
    Aug 2009
    Posts
    112
    Vote Rating
    1
    Whatty is on a distinguished road

      0  

    Default Ext.Direct support for polling

    Ext.Direct support for polling


    Good evening,

    Does the Ext.Direct stack provide support for polling?

    Whatty

  5. #225
    Ext JS Premium Member westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    905
    Vote Rating
    40
    westy is a jewel in the rough westy is a jewel in the rough westy is a jewel in the rough

      0  

    Default


    Quote Originally Posted by Whatty View Post
    Does the Ext.Direct stack provide support for polling?
    Hi,

    Not really what Ext.Direct is all about, or indeed Ajax; the idea is that it makes server-side methods appear as they are on the client-side, handling all the comms and callbacks for you.

    You could always write something that polled an Ext.Direct method on the client-side, kinda, but it's not very web2.0/ajaxy is it?

    Cheers,
    Westy
    Product Architect
    Altus Ltd.

  6. #226
    Sencha User
    Join Date
    Mar 2010
    Location
    Modena, Italy
    Posts
    59
    Vote Rating
    1
    gianmarco is on a distinguished road

      0  

    Default


    Quote Originally Posted by Whatty View Post
    Good evening,

    Does the Ext.Direct stack provide support for polling?

    Whatty
    Yes, see http://docs.sencha.com/ext-js/4-0/#!...ollingProvider

  7. #227
    Ext JS Premium Member westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    905
    Vote Rating
    40
    westy is a jewel in the rough westy is a jewel in the rough westy is a jewel in the rough

      0  

    Default


    Oh yeah, forgot about that provider
    Product Architect
    Altus Ltd.

  8. #228
    Sencha User
    Join Date
    Oct 2011
    Posts
    61
    Vote Rating
    0
    azinyama is on a distinguished road

      0  

    Default Catch Direct Exception

    Catch Direct Exception


    Hi, all!!! I'm a newbie with ExtJS 4...
    I have a tree store loading data from a database and would like to catch an exception if the there is an error loading the data, or if the asp.net session has expired. Below is my code.
    Javascript:
    Code:
    var store = Ext.create('Ext.data.TreeStore', 
            {
                autoLoad    : true,
                model       : 'DisabledTreePanelNode',
                root        : {
                                expanded    : true
                            },
                proxy       : {
                                type        : 'direct',
                                directFn    : _User.Load_TreeItem,
                                listeners   : {
                                                exception   : function(proxy, response, operation)
                                                            {
                                                                Ext.MessageBox.show(
                                                                {
                                                                    title   : 'REMOTE EXCEPTION',
                                                                    msg     : operation.getError(),
                                                                    icon    : Ext.MessageBox.ERROR,
                                                                    buttons : Ext.Msg.OK
                                                                });
                                                            }
                                            }
                            },
                listeners   : {
                                beforeload  : function(s, operation, eOpts)
                                            {
                                                desktop.setSystemStatus('Loading menu item options...', 'icon-loading');
                                            },
                                load        : function(store, node, records, success, eOpts)
                                            {
                                                if (success)
                                                {
                                                    desktop.setSystemStatus('Ready...', 'icon-accept');
                                                }
                                                else
                                                {
                                                    desktop.setSystemStatus('An error occured while trying to menu item options...', 'icon-error');
                                                    
                                                    Ext.MessageBox.show(
                                                    {
                                                        title   : 'REMOTE EXCEPTION',
                                                        msg     : 'An error occured while trying to menu item options...',
                                                        icon    : Ext.MessageBox.ERROR,
                                                        buttons : Ext.Msg.OK
                                                    });
                                                }
                                            }
                            }
            });
    Code:
    <DirectMethod()> _
            Public Function Load_TreeItem() As NodeCollection ' NodeSerializer 'ByVal order As String, ByVal direction As String) As UserSerializer
                'Dim userList As JArray = New JArray()
                Dim sm As SessionManager = SessionManager.getInstance()
    
                Dim objS As ISession = CType(sm.getSession(ClaimCatch_Main.AppHandler.stridSession), ISession)
                objS = Nothing 'set the session object to nothing
                If objS Is Nothing Then
                    Throw New Exception("Session has expired. Login again") 'send this message as exception message. THIS ISN'T WORKING.
                End If
    
                Return New NodeCollection()
            End Function
    I'm getting stuck at trying to get the message "Session has expired. Login again" on the javascript side.

    Any help would be appreciated.

  9. #229
    Sencha User
    Join Date
    Oct 2011
    Posts
    61
    Vote Rating
    0
    azinyama is on a distinguished road

      0  

    Default Ext.Direct .NET Router

    Ext.Direct .NET Router


    Anyone have answer to my question.

  10. #230
    Ext JS Premium Member westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    905
    Vote Rating
    40
    westy is a jewel in the rough westy is a jewel in the rough westy is a jewel in the rough

      0  

    Default


    Try overriding the direct proxy, and adding some logic to afterRequest.

    e.g.
    Code:
    Ext.define('Foo.data.proxy.Direct', {
        extend: 'Ext.data.proxy.Direct',
    
    
        alias: 'proxy.foo-direct',
    
    
        /**
         * Displays an error if the request failed.
         * @param {Object} request The Request object.
         * @param {Boolean} success True if the request was successful.
         */
        afterRequest: function(request, success) {
            if (!success && request.operation.hasException()) {
                Ext.Msg.show({
                    title: 'Error',
                    msg: request.operation.getError(),
                    buttons: Ext.MessageBox.OK,
                    icon: Ext.MessageBox.ERROR
                });
            }
        }
    });
    That's what I do, since with event handlers, other handlers can stop them propagating, or if someone downstream adds them in the same way (i.e. in the config as you're doing) then they get overwritten...

    I seem to remember a bug I raised to do with the events not getting properly raised.

    Another thought, can you see your exception coming back in Firebug?

    Cheers,
    Westy
    Product Architect
    Altus Ltd.