1. #1
    Sencha User
    Join Date
    Nov 2010
    Posts
    1
    Vote Rating
    0
    ymnikmonozone is on a distinguished road

      0  

    Default How to Extend a Provider

    How to Extend a Provider


    Hi all

    I had an application with Extjs3 and I'm now migrating to ExtJS4.
    In this application I have a custom provider to work with ejabber. This was working perfectly with extjs3.

    When I try to integrate it to my Extjs4 application, I'm not able to declare it.
    I'm not able to make it accessible from my application.
    I have the source code of my extended provider in a js file. I add it in the "require" section of my main file. I can see it loaded in firebug. But each time I try to use Ext.direct.Manager.addProvider function with a provider of my newly created provider, it is failing..
    In the very first lines of the Ext.Direct.Manager.Provider in the function addprovider, I see that ExtJS4 is searching for the provider in package Ext.Direct.Manager + "type of the provider" + Provider .
    Does it means that to be able to extend a provider, I have to create the new provider in the package Ext.Direct.Manager ? It seems strange for me.
    I probably miss something and I really need help as I tried so many things to make it work but without any success and the communication with ejabber through events is the core of my application.

    Thanks for your help to anybody could help me to solve this issue.
    Regards
    Vince

  2. #2
    Sencha User
    Join Date
    Jan 2008
    Posts
    29
    Vote Rating
    0
    SAnDAnGE is on a distinguished road

      0  

    Default


    I know this is an old thread, but since noone gave a solution and google points to it, here is the solution I found:

    Code:
    Ext.define('myapp.direct.ZendProvider', {    
        alias: 'direct.zendprovider',
        extend: 'Ext.direct.RemotingProvider'
    });
    And this is all you need to extend it.

    To use it:

    Code:
    Ext.Direct.addProvider({
        enableUrlEncode : 'extDirectData',
        url             : './mymodule',
        format          : 'json',
        type            : 'zend',
        actions         : {
            index : [{
                name   : 'logout',
                len    : 0
            }]
        },
        namespace : 'myapp.mymodule.provider'
    });
    To call it:


    Code:
    myapp.mymodule.provider.index.logout();
    Also to make this code fully functional, you need to add:
    Code:
    Ext.Ajax.on('beforerequest', function(conn, options) {
    
        if (options.transaction && options.transaction.provider && options.transaction.provider.type == 'zend') {
            var controller = options.transaction.action;
            controller = controller.replace(/([a-z])([A-Z])/g, "$1.$2").toLowerCase();
            var action    = options.transaction.method;
            action = action.replace(/([a-z])([A-Z])/g, "$1.$2").toLowerCase();
    
    
            var url = options.url;
            url     = url +
                       (url.lastIndexOf('/') == url.length-1 ? '' : '/') +
                       controller +
                       '/' +
                       action;
    
    
            if (options.transaction.provider.format) {
                url += '/format/' + options.transaction.provider.format;
            }
    
    
            options.url            = url;
            options.disableCaching = true;
        }
    
    
    });
    This code is taken and made to work with ExtJs 4.0 from Conjoon (nice cute zend framework+extjs opensource application).

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi