1. #21
    Ext JS Premium Member
    Join Date
    May 2007
    Posts
    44
    Vote Rating
    0
    netsuo is on a distinguished road

      0  

    Default


    Hi !

    I think I've found what caused my problem and you where true, the echo wasn't the problem.
    I don't know why (maybe a copy/paste error between two projects I'm working on), but after my "echo" there was a "die();"... now it explains all ;-)

    Sorry to have taken your time away. Rest assured I will report anything (real) I'll found about your ExtDirect, because I'll use it extensively the next weeks in a project I'm starting right now.

    Thanks a lot to have taken some time to help me, it definately gave me some advice on my problem !

  2. #22
    Sencha User j.bruni's Avatar
    Join Date
    Jun 2009
    Location
    Uberlândia, MG, Brazil
    Posts
    105
    Vote Rating
    7
    j.bruni is on a distinguished road

      0  

    Thumbs up New version - new features - coming soon!

    New version - new features - coming soon!


    Quote Originally Posted by netsuo View Post
    Sorry to have taken your time away. Rest assured I will report anything (real) I'll found about your ExtDirect, because I'll use it extensively the next weeks in a project I'm starting right now.

    Thanks a lot to have taken some time to help me, it definately gave me some advice on my problem !
    No problem. In fact, I thank the opportunity to share here in the forums a bit more information about "ExtDirect.php" internals. Also, each post makes the thread stay on top of the latest updated!

    I thought the cause of your problem could be also something related to the "header" command in ExtDirectController::output... but now you already found the real cause.

    I am using this "ExtDirect.php" in a project I am developing right now. More features were recently added! So, soon I will upload a new version.

    Basically, three new configuration options were added, all of callback type: "authorization_function", "transform_result_function", and "transform_response_function"

    You will be able to specify an "authorization_function", where you can check the user permissions and return true or false accordingly, allowing the API call or not.

    With the "transform_result_function", you can modify the result of the API method call after its execution, but before it is sent to the client-side.

    Finally, with the "transform_response_function", you can modify the response structure. This allows to fire server-side events! But I am not using this feature for it. I am using it to send extra server side data together with the RPC result.

    So... stay tuned!

    CYO

  3. #23
    Sencha User
    Join Date
    Mar 2010
    Posts
    47
    Vote Rating
    0
    Andrew Peacock is on a distinguished road

      0  

    Default


    Great job J! I just implemented this as a test last night, and like it's simplicity.

    One question though (which may or may not be specific to your code): I'm planning on using ExtJS's polling functionality soon - is there any way to pass a direct function into a polling provider (a bit like directFn for data stores)?

    Regards,
    Andy

  4. #24
    Sencha User aw1zard2's Avatar
    Join Date
    Sep 2009
    Location
    Dallas, Texas
    Posts
    577
    Vote Rating
    32
    aw1zard2 has a spectacular aura about aw1zard2 has a spectacular aura about

      0  

    Default


    Nice job on this! My company has a good jump ahead on this from compared to what you have made but you are getting the clear picture.

    Unfortunately I can't discuss in public what our company is doing, but if you need/want to chat about anything just shoot me a message.

    Regards,
    Ron

  5. #25
    Sencha User
    Join Date
    Mar 2010
    Posts
    47
    Vote Rating
    0
    Andrew Peacock is on a distinguished road

      0  

    Default


    Hi all,
    A word of advice:

    This works:

    Code:
     
    ExtDirect::$form_handlers = array( 'Config::setConfig');   
    ExtDirect::provide( 'Config' );
    This doesn't :-)
    Code:
     
    ExtDirect::provide( 'Config' );
    ExtDirect::$form_handlers = array( 'Config::setConfig');
    The latter method generates stack overflow errors when using multiple parameters, although it works fine with 1 parameter or 0 parameters, oddly.

    Great work - I love the form handler shortcut of having parameters automatically defined via the $_POST parameter names. Very slick!

    Andy

  6. #26
    Sencha User
    Join Date
    Mar 2010
    Posts
    47
    Vote Rating
    0
    Andrew Peacock is on a distinguished road

      0  

    Default


    PROBLEM SOLVED: SEE ANSWER LATER IN THIS POST

    Hi,
    One question about form data: I'm using a checkbox which submits the value "on" if it is selected. However, if it's not selected, nothing gets submitted, and the direct function doesn't seem to run at all. Here's the function being called:

    Code:
    public function setProxiesConfig($proxies_enabled="") {
            firebird("Proxies enabled = " . $proxies_enabled);
            $this->setOption("proxies_enabled",     $proxies_enabled);
            $this->saveConfig();
            
            $obj = array(
                            'success'    => true
                        );
                    
            return $obj;
        }
    Firebird() is a self-written routine to dump the output to firePHP and a debug file as well. As it's the first line in the function, I would expect it to run, but it doesn't, which implies the function is not running.

    The JSON response was:

    {"type":"rpc","tid":"12","action":"ConfigManager","method":"setCaptchaConfig","result":"Exception"}

    But there was no PHP error generated that I can see anywhere (and I've got PHP writting errors to a single log file regardless of which PHP file was running).

    Can anyone offer any inspiration to get round this?

    Regards,
    Andy


    SOLUTION FOUND:
    Enable the option to only count mandatory parameters:
    Code:
    ExtDirect::$count_only_required_params = true;
    Last edited by Andrew Peacock; 14 Jul 2010 at 1:30 PM. Reason: Problem solved

  7. #27
    Sencha User
    Join Date
    Mar 2010
    Posts
    47
    Vote Rating
    0
    Andrew Peacock is on a distinguished road

      0  

    Default


    Hi,
    Anyone got any thoughts on how to do this within a polled operation?
    Andy

  8. #28
    Sencha User
    Join Date
    Mar 2010
    Posts
    47
    Vote Rating
    0
    Andrew Peacock is on a distinguished road

      0  

    Default How to access the returned data?

    How to access the returned data?


    OK, it's been a long day, I'm just back off my hols, and I'm new to this kind of complex JS, so I can't work this one out.

    I've got the extdirect code working absolutely fine. But I'm having problems accessing the returned data FROM OUTSIDE THE EXTDIRECT CALL...

    Here's the relevant code:

    Code:
      var plugins = ['plugin1', 'plugin2'];
      var input="Anyone there? " ;
      var hook='test';
      
      function executeHook(hook, input) {
       var output = "";
       Ext.php.PluginManager.executeHooks(plugins, hook, input, function(data) {
        console.info("DEBUG WITHIN FUNCTION: " + data);
        output = data;
       });
       return output;
      }
      
      console.info("RESULT FROM FUNCTION:" + executeHook(hook, input));

    Each plugin simply adds a piece of test to the input, in a chain. So the output should be:

    "Anyone there? Hello from core; Hello from plugin 2; Hello from plugin 1; "



    However, the console has the two output lines as follows:
    "RESULT FROM FUNCTION:"
    "DEBUG WITHIN FUNCTION: Anyone there? Hello from core; Hello from plugin 2; Hello from plugin 1; "

    So the variable data is correct within the ExtDirect call, but how do I get access to the data outside the ExtDirect call?

    I've also tried:

    Code:
    Ext.php.PluginManager.executeHooks(plugins, hook, input, function(data) {
        console.info("DEBUG WITHIN FUNCTION: " + data);
        return data;
       });
    But that produces the same result.

    Any ideas?

    Regards,
    Andy

  9. #29
    Ext User
    Join Date
    May 2010
    Posts
    3
    Vote Rating
    0
    Trii is on a distinguished road

      0  

    Default


    @Andy

    You must remember that the Ext.Direct calls are asynchronous which means you cannot count on the callback parameter being executed in a linear fashion like the rest of your function code. In your example the function executeHook() calls the Direct method which sets a callback, then it returns output, which is empty until the callback is called. Once the HTTP request initiated by the executeHooks() completes, it then calls your callback and sets the value of output but by then your initial function has returned. You will have to redesign your logic to handle this

  10. #30
    Sencha User
    Join Date
    Mar 2010
    Posts
    47
    Vote Rating
    0
    Andrew Peacock is on a distinguished road

      0  

    Default


    Thanks Trii... I came to the same conclusion myself shortly afterwards. I typed that discovery into a post here, but I guess I forgot to press "submit". But thanks anyway - I appreciate your help.

    Whilst you and I are here.... I don't suppose you've got any thoughts about how to use this integration in a polling process? I don't have a scooby where to start.

    (Scooby => Scooby Doo => clue)

    Regards,
    Andy