Thank you for all the details. The scenario looks more or less clear for me. Seems a similar scenario is being discussed here:
http://forums.ext.net/showthread.php?27007
Is it your colleague?
Originally Posted by
timiteh
In fact, it seems that the direct method is executed only after the method which launch the call has ended.
Well, yes, when you call
X.Js.Call("...");
it just generates JavaScript which executes when a browser gets a response. There is no other way to initiate a client-server response from server.
Originally Posted by
timiteh
So to know that all the data have been sent back to the Parent Page we use a Thread which will periodically check that all the fields have a value.
It might be better to use a DirectMethods' success/failure handlers instead of monitoring. Here is a simple example to demonstrate what I mean.
Parent Page
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void SaveAll(object sender, DirectEventArgs e)
{
this.Session["count"] = 0;
X.Js.Call("callA"); // By the way, do you really need to call it from server side?
X.Js.Call("callB"); // It would be easier to call from client.
}
[DirectMethod]
public void DataPrepared()
{
int count = Convert.ToInt32(this.Session["count"]);
this.Session["count"] = ++count;
if (count == 2)
{
X.Msg.Alert("DataPrepared", "All the data is ready").Show();
}
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
<script>
var callA = function () {
App.WindowA.getBody().App.direct.GetContent({ // App.WindowA.getBody() produces the same as Ext.getCmp('WindowA').iframe.dom.contentWindow
success: function () {
App.direct.DataPrepared();
}
});
};
var callB = function () {
App.WindowB.getBody().App.direct.GetContent({ // App.WindowB.getBody() produces the same as Ext.getCmp('WindowA').iframe.dom.contentWindow
success: function () {
App.direct.DataPrepared();
}
});
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:Window ID="WindowA" runat="server" Title="A" X="50" Y="50">
<Loader runat="server" Mode="Frame" Url="A.aspx" />
</ext:Window>
<ext:Window ID="WindowB" runat="server" Title="B" X="100" Y="100">
<Loader runat="server" Mode="Frame" Url="B.aspx" />
</ext:Window>
<ext:Button runat="server" Text="Save" OnDirectClick="SaveAll" />
</form>
</body>
</html>
Child Page A
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
[DirectMethod]
public void GetContent()
{
System.Threading.Thread.Sleep(1500);
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
</form>
</body>
</html>
Child Page B
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
[DirectMethod]
public void GetContent()
{
System.Threading.Thread.Sleep(4500);
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
</form>
</body>
</html>
Originally Posted by
timiteh
I think that the problem come from the fact that the calls are asynchronous while we would need synchronous call.
Well, that is impossible. A parent page has no access to its child (iframe) pages on server. The only way is to access it on client via JavaScript as you are already doing by calling a child page's DirectMethod via JavaScript.
Originally Posted by
timiteh
By inefficient, i mean that it is cumbersome to use static fields to store data of just one instance of the Parent Page.
I am not sure how you store the child pages' content in the static fields of the parent page.
Originally Posted by
timiteh
Not forgetting that if there are at least 2 concurrent instances, things can become awful quite quickly.
What exactly do you mean under 2 concurrent instances? For example, two instances of the parent page opened by different users? Well, if there are several users, storing its data in a page's static fields is not an option at all, because a page's static fields are stored on the application level. In other words, it is the same for all the users.
Originally Posted by
timiteh
However, i am considering using a Session variable rather static fields.
Yes, it might be better in your case.
Originally Posted by
timiteh
Well, i would prefer to avoid using Javascript to get data from the child pages.
Me and my team are new with Ext (besides 2 people though they are not as strong as we thought), we have quite short delays and Javascript is not what i would call our favorite language. We try to avoid it as much as i can.
Well, I understand it and it makes some sense. Though, IMHO, as quick as you overcome it (I mean not acceptance of JavaScript), it would be better for you, because it is practically impossible to avoid using JavaScript to create a strong, well-performance application. In your case, retrieving all the data using JavaScript could be a good solution. By the way, what kind of data do you retrieve from the child pages?
Also I hava a big question for you - do you really need to use iframes for each Wizard step? I would recomment to avoid it if possible, because iframes are very heavy thing (especially, for IEs) and might have issues with memory.
Originally Posted by
timiteh
Where can i get more information on Messagebus as well as a step by step tutorial ?
I think that this could be a solution to my problem but i need a tutorial and more information to better understand this technology.
Unfortunately, we have no a step-by-step tutorial. Just two examples. Also you can investigate the links provided in this example.
https://examples2.ext.net/#/MessageBus/Basic/Simple/
Generally speaking, it should explain all the technology.