PDA

View Full Version : [CLOSED] Loader with Html renderer and Window rendering



paulc
May 17, 2012, 6:33 PM
Hi,

I'm trying to use the Html mode of the loader within a panel. This works fine on first load, but subsequent loads corrupt any windows that have been rendered previously. From digging around with this it appears that any windows are rendered to the end of the document body rather than the place holder for the loaded content. So ,for a panel it's fine because it renders to the place holder and then on reload that DOM element is replaced with the new panel. But any windows have been rendered to the document body and so on reload they still exist as they haven't been replaced causing issues that are similar to ID conflicts.

Please see test case below:

Parent View:


<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>


<!DOCTYPE html>
<html>
<head runat="server">
<title>ViewParent</title>
<ext:ResourceManager runat="server" ID="ParentResourceManager">
</ext:ResourceManager>
</head>
<body>
<ext:Viewport runat="server" Layout="FitLayout">
<Items>
<ext:Panel ID="PanelShellLoaderHtml" runat="server" Layout="FitLayout">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button runat="server" Text="Refresh" OnClientClick="#{PanelShellLoaderHtml}.loader.load();"></ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Loader ID="Loader1" runat="server" Url='<%# Url.Action("ViewChild") %>' AutoDataBind="True" Mode="Html" Scripts="True">
<LoadMask ShowMask="True" />
</Loader>
</ext:Panel>
</Items>
</ext:Viewport>
</body>
</html>




Child View


<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>


<!DOCTYPE html>
<html>
<head runat="server">
<title>ViewParent</title>
<ext:ResourceManager runat="server" ID="ParentResourceManager" RenderScripts="None"
RenderStyles="None">
</ext:ResourceManager>
</head>
<body>
<ext:Window ID="Window1" runat="server" Title="This is the window" Width="400" Height="500">
</ext:Window>
<ext:Panel runat="server" Title="Main Panel" Layout="FitLayout">
</ext:Panel>
</body>
</html>




If you run this you'll see the window appear fine on the first load, but clicking refresh in the toolbar will cause the window to corrupt. Removing the window ID cause it to use a generated ID will work as there is no conflict. But I think this is still a bug as the document is never cleaned up and will leak these components, plus INamingContainer style names are not acceptable as I have a lot of custom client script which expects the Id's to be static.

Hope you can help.

Daniil
May 17, 2012, 7:52 PM
Hi,

Well, Loader knows nothing about the content which it loads, so, it can't remove it automatically before "refresh".

I would suggest you to use partial views.

paulc
May 17, 2012, 8:36 PM
Hi Daniil, sorry to disagree but the Html renderer uses replace to remove and then replace the content loaded via XHR. That's why the panel isn't a problem, it's just the Window components that get rendered to the end of the body are in the wrong place to be replaced.

paulc
May 17, 2012, 11:49 PM
OK, some more thought... If I set the renderTo explicitly to the element generated to hold the content then it works. Question now is - is there a way to determine this name or a property that can be set to dictate this behaviour?

Any help much appreciated!




<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>


<!DOCTYPE html>
<html>
<head runat="server">
<title>ViewParent</title>
<ext:ResourceManager runat="server" ID="ParentResourceManager">
</ext:ResourceManager>
</head>
<body>
<ext:Viewport runat="server" Layout="FitLayout">
<Items>
<ext:Panel ID="PanelShellLoaderHtml" runat="server" Layout="FitLayout">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button runat="server" Text="Refresh" OnClientClick="#{PanelShellLoaderHtml}.loader.load();">
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Loader ID="Loader1" runat="server" Url='<%# Url.Action("ViewChild") %>' AutoDataBind="True"
Mode="Html" Scripts="True">
<LoadMask ShowMask="True" />
</Loader>
</ext:Panel>
</Items>
</ext:Viewport>
</body>
</html>






<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>


<!DOCTYPE html>
<html>
<head runat="server">
<title>ViewParent</title>
<ext:ResourceManager runat="server" ID="ParentResourceManager" RenderScripts="None"
RenderStyles="None">
</ext:ResourceManager>
</head>
<body>


<ext:Window ID="win1" runat="server" Title="This is the window" Width="400" Height="500"
RenderTo="PanelShellLoaderHtml-body">
</ext:Window>
<ext:Panel runat="server" Title="Main Panel" Layout="FitLayout">
<Content>
</Content>
</ext:Panel>
</body>
</html>

paulc
May 18, 2012, 7:26 AM
Hi, I've just tried using a partial view as suggested but this has the same result. Any content in the partial view is replaced as expected when reloaded with the exception of any Window components which persist after reload.

Daniil
May 18, 2012, 8:34 AM
Hi Daniil, sorry to disagree but the Html renderer uses replace to remove and then replace the content loaded via XHR. That's why the panel isn't a problem, it's just the Window components that get rendered to the end of the body are in the wrong place to be replaced.

Mode="Html" doesn't destroy components. It just:

1. Executes the scripts from a response if Scripts="true".
2. Replace container body HTML with a new one from a response.

The second doesn't mean the rendered components will be destroyed. It replaces just HTML.

For example, imagine there is "Panel1" in the child page which is loaded initially. Then you load some other page:

#{PanelShellLoaderHtml}.load({ url : 'Test2.aspx'});
with no Panel1.

The new page will replace the old container content, but you will be still able to access the Panel1 component which was rendered initially.

One more disadvantage of Mode="Html" - components from a child page won't participate in layout logic of a parent container. They will considered just as raw HTML.


I've just tried using a partial view as suggested but this has the same result.

I would suggest to place the Window into Bin of the Panel. Here is more details about the Bin feature.
http://forums.ext.net/showthread.php?13726&p=57259&viewfull=1#post57259

Here is the example how I would implement your requirement.

Example Main View

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.Net.MVC v2 Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Viewport runat="server" Layout="FitLayout">
<Items>
<ext:Panel ID="Panel1" runat="server" Layout="FitLayout">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button runat="server" Text="Refresh">
<Listeners>
<Click Handler="#{Panel1}.reload();" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Loader
runat="server"
Url="/Test/PartialView1"
Mode="Html"
Scripts="True">
<LoadMask ShowMask="True" />
<Params>
<ext:Parameter Name="containerId" Value="this.target.nsId" Mode="Raw" />
</Params>
</Loader>
</ext:Panel>
</Items>
</ext:Viewport>
</body>
</html>

Example Partial View

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<ext:Panel
ID="PanelPartialView"
IDMode="Static"
runat="server"
Html="I participate in layout. I am stretched according to FitLayout."
BodyStyle="background-color: yellow;">
<Bin>
<ext:Window
ID="WindowPartialView"
runat="server"
Html='<%# DateTime.Now.Second %>'
AutoDataBind="true" />
</Bin>
<Listeners>
<AfterRender Handler="this.bin[0].show();" />
</Listeners>
</ext:Panel>


Example Controller Action

public ActionResult PartialView1(string containerId)
{
Ext.Net.MVC.PartialViewResult r = new Ext.Net.MVC.PartialViewResult();
r.ContainerId = containerId;
r.RenderMode = RenderMode.AddTo;
r.SingleControl = true;

return r;
}

paulc
May 18, 2012, 9:16 AM
Hi Daniil, thank you for your suggestions, I will investigate these now. One thing to mention though is that I updated from SVN this morning and Vladimir made some changes this morning which appear to have fixed the rendering issue.

However, I am now considering whether this approach is usable at all because of the memory leak you refer to with regards to references to the components remaining. I will do some memory profiling and see what the result is, but I'm now at a point where I may have to rethink the whole approach. Another "murky" area I have is that I need to load content in Frame mode if it is legacy code or in Html mode if it is Ext.net by switching the renderer.
e.g. usage:


...
listeners: {
afteranimate: function () {
window.App.PanelShellLoader.loader.load({ url: menuItem.Url, renderer: menuItem.Mode.toLowerCase() });
}
}
...


I had a few problems getting this to work and came up with the following override. Could you cast your eye over it in case I've missed something?

TIA



Ext.override(Ext.net.ComponentLoader,
{
load: function (options) {
if (Ext.isString(options)) {
options = { url: options };
}
else {
options = Ext.apply({}, options);
}


if (this.paramsFn) {
this.params = this.paramsFn();
}


if (options.paramsFn) {
options.params = Ext.apply(options.params || {}, options.paramsFn());
}


if (!Ext.isDefined(options.passParentSize) && this.passParentSize) {
options.params = options.params || {};
options.params.width = this.target.body.getWidth(true);
options.params.height = this.target.body.getHeight(true);
}


if (!Ext.isEmpty(this.target.iframe) && options.renderer != "frame") {
this.target.removeAll(true);
this.target.iframe = null;
}


if (options.renderer == "frame") {
this.loadFrame(options);
return;
}


if (this.directMethod) {
var me = this,
mask = Ext.isDefined(options.loadMask) ? options.loadMask : me.loadMask,
params = Ext.apply({}, options.params),
callback = options.callback || me.callback,
scope = options.scope || me.scope || me,
method,
dmCfg;


Ext.applyIf(params, me.params);
Ext.apply(params, me.baseParams);


Ext.apply(options, {
scope: me,
params: params,
callback: me.onComplete
});


if (me.fireEvent('beforeload', me, options) === false) {
return;
}


if (mask) {
me.addMask(mask);
}


method = Ext.decode(this.directMethod);


dmCfg = {
complete: function (success, result, response) {
me.onComplete(options, success, { responseText: result });
}
}


if (method.length > 1) {
method(Ext.encode(options.params), dmCfg);
}
else {
method(dmCfg);
}


me.active = {
options: options,
mask: mask,
scope: scope,
callback: callback,
success: options.success || me.success,
failure: options.failure || me.failure,
renderer: options.renderer || me.renderer,
scripts: Ext.isDefined(options.scripts) ? options.scripts : me.scripts
};


me.setOptions(me.active, options);


return;
}


Ext.net.ComponentLoader.superclass.load.apply(this , arguments);
}
});

Daniil
May 18, 2012, 10:12 AM
Hi Daniil, thank you for your suggestions, I will investigate these now. One thing to mention though is that I updated from SVN this morning and Vladimir made some changes this morning which appear to have fixed the rendering issue.


Yes, he has added the feature of "auto-destroying" components. A component checks before creating any other component with the same id exists. If exists, then the component removes this "previous" component. And yes, it should fix your initial issue.

But it's a bit experimental feature in the context of Beta release. We might give it up for the final release if there will be any problems (we are just not sure at the moment what backstage effects may be caused by this feature).

Explicit destroying would be the best choice.

In addition, the following example is marked with "an experimental example".
http://examples2.ext.net/Default.aspx#/Panel/Basic/Loader_Html_Mode/

So, we would still don't recommend to use it in a real application. At least, in the case when you need Ext.NET control in a child page.


Another "murky" area I have is that I need to load content in Frame mode if it is legacy code or in Html mode if it is Ext.net by switching the renderer.
e.g. usage:


...
listeners: {
afteranimate: function () {
window.App.PanelShellLoader.loader.load({ url: menuItem.Url, renderer: menuItem.Mode.toLowerCase() });
}
}
...


I had a few problems getting this to work and came up with the following override. Could you cast your eye over it in case I've missed something?


Could you please start a new forum thread? Please provide more details about the initial problem with switching renderers.

paulc
May 18, 2012, 10:27 AM
Auto-destroy sounds like a very neat idea, I hope it works out. I did do some profiling and your 100% correct there is a memory leak when I reload the content. I also checked a standard partialview invoked via a directmethod and to my surprise that also leaks, I kind of thought that was a pretty safe thing to do? Is this also a known limitation of partialview rendering?

4260

My Window markup in the partial view is:



<ext:Window runat="server" ID="windowPreview" Title="Asset Details" Width="750" Height="650"
Maximizable="true" Layout="BorderLayout" CloseAction="Destroy" Closable="True"
Modal="True">
...
</ext:Window>

Daniil
May 18, 2012, 10:33 AM
I also checked a standard partialview invoked via a directmethod and to my surprise that also leaks, I kind of thought that was a pretty safe thing to do? Is this also a known limitation of partialview rendering?

To get the controls from a partial view destroyed, there must be the same id of a new rendered control (after refreshing).

I've achieved that in my example by setting

IDMode="Static"
for the top level Panel.

paulc
May 18, 2012, 10:38 AM
Yes, I have static id's. And CloseAction="Destroy". I think something else is holding a reference (event handler maybe?) that is preventing it from being disposed.

Daniil
May 18, 2012, 10:49 AM
Please post responses of initially partial view request and after refresh. I will review.

paulc
May 18, 2012, 11:30 AM
Hmmm I'd's are different..



{script:"Ext.net.ResourceMgr.destroyCmp(\"App.idd5e55980b0f31609_UC_windowPreview\");Ext.create(\"Ext.window.Window\"

...
}



{script:"Ext.net.ResourceMgr.destroyCmp(\"App.idc030a3b9db63a8e1_UC_windowPreview\");Ext.create(\"Ext.window.Window\",....



But I have



<extnet idMode="Static" ...


in my web.config

paulc
May 18, 2012, 12:26 PM
With IDMode="Static" set explicitly on the control the responses are:


{script:"Ext.net.ResourceMgr.destroyCmp(\"App.windowPreview\");Ext.create(\"Ext.window.Window\",{id:\"windowPreview\",height:650...


script:"Ext.net.ResourceMgr.destroyCmp(\"App.windowPreview\");Ext.create(\"Ext.window.Window\",{id:\"windowPreview\",height:650...

Heap Profile (GC done before snapshot taken) ...

Baseline - 12.21MB
View 1 - 13.34MB
Close - 13.22MB
View 2 - 13.87MB
Close - 13.72MB
View 3 - 14.35MB
Close - 14.21MB

Daniil
May 18, 2012, 12:27 PM
Currently, PartialViewResult doesn't read idMode from Web.config. We will review this behavior soon.

There is the IDMode property of PartialViewResult you could set up to Static. But it appears to be not working at the moment. Probably, a bug.

So, the single way at the moment is setting up

IDMode="Static"
for the Panel in the partial view.

Daniil
May 18, 2012, 1:36 PM
With IDMode="Static" set explicitly on the control the responses are:


{script:"Ext.net.ResourceMgr.destroyCmp(\"App.windowPreview\");Ext.create(\"Ext.window.Window\",{id:\"windowPreview\",height:650...


script:"Ext.net.ResourceMgr.destroyCmp(\"App.windowPreview\");Ext.create(\"Ext.window.Window\",{id:\"windowPreview\",height:650...

Heap Profile (GC done before snapshot taken) ...

Baseline - 12.21MB
View 1 - 13.34MB
Close - 13.22MB
View 2 - 13.87MB
Close - 13.72MB
View 3 - 14.35MB
Close - 14.21MB

Could you please provide exactly the code you are testing with?

paulc
May 18, 2012, 1:38 PM
Hi, Danill. I can't post the code to the public forum but I could e-mail instead if that's possible.

Daniil
May 18, 2012, 1:49 PM
We would prefer to avoid looking on the private code even via our e-mails.

I had assumed you are working with a simple example like this one I have posted before:
http://forums.ext.net/showthread.php?19047&p=82150&viewfull=1#post82150

Can you reproduce memory leaking with a simple example?

We would really appreciate if you could post a simplified example to reproduce the problem.

The following

Ext.net.ResourceMgr.destroyCmp(\"App.windowPreview\");
destroys a Window for sure. But I know nothing about its content which might be not destroyed automatically.


Heap Profile (GC done before snapshot taken) ...

Please clarify does the tool force GC before snapshot? Or do you somehow force it manually? What the tool do you use?

Can we 100% sure GC is 100% done before snapshot?

paulc
May 18, 2012, 1:52 PM
Hi, I'll put together an example but it may not be till Monday now. I'm using the Chrome developer tools and the heap snapshot profiler. I'm pretty sure this invokes a GC before taking the snapshot.

Vladimir
May 18, 2012, 2:03 PM
Heap Profile (GC done before snapshot taken) ...

Baseline - 12.21MB
View 1 - 13.34MB
Close - 13.22MB
View 2 - 13.87MB
Close - 13.72MB
View 3 - 14.35MB
Close - 14.21MB

Is it memory of your web application? I am not sure that it is related with Ext.Net, we don't use any unmanage resources therefore we almost cannot affect on memory leaking (atleast, as I know .NET memory managment). But I can wrong

Daniil
May 18, 2012, 2:33 PM
I have tried to make Chrome shapshots for this simple page.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void RenderWindow(object sender, DirectEventArgs e)
{
Window win = new Window();
win.Html = "Close me";
win.CloseAction = CloseAction.Destroy;
this.Form.Controls.Add(win);
win.Render();
}
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:Button runat="server" Text="Render Window" OnDirectClick="RenderWindow" />
</form>
</body>
</html>


I had the following results:

1. Initially just after page load.
6.62MB

2. Render the Window
7.03MB

3. Close the Window.
7.01MB

4. Render the Window.
7.11MB

5. Close the Window.
7.15MB

6. Render the Window
7.19MB

7. Close the Window.
7.15MB


Generally, the same as you had with your application.

I'm not sure how to handle these results, but there should not be any memory leaking in this simple example.

Daniil
May 28, 2012, 5:51 PM
I think the thread appears to be related to this one.
http://forums.ext.net/showthread.php?18515

Also you can be interested to look at this thread.
http://forums.ext.net/showthread.php?19142

marco.morreale
Jun 19, 2013, 12:37 PM
Hello,

when my windows opens, an undesired query string parameters appears in the url:

&_dc=1371645351581&

this causes an error to destination page.
How can I prevent this behaviour?
Thanks in advance
Marco

.cs page


Window win = new Window
{
ID = "Window1",
Title = "Contratto",
Width = Unit.Pixel(1000),
Height = Unit.Pixel(600),
Collapsible = true,
Maximizable = true,
Modal = true,
CloseAction = CloseAction.Destroy,
// Html = "A new Window was created at: " + DateTime.Now.ToLongTimeString(),
Loader = new ComponentLoader
{
Url = "http://pom-sql01/ReportServer/Pages/ReportViewer.aspx?%2fAGS_MSCRM%2fTicket+AGS+in+WOR D&rs%3aCommand=Render&rs:Format=PDF&CRM_IncidentId={0}" + Idticket;
Mode = LoadMode.Frame,
LoadMask =
{
ShowMask = true,
Msg = "Caricamento in corso..."
}
}
};

win.Render(this.Form);

Daniil
Jun 19, 2013, 2:49 PM
Hi Marco,

Please provide a full test case.

marco.morreale
Jun 20, 2013, 12:27 PM
Hi Daniil,
you can see it in "Load External Website" example at

http://examples2.ext.net/Examples/Window/Basic/Load_External_Website/

If you insepect the http traffic, yo can see that external page is called with the following url:

http://www.ext.net/?_dc=1371730805190&

This causes a problem with my destination page.
Marco

Daniil
Jun 24, 2013, 7:29 AM
It is a cache buster parameter. To disable it, please set DisableCaching="false" for a Loader instance.

Currently, there will be "/?" at the end. If it still breaks because of this "/?", please update from SVN or add this fix to the page's <head>.

Fix to remove "/?"

Ext.net.ComponentLoader.override({
loadFrame: function (options) {
options = Ext.apply({}, options);

var me = this,
target = me.target,
mask = Ext.isDefined(options.loadMask) ? options.loadMask : me.loadMask,
monitorComplete = Ext.isDefined(options.monitorComplete) ? options.monitorComplete : me.monitorComplete,
disableCaching = Ext.isDefined(options.disableCaching) ? options.disableCaching : me.disableCaching,
disableCachingParam = options.disableCachingParam || "_dc",
params = Ext.apply({}, options.params),
callback = options.callback || me.callback,
scope = options.scope || me.scope || me;

Ext.applyIf(params, me.params);
Ext.apply(params, me.baseParams);

Ext.applyIf(options, {
url: me.url
});

Ext.apply(options, {
mask: mask,
monitorComplete: monitorComplete,
disableCaching: disableCaching,
params: params,
callback: callback,
scope: scope
});

this.lastOptions = options;

if (!options.url) {
throw 'No URL specified';
}

if (me.fireEvent('beforeload', me, options) === false) {
return;
}

var url = options.url;

if (disableCaching !== false) {
url = url + ((url.indexOf("?") > -1) ? "&" : "?") + disableCachingParam + "=" + new Date().getTime();
}

if (!Ext.Object.isEmpty(params)) {
var p = {};
for (var key in params) {
var ov = params[key];

if (typeof ov == "function") {
p[key] = ov.call(target);
} else {
p[key] = ov;
}
}

p = Ext.urlEncode(p);
url = url + ((url.indexOf("?") > -1) ? "&" : "?") + p;
}

if (mask) {
me.addMask(mask);
}

if (Ext.isEmpty(target.iframe)) {
var iframeObj = {
tag: "iframe",
id: target.id + "_IFrame",
name: target.id + "_IFrame",
src: url,
frameborder: 0
},
layout = target.getLayout();

if (!target.layout || target.layout.type !== "fit") {
target.setLayout(Ext.layout.Layout.create("fit"));
}

target.removeAll(true);

var p = target,
iframeCt = {
xtype : "component",
autoEl: iframeObj,
listeners: {
afterrender: function () {
var owner = this.ownerCt;
owner.iframe = this.el;

if (monitorComplete) {
owner.getLoader().startIframeMonitoring();
} else {
this.el.on("load", owner.getLoader().afterIFrameLoad, owner.getLoader());
}

owner.getLoader().beforeIFrameLoad(options);
}
}
};

target.add(iframeCt);
} else {
target.iframe.dom.src = Ext.String.format("java{0}", "script:false");

try {
window.frames[target.iframe.dom.name].location.replace(url);
} catch (e) {
target.iframe.dom.src = url; // IE9 refresh iframe with pdf issue: http://forums.ext.net/showthread.php?24690
}

this.beforeIFrameLoad(options);
}

if (!this.destroyIframeOnUnload) {
this.destroyIframeOnUnload = true;
}
}
});

marco.morreale
Jun 24, 2013, 9:50 AM
It seems that a "&" is added instead of "/?". This is still a problem form me.

I tried to putyour function on the page page this doesn't solve.

Now, I am trying to update from svn.

M

Daniil
Jun 24, 2013, 10:09 AM
It seems that a "&" is added instead of "/?".


I cannot reproduce it with the test case. If you still can reproduce it after updating from SVN trunk, please provide a test case.

marco.morreale
Jun 24, 2013, 10:11 AM
Ok Daiil,
I try.

The error I am getting is:

Uncaught TypeError: Object #<Object> has no method 'isEmpty'

Daniil
Jun 24, 2013, 10:48 AM
Did you update from this location?
http://svn.ext.net/premium/trunk

marco.morreale
Jun 25, 2013, 6:55 AM
Before updating I tried to add the override but window content doesn't load:



<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Window win = new Window()
{
ID = "Window1",
Title = "Ext.NET",
Width = Unit.Pixel(1000),
Height = Unit.Pixel(600),
Modal = true,
AutoRender = false,
Collapsible = true,
Maximizable = true,
Hidden = true,
Loader = new ComponentLoader
{
DisableCaching = false,
Url = "http://www.ext.net",
// Url = "http://10.0.0.61/ReportServer?%2fRegolamento+Unico+CRM+-+WEB&rs:Command=Render&rs:Format=PDF&GruppoTicket=2515",
Mode = LoadMode.Frame,
LoadMask =
{
ShowMask = true
}
}
};

this.Form.Controls.Add(win);
}
</script>

<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
<title>Load External Website into Window - Ext.NET Examples</title>
<link href="/resources/css/examples.css" rel="stylesheet" />


<script type="text/javascript" >

Ext.net.ComponentLoader.override({
loadFrame: function (options) {
options = Ext.apply({}, options);

var me = this,
target = me.target,
mask = Ext.isDefined(options.loadMask) ? options.loadMask : me.loadMask,
monitorComplete = Ext.isDefined(options.monitorComplete) ? options.monitorComplete : me.monitorComplete,
disableCaching = Ext.isDefined(options.disableCaching) ? options.disableCaching : me.disableCaching,
disableCachingParam = options.disableCachingParam || "_dc",
params = Ext.apply({}, options.params),
callback = options.callback || me.callback,
scope = options.scope || me.scope || me;

Ext.applyIf(params, me.params);
Ext.apply(params, me.baseParams);

Ext.applyIf(options, {
url: me.url
});

Ext.apply(options, {
mask: mask,
monitorComplete: monitorComplete,
disableCaching: disableCaching,
params: params,
callback: callback,
scope: scope
});

this.lastOptions = options;

if (!options.url) {
throw 'No URL specified';
}

if (me.fireEvent('beforeload', me, options) === false) {
return;
}

var url = options.url;

if (disableCaching !== false) {
url = url + ((url.indexOf("?") > -1) ? "&" : "?") + disableCachingParam + "=" + new Date().getTime();
}

if (!Ext.Object.isEmpty(params)) {
var p = {};
for (var key in params) {
var ov = params[key];

if (typeof ov == "function") {
p[key] = ov.call(target);
} else {
p[key] = ov;
}
}

p = Ext.urlEncode(p);
url = url + ((url.indexOf("?") > -1) ? "&" : "?") + p;
}

if (mask) {
me.addMask(mask);
}

if (Ext.isEmpty(target.iframe)) {
var iframeObj = {
tag: "iframe",
id: target.id + "_IFrame",
name: target.id + "_IFrame",
src: url,
frameborder: 0
},
layout = target.getLayout();

if (!target.layout || target.layout.type !== "fit") {
target.setLayout(Ext.layout.Layout.create("fit"));
}

target.removeAll(true);

var p = target,
iframeCt = {
xtype: "component",
autoEl: iframeObj,
listeners: {
afterrender: function () {
var owner = this.ownerCt;
owner.iframe = this.el;

if (monitorComplete) {
owner.getLoader().startIframeMonitoring();
} else {
this.el.on("load", owner.getLoader().afterIFrameLoad, owner.getLoader());
}

owner.getLoader().beforeIFrameLoad(options);
}
}
};

target.add(iframeCt);
} else {
target.iframe.dom.src = Ext.String.format("java{0}", "script:false");

try {
window.frames[target.iframe.dom.name].location.replace(url);
} catch (e) {
target.iframe.dom.src = url; // IE9 refresh iframe with pdf issue: http://forums.ext.net/showthread.php?24690
}

this.beforeIFrameLoad(options);
}

if (!this.destroyIframeOnUnload) {
this.destroyIframeOnUnload = true;
}
}
});


</script>


</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />

<h1>Load External Website into an &lt;ext:Window></h1>

<p>Load an external url into a Window using the AutoLoad property.
All Properties for the &lt;ext:Window> are set during the Page_Load Event.</p>

<ext:Button ID="Button1" runat="server" Text="Show Window" Icon="Application">
<Listeners>
<Click Handler="#{Window1}.show(this);" />
</Listeners>
</ext:Button>
</form>
</body>
</html>

Daniil
Jun 25, 2013, 7:02 AM
Your test case works fine for me.

marco.morreale
Jun 25, 2013, 7:35 AM
I updated from SVN 2.1 and it works now .
I thought updating was alternative to overriding.
You can mark as closed.
Thank you very much.
M

Daniil
Jun 25, 2013, 7:43 AM
Yes, it was supposed to be so. Initially, I tested it with the v2.2 release. It worked.

Now I tested with the v2.1 release (which you, probably, used before the update) and were able to reproduce the error. To avoid that error, this:

if (!Ext.Object.isEmpty(params)) {
should be replaced with

if (!Ext.isEmptyObj(params)) {