[CLOSED] Direct Event/Method Call Priority

  1. #1

    [CLOSED] Direct Event/Method Call Priority

    Hello,

    What is the call priority for direct event and direct method listener in case they are both configured for the same event of a component? Is there a sequence followed and former one can prevent execution of the other or they are called asynchronously?

    Tkanks.
    Last edited by Daniil; Feb 08, 2013 at 2:40 PM. Reason: [CLOSED]
  2. #2
    in case they are both configured for the same event of a component?
    Don't do this.
    Geoffrey McGill
    Founder
  3. #3
    Quote Originally Posted by bayoglu View Post
    Hello,

    What is the call priority for direct event and direct method listener in case they are both configured for the same event of a component? Is there a sequence followed and former one can prevent execution of the other or they are called asynchronously?

    Tkanks.
    Hello!

    I agree with Geoffrey you shouldn't do this. Main reason it doesn't have sense because both of these mechanisms were created to communicate with a server. However, in most situations DirectMethod is called first but you can change it using Delays.

    If can you provide example where you need this we can help you to find other ways to solve your problem.
  4. #4
    Quote Originally Posted by Baidaly View Post
    Hello!

    I agree with Geoffrey you shouldn't do this. Main reason it doesn't have sense because both of these mechanisms were created to communicate with a server. However, in most situations DirectMethod is called first but you can change it using Delays.

    If can you provide example where you need this we can help you to find other ways to solve your problem.
    I agree that it sounds weird to configure both direct event and direct method for the same event. The solution is related to my previous post here: http://forums.ext.net/showthread.php...to-parent-page

    Briefly, a grid column command loads another aspx page in an iframe window. I needed to render this new window into current page or the parent page depending on a parameter. If the calling page is already a window child of a parent page, then the new aspx page is to be rendered in parent page. if the calling page is not rendered in a window, then it is safe to render the new aspx page in the calling page. Daniil adviced to call direct method of the parent page to render the new aspx page in parent page instead of calling page. To sum up, I configured both a direct event and a direct method for the command column, and I set a URL parameter. If parameter value is "1", then direct event before event handler returns false and prevents direct event call, and parent pages direct method is called by command handler listener. If parameter value is "0", direct event before handler returns true and direct event is called. In this case, command handler listener does not call parent page's direct method.

    See below simplified codes for direct event before event handler and command listener handler calling parent page direct method.

    //to check whether to call direct method or not
    function commandHandler(command) {
        if (command == "myCommand") {
            var renderChildToText = App.hiddenParameter.getValue();
            var renderChildTo = parseInt(renderChildToText);
            if (!isNaN(renderChildTo)) {
                if (renderChildTo == 1) { //call direct method of parent page
                    if (parent.App.direct != null) {
                        if (parent.App.direct.myDirectMethod != null) {
                            parent.App.direct.myDirectMethod();
                        }
                    }
                }
            }
        }
    }
    
    //to prevent direct event call if hiddden parameter value equals 1
    function directEventBeforeHandler() {
        var renderChildToText = App.hiddenParameter.getValue();
        var renderChildTo = parseInt(renderChildToText);
        if (!isNaN(renderChildTo)) {
            if (renderChildTo == 1) {
                return false;
            }
            else { //render to current form
                return true;
            }
        }
    }
    Do you think there is a safer way to do this? Thank you.
  5. #5
    Why do you use DirectEvent in second page?

    Can you instead of this use only JavaScript?

    Something like this:

    Modified Page 1 from your previous post http://forums.ext.net/showthread.php...to-parent-page :

    <%@ Page Language="C#" %>
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
     
    <!DOCTYPE html>
     
    <html>
    <head id="Head1" runat="server">
        <script>
            var openWindow = function(ctx) {
                ctx.create('Ext.window.Window', {
                    id: 'page2', 
                    height: 300, 
                    hidden: false, 
                    loader: {
                        renderer: 'frame', 
                        url: 'http://ext.net'
                    }, 
                    renderTo: ctx.net.ResourceMgr.getRenderTarget(), 
                    width: 300, 
                    title: 'Page #2', 
                    modal: true
                });
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
           <ext:ResourceManager ID="ResourceManager2" runat="server"/>
           <ext:Button ID="Button1" runat="server" Text="Show Window #2">
                <Listeners>
                    <Click Handler="openWindow(window.parent != null ? window.parent.Ext : Ext); "></Click>
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>
    Last edited by Baidaly; Feb 08, 2013 at 6:14 PM.
  6. #6
    Hello Baidaly, you rock!
    window.parent != null ? window.parent.Ext : Ext did all the trick. Now I have only a command listener to render window to parent or current page. Thank you. Case closed.

Similar Threads

  1. [CLOSED] Output Cache issue with Direct Method / Direct Event
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 18
    Last Post: Mar 01, 2013, 5:03 AM
  2. [CLOSED] how to call direct method
    By tactime10 in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 04, 2012, 8:38 AM
  3. [CLOSED] Can I use Response object in a direct method call?
    By feanor91 in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 12, 2012, 11:50 AM
  4. how to call direct method in asp.net mvc3
    By waqasde in forum 2.x Help
    Replies: 1
    Last Post: Mar 16, 2012, 9:26 AM
  5. Direct method and direct event over SSL?
    By dimitar in forum 1.x Help
    Replies: 0
    Last Post: Oct 08, 2011, 8:09 PM

Posting Permissions