1. #1
    Sencha Premium Member
    Join Date
    Jul 2007
    Location
    Sydney, Australia
    Posts
    138
    Answers
    2
    Vote Rating
    5
    seade is on a distinguished road

      0  

    Default Unanswered: Format of and alternatives to Direct Resource

    Unanswered: Format of and alternatives to Direct Resource


    Architect allows me to add a Direct Resource but my Ext.Direct provider (DirectJNgine) provides the API descriptor in a slightly different format and hence it will not load.

    I get the impression (it is not exactly clear) from http://docs-origin.sencha.com/archit...section-DirRes that the URL should return something like
    Code:
    {
        url: someurl.php,
        type: 'remoting',
        namespace: 'app.RPC',
        actions: {...}
    }
    DirectJNgine however provides:
    Code:
    Ext.namespace( 'app.RPC');
    
    app.RPC.PROVIDER_BASE_URL=window.location.protocol + '//' + window.location.host + '/' + (window.location.pathname.split('/').length>2 ? window.location.pathname.split('/')[1]+ '/' : '')  + 'djn/directprovider';
    
    app.RPC.POLLING_URLS = {}
    
    
    app.RPC.REMOTING_API = {
      url: app.RPC.PROVIDER_BASE_URL,
      type: 'remoting',
      actions: {...}
    }
    The result is that Direct Resource cannot be used. So my first comment is that it would be good if Direct Resource could be a little more flexible in relation to how it deals with the response from the URL (I equally acknowledge that DirectJNgine should be more flexible in relation to how it generates the file).

    As a fallback I am including the API descriptor via a regular JS Resource and therefore need to invoke
    Code:
    Ext.Direct.addProvider(app.RPC.REMOTING_API);
    somewhere. The obvious place to do this would seem to be in Ext.application.launch(), but if I do this the API is not loaded before one of my views that needs to reference it. I can add the provider in the init method of the controller associated with the view to get it to work, but this seems like a fairly random place to be loading the API. So where do you suggest I load it?

    Because I am loading the file in this fashion I don't get any visibility of the API in the selectors for directFn and in fact I don't seem to be able to access the API from a Direct proxy - neither directFn nor API can see the previously declared remote API. This has me kind of stuck. Suggestions for a path forward would be welcome.

    Scott

  2. #2
    Sencha Premium Member
    Join Date
    Jul 2007
    Location
    Sydney, Australia
    Posts
    138
    Answers
    2
    Vote Rating
    5
    seade is on a distinguished road

      0  

    Default


    Through a bit of trial and error I can see that Direct Resource is in fact expecting from the defined url a response such as:
    Code:
    Ext.app.REMOTING_API = {
        url: 'djn/directprovider',
        type: 'remoting',
        namespace: 'app.RPC',
        actions: {...}
    }
    The quotes around the url, type and namespace values are essential. It is unclear how I would go about specifying polling URLs.

    SA does not seem to accept the response from the url if there is anything other than a comment ahead of the above content.

  3. #3
    Sencha Premium Member
    Join Date
    Jul 2007
    Location
    Sydney, Australia
    Posts
    138
    Answers
    2
    Vote Rating
    5
    seade is on a distinguished road

      0  

    Default A way of making DJN 2.2 work with SA3

    A way of making DJN 2.2 work with SA3


    While it would be great if SA was a little more flexible in relation to how a Direct Resource is configured, I have provided a small patch to DJN to have it produce the API file in a format acceptable to SA3. See http://www.sencha.com/forum/showthre...=1#post1010977

    HTH, Scott

  4. #4
    Sencha - Architect Dev Team jjohnston's Avatar
    Join Date
    Sep 2010
    Posts
    461
    Answers
    18
    Vote Rating
    15
    jjohnston will become famous soon enough jjohnston will become famous soon enough

      0  

    Default


    Thanks for taking the time to patch DirectJNgine.

    I agree that Architect needs to be more flexible in the formats it accepts; I'm opening an internal ticket to get that improved. (DSGNR-5141 for our future reference)

    As for the dependency-order issue with the addProvider call, here's how Architect handles that when using a Direct Resource:

    - A class MyApp.DirectAPI is created at app/DirectAPI.js
    - That class requires the Ext.direct.* classes, and then in its class definition callback it defines the provider object and calls addProvider
    - Any proxy that uses this provider adds MyApp.DirectAPI to its requires

    While it may look a bit obscure, this setup is the cleanest way we've found to ensure that addProvider is called after the Ext.direct.* classes are defined but before the Direct proxies are initialized. And it works when building your app with Cmd.

    I hope that helps,
    --Jason
    Jason Johnston
    @lojjic
    Sencha Architect Development Team

Thread Participants: 1