[CLOSED] ResourceManager MessageBusListeners

  1. #1

    [CLOSED] ResourceManager MessageBusListeners

    I would like to know whether you could add MessageBusListeners to the ResourceManager. I have a scenario, which i would like to add a MessageBusListener to the document as a whole and in my opinion, this listener would be clearer if it was added to the ResourceManager instead of another element of the page, such a Panel.


    Thanks in advance
    Last edited by Daniil; Dec 05, 2014 at 2:08 PM. Reason: [CLOSED]
  2. #2
    Hi Raphael,

    Yes, unfortunately, ResourceManager doesn't have MessageBusListeners.

    For listening to global events, we can recommend this C# code:
    MessageBus.Default.Subscribe("**", new JFunction("alert('I catch any event!');"));
    You could call it in a Page_Load, for example.

    Here is a JavaScript counter part:
    Ext.net.Bus.subscribe("**",function(){ alert('I catch any event!'); });
    You could run it in a ResourceManager's DocumentReady or in your own Ext.onReady() call.
  3. #3
    Thank you Daniil.

    Please mark this thread as closed.

    I would like to provide a simple sample:

    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
        <script type="text/javascript">
            var RaiseEvents = function () {
                Ext.net.Bus.publish("Event1", "Ext.Net");
    
                Ext.net.Bus.publish("Event2", "Sencha");
            }
    
            var DocumentReady = function () {
    
                //Subscribe to Event1
                Ext.net.Bus.subscribe("Event1", function (name, param) {
                    alert(Ext.String.format("Event1 (Specific). Data received: {0}", param));
                });
    
                //Subscribe to all events
                Ext.net.Bus.subscribe("**", function (name, param) {
                    alert(Ext.String.format("{0}. Data received: {1}", name, param));
                });
            }
        </script>
    </head>
    <body>
        <ext:ResourceManager runat="server" ScriptMode="Debug">
            <Listeners>
                <DocumentReady Handler="DocumentReady();" />
            </Listeners>
        </ext:ResourceManager>
        <br />
        <ext:Button Text="Raise Events" runat="server">
            <Listeners>
                <Click Handler="RaiseEvents();" />
            </Listeners>
        </ext:Button>
        <br />
    </body>
    </html>
    Last edited by RCN; Dec 05, 2014 at 12:19 PM.

Similar Threads

  1. [CLOSED] ResourceManager WindowUnloadMsg
    By osef in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 06, 2014, 5:42 PM
  2. [CLOSED] Have instance of ResourceManager
    By immenso in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jan 21, 2014, 11:59 AM
  3. ResourceManager and ViewState
    By fkmbkk in forum 2.x Help
    Replies: 3
    Last Post: Jul 05, 2013, 2:58 PM
  4. [CLOSED] ResourceManager and Razor
    By joxa83 in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 31, 2012, 2:47 PM
  5. Problem with ResourceManager
    By jwcelyo in forum 1.x Help
    Replies: 2
    Last Post: Oct 27, 2010, 4:08 PM

Posting Permissions