[CLOSED] ComponentLoader load event for iframe has null response. AutoLoad in 1.x has a response

  1. #1

    [CLOSED] ComponentLoader load event for iframe has null response. AutoLoad in 1.x has a response

    Hi,

    Just finding a slight difference between 1.x and 2.x.

    Here is a 1.x sample that modifies the examples from the Ext.NET examples explorer to add an "update" listener:

    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            var win = new Window
            {
                ID = "Window1",
                Title = "Ext.NET",
                Width = Unit.Pixel(800),
                Height = Unit.Pixel(600),
                Modal = true,
                Collapsible = true,
                Maximizable = true,
                Hidden = true
            };
            
            win.AutoLoad.Url = "http://www.ext.net";
            win.AutoLoad.Mode = LoadMode.IFrame;
    
            win.Listeners.Update.Fn = "onWindowUpdate";
    
            win.Render(Form);
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Load External Website into Window - Ext.NET Examples</title>
        
        <script>
            function onWindowUpdate(win, response) {
                console.log(response.iframe);
            }
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:Button runat="server" Text="Show Window" Icon="Application">
                <Listeners>
                    <Click Handler="#{Window1}.show(this);" />
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>
    Notice, I am able to get "response.iframe" successfully.

    In the 2.x version of this code, I find the response is always null:

    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            var win = new Window()
            {
                ID = "Window1",
                Title = "Ext.NET",
                Width = Unit.Pixel(800),
                Height = Unit.Pixel(600),
                Modal = true,
                AutoRender = false,
                Collapsible = true,
                Hidden = true,
                Loader = new ComponentLoader
                {
                    Url = "http://www.ext.net",
                    Mode = LoadMode.Frame,
                    LoadMask =
                    {
                        ShowMask = true
                    },
                    Listeners =
                    {
                        Load = { Fn = "onLoad" }
                    }
                }
            };
    
            Form.Controls.Add(win);
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Load External Website into Window - Ext.NET Examples</title>
    
        <script>
            function onLoad(loader, response) {
                console.log(response, loader.getTarget().getComponent(0).getEl());
            }
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:Button runat="server" Text="Show Window" Icon="Application">
                <Listeners>
                    <Click Handler="#{Window1}.show(this);" />
                </Listeners>
            </ext:Button>
        </form>
    </body>
    </html>
    Looking at the Ext.NET code, in componentloader.js, I notice in the "afterIFrameLoad" method this:

    this.fireEvent("load", this, null, options);
    Would it be possible to pass the response (assuming a similar "iframe" property would exist on it as in 1.x)? From what I can see the response object has two properties when it is an iframe: "iframe" and "url".

    For the moment I can use "loader.getTarget().getComponent(0).getEl().do m" to get the iframe from within the load event handler, unless there is a more optimal way to do this that I have missed?

    Thanks!
    Last edited by Daniil; Jan 13, 2014 at 2:48 PM. Reason: [CLOSED]
  2. #2
    Hi Anup,

    Yes, there is a bit more optimal way:
    loader.getTarget().iframe
    We are reluctant to add that additional parameter to the Load event, because it makes sense for the Frame mode only and doesn't make sense for others like Component.

    Are you OK with that?
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi Anup,

    Yes, there is a bit more optimal way:
    loader.getTarget().iframe
    Thanks for that pointer. That is great. I will use that.

    Quote Originally Posted by Daniil View Post
    We are reluctant to add that additional parameter to the Load event, because it makes sense for the Frame mode only and doesn't make sense for others like Component.

    Are you OK with that?
    I wasn't requesting a new parameters, but that the existing one is being set to null. I refer to the response parameter described here:
    http://docs.sencha.com/extjs/4.2.2/#...der-event-load

    In this line of code:

    this.fireEvent("load", this, null, options);
    It is the "null" parameter that is the response parameter.

    componentloader.js is extended in Ext.NET 2 and the above code is from the "afterIFrameLoad" method.

    So I guess it may be possible to do something like this?

    var iframe = this.getTarget().iframe,
        response = iframe && iframe.dom ? { iframe: iframe.dom, url: iframe.dom.src } : null;
    
    this.fireEvent("load", this, response, options);
    (Not tested that code fully and may need more validation etc.)

    Hope that helps clarify?
  4. #4
    Yes, your requirement looks clear.

    Though, that is not a response technically...
    response = iframe && iframe.dom ? { iframe: iframe.dom, url: iframe.dom.src } : null;
    We could mislead another developer who expects a real iframe's response. What do you think?
  5. #5
    Quote Originally Posted by Daniil View Post
    Yes, your requirement looks clear.

    Though, that is not a response technically...
    response = iframe && iframe.dom ? { iframe: iframe.dom, url: iframe.dom.src } : null;
    We could mislead another developer who expects a real iframe's response. What do you think?
    That's true. I guess I was thinking more in line of API consistency with the 1.x code which does provide that info in the response parameter... (As I was migrating some code from 1.x to 2.x that threw me for a bit). Anyway, I leave it to you guys to decide, given there is an easy way to get at the iframe, anyway.

    Thanks!
  6. #6
    Yes, I do understand your point.

    Iframe loading was a part of the Panel class in v1.

    Now it is incorporated to the ComponentLoader class in v2 and we decided not to pass that "response" parameter to the Load event not to mislead developers, because it is not an actual response.

    given there is an easy way to get at the iframe, anyway.
    Well, that is the main point why we are reluctant to change it:)
  7. #7
    :)

    Cool. You can mark this as closed then.

Similar Threads

  1. Replies: 0
    Last Post: Aug 05, 2012, 10:46 AM
  2. Replies: 1
    Last Post: Dec 27, 2011, 1:47 PM
  3. Response.write is not working in ajax event.
    By Nagaraju in forum 1.x Help
    Replies: 1
    Last Post: Oct 17, 2011, 7:06 AM
  4. Replies: 5
    Last Post: Apr 22, 2010, 7:06 PM
  5. store load exception bad response
    By [WP]joju in forum 1.x Help
    Replies: 2
    Last Post: Jan 12, 2010, 5:45 AM

Posting Permissions