Author: dmorozov
Date: 2008-11-19 09:11:12 -0500 (Wed, 19 Nov 2008)
New Revision: 11235
Modified:
trunk/sandbox/samples/queue-sample/src/main/webapp/pages/events.xhtml
Log:
https://jira.jboss.org/jira/browse/RF-4899
Modified: trunk/sandbox/samples/queue-sample/src/main/webapp/pages/events.xhtml
===================================================================
--- trunk/sandbox/samples/queue-sample/src/main/webapp/pages/events.xhtml 2008-11-19
14:09:05 UTC (rev 11234)
+++ trunk/sandbox/samples/queue-sample/src/main/webapp/pages/events.xhtml 2008-11-19
14:11:12 UTC (rev 11235)
@@ -10,7 +10,7 @@
<body>
<f:view>
<ui:include src="/templates/navigation.xhtml" />
-
+
<a4j:status startText="...running..." startStyle="color: green"
/>
<style type="text/css">
@@ -60,51 +60,61 @@
resetCells();
- var handlersList = ["onbeforedomupdate", "onsubmit",
"oncomplete", "onerror"];
+ var events = {
+ "onbeforedomupdate": ["request", "event",
"data"],
+ "onsubmit": ["request"],
+ "oncomplete": ["request", "event", "data"],
+ "onerror": ["request", "status", "message"]
+ };
+
+ var handlers = {};
- var handlers = {};
+ for (var handlerName in events) {
+ var args = events[handlerName];
+ var argCheck = "";
+ for ( var i = 0; i < args.length; i++) {
+ argCheck += "if (!" + args[i] + ") alert('argument " +
args[i] + " missing for handler " + handlerName + "');";
+ }
- for ( var i = 0; i < handlersList.length; i++) {
- var handlerName = handlersList[i];
- handlers["queue:" + handlerName] = new Function("my$('" +
handlerName + "Elt').innerHTML += 'Q'");
- handlers["component:" + handlerName] = new Function("my$('"
+ handlerName + "Elt').innerHTML += 'C'");
+ handlers["queue:" + handlerName] = Function.constructor.apply(this, [args,
argCheck + "my$('" + handlerName + "Elt').innerHTML +=
'Q'"]);
+ handlers["component:" + handlerName] = Function.constructor.apply(this,
[args, argCheck + "my$('" + handlerName + "Elt').innerHTML +=
'C'"]);
}
//]]></script>
- <q:queue name="queue"
onsubmit="handlers['queue:onsubmit']()"
onerror="handlers['queue:onerror']()"
- oncomplete="handlers['queue:oncomplete']()"
onbeforedomupdate="handlers['queue:onbeforedomupdate']()" />
+ <q:queue name="queue"
onsubmit="handlers['queue:onsubmit'](request)"
onerror="handlers['queue:onerror'](request, status, message)"
+ oncomplete="handlers['queue:oncomplete'](request, event, data)"
onbeforedomupdate="handlers['queue:onbeforedomupdate'](request, event,
data)" />
<h:form>
<h:panelGrid columns="1">
Components in queue
- <a4j:commandLink onclick="resetCells()" value="No component
handlers" eventsQueue="queue"/>
+ <a4j:commandLink onclick="resetCells()" value="No component
handlers" eventsQueue="queue" data="data" />
<a4j:commandLink onclick="resetCells()" value="Oncomplete
component client handler" eventsQueue="queue"
- onbeforedomupdate="request.options.oncomplete =
handlers['component:oncomplete']" />
+ onbeforedomupdate="request.options.oncomplete =
handlers['component:oncomplete']" data="data" />
- <a4j:commandLink onclick="resetCells(); A4J.AJAX.onError = undefined;"
value="Onerror" eventsQueue="queue" timeout="1" />
+ <a4j:commandLink onclick="resetCells(); A4J.AJAX.onError = undefined;"
value="Onerror" eventsQueue="queue" timeout="1"
data="data" />
<a4j:commandLink onclick="resetCells(); A4J.AJAX.onError =
handlers['component:onerror'];" value="Component onerror"
eventsQueue="queue"
- timeout="1" />
+ timeout="1" data="data" />
<a4j:commandLink onclick="resetCells()" value="Both component
handlers" eventsQueue="queue"
- oncomplete="handlers['component:oncomplete']()"
- onbeforedomupdate="handlers['component:onbeforedomupdate']()"
/>
+ oncomplete="handlers['component:oncomplete'](request, event,
data)"
+ onbeforedomupdate="handlers['component:onbeforedomupdate'](request,
event, data)" data="data" />
</h:panelGrid>
<h:panelGrid columns="1">
Components without queue
- <a4j:commandLink onclick="resetCells()" value="No component
handlers" />
+ <a4j:commandLink onclick="resetCells()" value="No component
handlers" data="data" />
<a4j:commandLink onclick="resetCells()" value="Oncomplete
component client handler"
- onbeforedomupdate="request.options.oncomplete =
handlers['component:oncomplete']" />
+ onbeforedomupdate="request.options.oncomplete =
handlers['component:oncomplete']" data="data" />
- <a4j:commandLink onclick="resetCells(); A4J.AJAX.onError = undefined;"
value="Onerror" timeout="1" />
+ <a4j:commandLink onclick="resetCells(); A4J.AJAX.onError = undefined;"
value="Onerror" timeout="1" data="data" />
<a4j:commandLink onclick="resetCells(); A4J.AJAX.onError =
handlers['component:onerror'];" value="Component onerror"
- timeout="1" />
+ timeout="1" data="data" />
<a4j:commandLink onclick="resetCells()" value="Both component
handlers"
- oncomplete="handlers['component:oncomplete']()"
- onbeforedomupdate="handlers['component:onbeforedomupdate']()"
/>
+ oncomplete="handlers['component:oncomplete'](request, event,
data)"
+ onbeforedomupdate="handlers['component:onbeforedomupdate'](request,
event, data)" data="data" />
</h:panelGrid>
</h:form>
</f:view>