1. #1
    Sencha User
    Join Date
    Apr 2008
    Location
    Germany
    Posts
    24
    Vote Rating
    0
    Yasheena is on a distinguished road

      0  

    Default Ext.Direct Exceptions and Events

    Ext.Direct Exceptions and Events


    Hi,
    Ext.Direct is a wonderful method to interact with the server side, but I have a few questions about things I cannot found in the source.

    1) In Direct.js I found:
    Code:
    exceptions: {
            TRANSPORT: 'xhr',
            PARSE: 'parse',
            LOGIN: 'login',
            SERVER: 'exception'
    }
    What does this mean? What can I do with it?

    2) With something like
    Code:
    Ext.Direct.on('info', function(e) {
    	Ext.Msg.alert('Info: ' + e.data);
    });
    I can react onto server side events. But how can I produce a server side event. The special case of an exception is no problem: throw new exception ...
    But what is to do with other events?

    3) Is it possible to initiate a server side event out of a php script called by cron?

    4) Is there already a useful login method? I think about following situation: A session may be timed out, but this should not end in loosing data, which was not saved. So if an Ext.Direct call is make for doing something on the server and the session is timed out, on client side should appear a login window. If the user logged in successfully, the last call to the server should be repeated. So it is a transparent login system: the application itself is not disturbed when the user is able to continue the session with correct password (changing the username should not be possible). If nothing exists till now, has anyone an idea, how to solve this?

    Greetings,

    Wolfgang

  2. #2
    Ext User
    Join Date
    Mar 2010
    Posts
    14
    Vote Rating
    0
    kodomo is on a distinguished road

      0  

    Default


    1) no idea

    2) You can catch anything you want with this. particulary :

    Code:
    Ext.Direct.on('timeout', onShowLoginFormToDoNotLoseCurrentChanges); 
    Ext.Direct.on('msg', displayMsgThatComesInDataField); 
    Ext.Direct.on('trace', ifYouAreADeveloperShowThisInAAlertMsgOrWhathever);
    so this specialized functions handle every special type of "event". Now the server direct request handler normaly must be able to answer several "transactions" in one request (couple of stores refreshing, on update). In my case these "msg" or "timeouts", are "created" and added as a response to the request, whenever it's necessary because it's in their nature to "not be expected".

    So, to me, they are some kind of "core" msg system between the server side app and the client side app.

    example msg:
    Code:
    {type : 'event',
     name : 'msg',
     data  : 'Some Important Data'}
    
    {type : 'event',
     name: 'trace',
     where : 'Where this XXXX happen',
     trace  : 'Some important debug data like a dump'}
    
    {type : 'event',
     name: 'bunnyjump',
     anything : 'dummy',
     goesHere  : 'you can create you custom data depending what you need'}
    3) From what I see you can't. The client must request something to communicate with him, http is not a persistent connection. but you can create a PollingProvider to keep in touch, anything new can be add there.

    4) there you go. In number 2) I kind of answered that. But it's up to you basically.

    Cheers
    Israel.
    Last edited by kodomo; 29 Sep 2010 at 12:06 PM. Reason: name

  3. #3
    Sencha User steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,664
    Vote Rating
    7
    steffenk has a spectacular aura about steffenk has a spectacular aura about steffenk has a spectacular aura about

      0  

    Default


    We use exceptions to debug from php.

    Code:
    Ext.Direct.on("exception", function(event) {
        var backtrace = "";
        if (event.where) {
            backtrace = "<p style=\"margin-top: 20px;\">" +
                "<strong>Backtrace:<\/strong><br \/>" +
                event.where.replace(/#/g, "<br \/>#") +
                "<\/p>";
        }
    
        extDirectDebug(
            "<p>" + event.message + "<\/p>" + backtrace,
            event.method,
            "ExtDirect - Exception"
        );
    });
    
    Ext.Direct.on("event", function(event, provider) {
        if (typeof event.debug !== "undefined" && event.debug !== "") {
            extDirectDebug(event.debug, event.method, "ExtDirect - Debug");
        }
    });
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  4. #4
    Sencha User
    Join Date
    Apr 2008
    Location
    Germany
    Posts
    24
    Vote Rating
    0
    Yasheena is on a distinguished road

      0  

    Default


    Have you code for 'extDirectDebug'?

  5. #5
    Sencha User steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,664
    Vote Rating
    7
    steffenk has a spectacular aura about steffenk has a spectacular aura about steffenk has a spectacular aura about

      0  

    Default


    sure, though it's only the output, depends on the environment.

    Code:
    var extDirectDebug = function(message, header, group) {
    	var TYPO3ViewportInstance = null;
    
    	if (top && top.TYPO3 && typeof top.TYPO3.Backend === "object") {
    		TYPO3ViewportInstance = top.TYPO3.Backend;
    	} else if (typeof TYPO3 === "object" && typeof TYPO3.Backend === "object") {
    		TYPO3ViewportInstance = TYPO3.Backend;
    	}
    
    	if (TYPO3ViewportInstance !== null) {
    		TYPO3ViewportInstance.DebugConsole.addTab(message, header, group);
    	} else if (typeof console === "object") {
    		console.log(message);
    	} else {
    		document.write(message);
    	}
    };
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

Similar Threads

  1. Ext.Direct.exceptions.LOGIN : 'login'
    By bareflix in forum Ext.Direct
    Replies: 0
    Last Post: 18 Aug 2010, 1:23 PM
  2. Simple Ext.Direct-Combobox plugin --- with Ext.Direct.Store for reuse
    By xp743 in forum Ext 3.x: User Extensions and Plugins
    Replies: 1
    Last Post: 26 Jul 2010, 11:56 AM
  3. [OPEN-964] Ext.Direct and exceptions
    By stever in forum Ext 3.x: Bugs
    Replies: 0
    Last Post: 13 May 2010, 7:34 PM
  4. events: connection exceptions, chaining events & canceling
    By end-user in forum Ext 2.x: Help & Discussion
    Replies: 11
    Last Post: 10 Jul 2008, 10:31 AM
  5. Ext.Toolbar causing DOM Exceptions in Firefox
    By chris in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 19 Apr 2007, 1:53 AM

Thread Participants: 2