In xsltforms-493 and earlier, xforms-ready is dispatched immediately
after xforms-model-construct-done, but before the UI is ready.
The UI should be ready before xforms-ready is dispatched.
For example, if you want to display a page, and load additional
resources on xforms-ready to display when they return, you would perform
the final submissions on xforms-ready.
In the current implementation there is no difference between doing this
on xforms-model-construct-done and xforms-ready because both block the
initial page display.
I have not examined all aspects of this problem, but I noticed the
following simple change will fix it:
--- xsltforms.js.old 2011-03-15 13:44:44.000000000 -0700
+++ xsltforms.js 2011-03-15 14:07:10.774157731 -0700
@@ -1599,7 +1599,6 @@
this.openAction();
XMLEvents.dispatchList(this.models, "xforms-model-construct");
- XMLEvents.dispatchList(this.models, "xforms-ready");
this.refresh();
this.closeAction();
this.ready = true;
@@ -2109,6 +2108,7 @@
}
XMLEvents.dispatch(this, "xforms-rebuild");
XMLEvents.dispatch(this, "xforms-model-construct-done");
+ window.setTimeout("XMLEvents.dispatchXFormsReady()", 1);
};
@@ -7256,6 +7256,10 @@
+XMLEvents.dispatchXFormsReady = function() {
+ XMLEvents.dispatchList(xforms.models, "xforms-ready");
+};
+
XMLEvents.dispatchList = function(list, name) {
for (var id = 0, len = list.length; id < len; id++) {
XMLEvents.dispatch(list[id], name);
Here is a test case. Without this change, or a similar one, the whole
page blocks and then you see A and B at the same time.
With it, you see A, then a pause, then B is added.
<?xml version="1.0"?>
<?css-conversion no?>
<?xml-stylesheet type="text/xsl" href="/xsltforms/xsltforms.xsl" css="no"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<head>
<title>A/B</title>
<model xmlns="http://www.w3.org/2002/xforms">
<instance id="a" resource="a.xml" />
<instance id="b"><empty xmnls="" /></instance>
<submission id="load-b" method="get"
ref="instance('b')"
replace="instance" mode="asynchronous"
resource='b.cgi' />
<xf:action ev:event="xforms-ready">
<xf:send submission="load-b" />
</xf:action>
</model>
</head>
<body>
<group xmlns="http://www.w3.org/2002/xforms">
<output ref="instance('a')/a">
<label>A: </label>
</output>
<output ref="instance('b')/b">
<label>B: </label>
</output>
</group>
</body>
</html>
a.xml:
<?xml version="1.0"?>
<data>
<a>a is loaded</a>
</data>
b.cgi:
#!/bin/sh
sleep 2
echo "Content-Type: text/plain"
echo ""
cat <<EOF
<?xml version="1.0"?>
<data>
<b>b is loaded</b>
</data>
EOF
|