1. #61
    Ext JS Premium Member dancablam's Avatar
    Join Date
    Apr 2008
    Location
    Dallas, TX
    Posts
    134
    Vote Rating
    0
    dancablam is on a distinguished road

      0  

    Default


    Hi oaugustus,

    Implementing the ext direct plugin into admin generator actions has proven to be tricky for others as well for similar reasons. What I may do, which may help other users such as nicolx as well, is add additional parameters in app.yml that let you manually specify actions for plugins and admin generator actions where reading the actions from the comments is not easy/possible.

    I'll experiment with this in the coming days and keep you posted.

    Thanks,
    Dan

  2. #62
    Ext JS Premium Member dancablam's Avatar
    Join Date
    Apr 2008
    Location
    Dallas, TX
    Posts
    134
    Vote Rating
    0
    dancablam is on a distinguished road

      0  

    Default


    Hi corpse_br,

    Not sure why you're seeing that error. Have you cleared the symfony cache? You might also using the debug flag (-d) when generating the API. Let me know if none of these suggestions helped and I'll see what else I can dig up for you.

    Cheers,
    Dan

  3. #63
    Ext User
    Join Date
    Nov 2007
    Posts
    7
    Vote Rating
    0
    corpse_br is on a distinguished road

      0  

    Default


    Thx Dan, problem solved!

    in factories.yml, I was doing:
    Code:
    all:
       extdirect:
          controller:
            class: dsExtDirectController

    instead of pasting it in the root level of the file:
    Code:
    extdirect:
          controller:
            class: dsExtDirectController
    all:
    ...
    it verks!!!

  4. #64
    Ext User
    Join Date
    Apr 2010
    Posts
    1
    Vote Rating
    0
    alexro is on a distinguished road

      0  

    Default Ext.Direct calls to model-classes

    Ext.Direct calls to model-classes


    Hi Dan,

    is it possible to have your plugin parse not only the action-classes but the model classes (lib/model/...) as well? It would be nice, if you could make extdirect calls to the model classes. This would skip the controller, of course ...

  5. #65
    Ext JS Premium Member dancablam's Avatar
    Join Date
    Apr 2008
    Location
    Dallas, TX
    Posts
    134
    Vote Rating
    0
    dancablam is on a distinguished road

      0  

    Default


    Hi alexro,

    I'm hesitant to bypass the action layer as this would skirt all of symfony's security capabilities as well as numerous object instantiations like sfWebRequest, sfWebResponse, and other objects that both the plugin and symfony rely on to function. To do what you're wanting I would suggest using the straight PHP router on a non-symfony project and just download a standalone instance of Doctrine or Propel to use as your ORM.

    Cheers,
    Dan

  6. #66
    Ext User
    Join Date
    Jun 2007
    Location
    Reading, UK
    Posts
    22
    Vote Rating
    0
    RyanG is on a distinguished road

      0  

    Default


    Hi Dan,

    Firstly, thanks a lot for a great plugin, works really well and has saved me a lot of time and effort with my application development so far.

    One thing I've noticed though, is that if I populate $this->result in my action with an already created JSON string (for example, i'm using atolExt3WidgetPlugin to build formpanel JSON (derived from a Symfony form) and return it via Ext.Direct), by the time the router assembles the response it json_encodes a JSON string and puts it into the result hash.

    resulting in:

    Code:
    "result":"{xtype:\"form\",url:null,monitorValid:true,standardSubmit:false,method:\"POST\",autoScroll:true,labelWidth:150,bodyStyle:{padding:\"10px\"},buttons:[{xtype:\"directsubmitbutton\",cls:\"sf_validate_button\",text:\"Submit\"}]
    desired instead:

    Code:
    "result": { xtype: "form", url: null ... etc ... }
    Of course I can run Ext.decode(data.result) to convert the escaped string back into a JS hash again, but it would be nice if it was in the correct format when served out in the first place?

    I'm wondering if it might be worth adding an action comment tag like @rawJsonOutput to ensure that the result is inserted without attempting to json encode a string which is already in JSON format.

    Does anyone have a view on this please, or am I simply missing something obvious?

    Thanks,

    Ryan

  7. #67
    Ext JS Premium Member dancablam's Avatar
    Join Date
    Apr 2008
    Location
    Dallas, TX
    Posts
    134
    Vote Rating
    0
    dancablam is on a distinguished road

      0  

    Default


    Hi Ryan,

    Yeah the controller will definitely attempt to encode anything you get it into JSON as you've seen. My recommendation is to simply do:
    Code:
    $this->result = json_decode($myData, true);
    The overall performance hit would be on the order of a few microseconds so this should work just fine unless you have an extremely high performance requirement. Let me know if that works for you.

    Cheers,
    Dan

  8. #68
    Ext User
    Join Date
    Jun 2007
    Location
    Reading, UK
    Posts
    22
    Vote Rating
    0
    RyanG is on a distinguished road

      0  

    Default


    Hi Dan,

    Thanks for the tip, but unfortunately as the JSON string I am trying to put into $this->result sometimes contains references to Ext.Direct methods (eg. in a DirectStore ComboBox directFn definition), it returns a null string as I assume json_decode considers the string illegal.

    If it were possible to use a raw attribute comment tag for the action as I mentioned before, perhaps you could temporarily replace $this->result with "%REPLACE%" and then after the direct router json_encodes it, simply replace that string with the raw JSON output again and serve it all up?

    Not the most elegant solution, but I'm not sure one exists for this particular case? Do you have any other ideas?

    Thanks,

    Ryan

    Quote Originally Posted by dancablam View Post
    Hi Ryan,

    Yeah the controller will definitely attempt to encode anything you get it into JSON as you've seen. My recommendation is to simply do:
    Code:
    $this->result = json_decode($myData, true);
    The overall performance hit would be on the order of a few microseconds so this should work just fine unless you have an extremely high performance requirement. Let me know if that works for you.

    Cheers,
    Dan

  9. #69
    Ext JS Premium Member dancablam's Avatar
    Join Date
    Apr 2008
    Location
    Dallas, TX
    Posts
    134
    Vote Rating
    0
    dancablam is on a distinguished road

      0  

    Default


    Hi Ryan,

    Can you post an example of some JSON that returns a NULL string? If it's valid JSON you should be able to decode regarless of what references it contains.

    Dan

  10. #70
    Ext User
    Join Date
    Jun 2007
    Location
    Reading, UK
    Posts
    22
    Vote Rating
    0
    RyanG is on a distinguished road

      0  

    Default


    Hi Dan,

    Ok, so heres a small excerpt of my test JSON which gives NULL when doing json_decode:

    Code:
    {
       xtype:"form",
       url:null,
       monitorValid:true,
       standardSubmit:false,
       method:"POST",
       autoScroll:true,
       labelWidth:150,
       bodyStyle:{
          padding:"10px"
       },
       buttons:[
          {
             xtype:"submitbutton",
             cls:"sf_validate_button",
             text:"Submit"
          }
       ],
       api:{
          submit:Extdirect.project.update
       },
       paramsAsHash:true,
       border:false
    }
    There are 2 problems with it: a) The names need to be in double quotes, b) and so do the values ... so using direct JS function references like "submit: Extdirect.dceProject.update" will also return NULL

    The real issue here is that while the above JSON string is valid Javascript, the built in PHP JSON parser cannot handle it and gives up.

    I am quite impressed with atolExt3WidgetPlugin's JSON builder (which is where the above string came from), but when it comes to reversing that JSON string in PHP your options are pretty limited.

    I'm still thinking my original idea from earlier post could work, but of course its up to the developer to ensure the JSON string in $this->result is completely valid.

    One other client-side option might be to intercept the JSON receipt in a Direct call before the requesting code has a chance to do anything with it, and run a quick Ext.decode over it first, but again I think I'd prefer it was in the desired format to begin with.

    Hope this helps!

    Thanks,

    Ryan