Author: lfryc(a)redhat.com
Date: 2010-11-16 12:02:12 -0500 (Tue, 16 Nov 2010)
New Revision: 20059
Added:
modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTimeWatcher.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/resources/script/clientTime-refresh.js
modules/tests/metamer/trunk/application/src/main/webapp/resources/script/clientTime-updateDifference.js
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jAttachQueue/nested.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTime.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jQueue/QueueModel.java
Log:
a4j:attachQueue - nested sample - implemented and used new CC component for testing time
critical components + tests modified accordingly (RFPL-923)
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jAttachQueue/nested.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jAttachQueue/nested.xhtml 2010-11-16
16:16:33 UTC (rev 20058)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jAttachQueue/nested.xhtml 2010-11-16
17:02:12 UTC (rev 20059)
@@ -39,15 +39,6 @@
function add(element) {
element.innerHTML = 1 + parseInt(element.innerHTML);
}
-
- function updateDifferenceTime() {
- var eventTime1 =
parseInt(jQuery(#{rich:element('eventTime1:outputTime')}).attr('title'));
- var eventTime2 =
parseInt(jQuery(#{rich:element('eventTime2:outputTime')}).attr('title'));
- var beginTime =
parseInt(jQuery(#{rich:element('beginTime:outputTime')}).attr('title'));
-
- var eventTime = Math.max(eventTime1, eventTime2);
- jQuery(#{rich:element('differenceTime')}).text(beginTime -
eventTime);
- }
</script>
</ui:define>
@@ -67,9 +58,9 @@
requestDelay="#{a4jQueueBean.attributes['requestDelay'].value}"
status="status1"
timeout="#{a4jQueueBean.attributes['timeout'].value}" />
- <h:inputText id="input1"
value="#{a4jAttachQueueBean.text1}"
onkeypress="add(#{rich:element('events1')});
refresh(#{rich:element('eventTime1:outputTime')}); ">
- <a4j:ajax event="keypress" render="output1"
execute="@form" onbegin="add(#{rich:element('requests')});
refresh(#{rich:element('beginTime:outputTime')}); "
-
onbeforedomupdate="add(#{rich:element('updates')});"
oncomplete="refresh(#{rich:element('completeTime:outputTime')});
updateDifferenceTime(); ">
+ <h:inputText id="input1"
value="#{a4jAttachQueueBean.text1}"
onkeypress="add(#{rich:element('events1')});
#{rich:element('timeWatcher:grid')}.event(1); ">
+ <a4j:ajax event="keypress" render="output1"
execute="@form" onbegin="add(#{rich:element('requests')});
#{rich:element('timeWatcher:grid')}.begin(); "
+
onbeforedomupdate="add(#{rich:element('updates')});"
oncomplete="#{rich:element('timeWatcher:grid')}.complete();
#{rich:element('timeWatcher:grid')}.difference(); ">
<a4j:attachQueue id="a4jAttachQueue1"
ignoreDupResponses="#{a4jAttachQueueBean.attributes['ignoreDupResponses'].value}"
name="#{a4jAttachQueueBean.attributes['name'].value}"
@@ -83,9 +74,9 @@
</a4j:ajax>
</h:inputText>
- <h:inputText id="input2"
value="#{a4jAttachQueueBean.text2}"
onkeypress="add(#{rich:element('events2')});
refresh(#{rich:element('eventTime2:outputTime')}); ">
- <a4j:ajax event="keypress" render="output2"
execute="@form" onbegin="add(#{rich:element('requests')});
refresh(#{rich:element('beginTime:outputTime')}); "
-
onbeforedomupdate="add(#{rich:element('updates')});"
oncomplete="refresh(#{rich:element('completeTime:outputTime')});
updateDifferenceTime();">
+ <h:inputText id="input2"
value="#{a4jAttachQueueBean.text2}"
onkeypress="add(#{rich:element('events2')});
#{rich:element('timeWatcher:grid')}.event(2); ">
+ <a4j:ajax event="keypress" render="output2"
execute="@form" onbegin="add(#{rich:element('requests')});
#{rich:element('timeWatcher:grid')}.begin(); "
+
onbeforedomupdate="add(#{rich:element('updates')});"
oncomplete="#{rich:element('timeWatcher:grid')}.complete();
#{rich:element('timeWatcher:grid')}.difference(); ">
<a4j:attachQueue id="a4jAttachQueue2"
ignoreDupResponses="#{a4jAttachQueueBean.attributes2['ignoreDupResponses'].value}"
name="#{a4jAttachQueueBean.attributes2['name'].value}"
@@ -112,16 +103,11 @@
<h:outputText value="0" id="requests" />
DOM updates count:
<h:outputText value="0" id="updates" />
- Difference time:
- <h:outputText value="" id="differenceTime" />
</h:panelGrid>
+
+
- <h:panelGrid columns="1">
- <metamer:clientTime id="eventTime1" label="Event 1
Time:" />
- <metamer:clientTime id="eventTime2" label="Event 2
Time:" />
- <metamer:clientTime id="beginTime" label="Begin
Time:" />
- <metamer:clientTime id="completeTime" label="Complete
Time:" />
- </h:panelGrid>
+ <metamer:clientTimeWatcher id="timeWatcher" events="2"
/>
</ui:define>
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTime.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTime.xhtml 2010-11-16
16:16:33 UTC (rev 20058)
+++
modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTime.xhtml 2010-11-16
17:02:12 UTC (rev 20059)
@@ -9,20 +9,20 @@
</composite:interface>
<composite:implementation>
- <h:outputLabel value="#{cc.attrs.label}" />
- <h:outputText id="outputTime" value=""
title="" />
- <h:outputScript library="script" name="date-format.js"
/>
- <script type="text/javascript">
- //<![CDATA[
- function refresh(element) {
- var now = new Date();
- jQuery(element)
- .text(now.format("dd.mm.yyyy HH:MM:ss.l", false))
- .attr("title", now.getTime());
- }
- refresh(#{rich:element('outputTime')});
- //]]>
- </script>
+ <h:outputScript target="head" library="script"
name="date-format.js" />
+ <h:outputScript target="head" library="script"
name="clientTime-refresh.js" />
+
+ <style>
+ td.metamerClientTimeLabel {
+ width: 8em;
+ }
+ </style>
+
+ <h:panelGrid columns="2"
columnClasses="metamerClientTimeLabel, metamerClientTimeText">
+ <h:outputLabel value="#{cc.attrs.label}" />
+ <h:outputText id="outputTime" value=""
title="" />
+ </h:panelGrid>
+
<script>Metamer.ClientTime.refresh(#{rich:element('outputTime')});</script>
</composite:implementation>
</h:body>
</html>
Added:
modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTimeWatcher.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTimeWatcher.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTimeWatcher.xhtml 2010-11-16
17:02:12 UTC (rev 20059)
@@ -0,0 +1,67 @@
+<!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"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:c="http://java.sun.com/jsp/jstl/core"
+
xmlns:composite="http://java.sun.com/jsf/composite"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:metamer="http://java.sun.com/jsf/composite/metamer">
+
+<h:body>
+ <composite:interface>
+ <composite:attribute name="events" type="java.lang.Integer"
default="1" />
+ </composite:interface>
+
+ <composite:implementation>
+ <h:outputScript target="head" library="script"
name="clientTime-refresh.js" />
+ <h:outputScript target="head" library="script"
name="clientTime-updateDifference.js" />
+
+ <h:panelGrid id="grid" columns="1">
+ <c:forEach var="event" begin="1"
end="#{cc.attrs.events}">
+ <metamer:clientTime id="event#{event}"
+ label="Event #{cc.attrs.events > 1 ? event : ''} Time:" />
+ </c:forEach>
+ <metamer:clientTime id="begin" label="Begin Time:" />
+ <metamer:clientTime id="complete" label="Complete Time:" />
+ <h:panelGroup>
+ Difference ms: <h:outputText id="difference" value="-"
/>
+ </h:panelGroup>
+ </h:panelGrid>
+
+ <script>
+ (function( undefined ) {
+ grid = #{rich:element('grid')};
+
+ grid.event = function(event) {
+ event = (event) ? event : 1;
+ var id =
"#{rich:clientId('event1')}:outputTime".replace("1", event);
+ Metamer.ClientTime.refresh(document.getElementById(id));
+ }
+
+ grid.begin = function() {
+ Metamer.ClientTime.refresh(this.getBeginElement());
+ }
+
+ grid.complete = function() {
+ var id = "#{rich:clientId('complete')}:outputTime";
+ Metamer.ClientTime.refresh(document.getElementById(id));
+ }
+
+ grid.difference = function() {
+ var differenceElement = #{rich:element('difference')};
+ var beginTimeElement = this.getBeginElement();
+ var eventTimeId =
"#{rich:clientId('event1')}".replace("1", "");
+ Metamer.ClientTime.updateDifference(differenceElement, beginTimeElement,
eventTimeId);
+ }
+
+ grid.getBeginElement = function() {
+ var id = "#{rich:clientId('begin')}:outputTime";
+ return document.getElementById(id);
+ }
+ })();
+ </script>
+
+ </composite:implementation>
+</h:body>
+</html>
Added:
modules/tests/metamer/trunk/application/src/main/webapp/resources/script/clientTime-refresh.js
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/resources/script/clientTime-refresh.js
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/resources/script/clientTime-refresh.js 2010-11-16
17:02:12 UTC (rev 20059)
@@ -0,0 +1,14 @@
+if (Metamer == undefined) {
+ var Metamer = {};
+}
+
+if (Metamer.ClientTime == undefined) {
+ Metamer.ClientTime = {};
+}
+
+Metamer.ClientTime.refresh = function (element) {
+ var now = new Date();
+ jQuery(element)
+ .text(now.format("dd.mm.yyyy HH:MM:ss.l", false))
+ .attr("title", now.getTime());
+}
\ No newline at end of file
Added:
modules/tests/metamer/trunk/application/src/main/webapp/resources/script/clientTime-updateDifference.js
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/resources/script/clientTime-updateDifference.js
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/resources/script/clientTime-updateDifference.js 2010-11-16
17:02:12 UTC (rev 20059)
@@ -0,0 +1,28 @@
+if (Metamer == undefined) {
+ var Metamer = {};
+}
+
+if (Metamer.ClientTime == undefined) {
+ Metamer.ClientTime = {};
+}
+
+Metamer.ClientTime.updateDifference = function (differenceTimeElement, beginTimeElement,
eventTimeId) {
+ var maxEventTime = 0;
+
+ for (var i = 1; i < 100; i++) {
+ var id = eventTimeId + i + ":outputTime";
+ var element = document.getElementById(id);
+ if (!element) {
+ if (i == 1) {
+ throw new Error("no eventTime element with id '" + id + "' was
found");
+ }
+ break;
+ }
+ var eventTime = parseInt(element.title);
+ maxEventTime = Math.max(eventTime, maxEventTime);
+ }
+
+ var beginTime = parseInt(beginTimeElement.title);
+
+ jQuery(differenceTimeElement).text(beginTime - maxEventTime);
+}
\ No newline at end of file
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jQueue/QueueModel.java
===================================================================
---
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jQueue/QueueModel.java 2010-11-16
16:16:33 UTC (rev 20058)
+++
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jQueue/QueueModel.java 2010-11-16
17:02:12 UTC (rev 20059)
@@ -47,10 +47,10 @@
ElementLocator<?> requests = ref(form, "span[id$=requests]");
ElementLocator<?> updates = ref(form, "span[id$=updates]");
- AttributeLocator<?> event1Time = ref(form,
"span[id$=eventTime1\\:outputTime]").getAttribute(TITLE);
- AttributeLocator<?> event2Time = ref(form,
"span[id$=eventTime2\\:outputTime]").getAttribute(TITLE);
- AttributeLocator<?> beginTime = ref(form,
"span[id$=beginTime\\:outputTime]").getAttribute(TITLE);
- AttributeLocator<?> completeTime = ref(form,
"span[id$=completeTime\\:outputTime]").getAttribute(TITLE);
+ AttributeLocator<?> event1Time = ref(form,
"span[id$=event1\\:outputTime]").getAttribute(TITLE);
+ AttributeLocator<?> event2Time = ref(form,
"span[id$=event2\\:outputTime]").getAttribute(TITLE);
+ AttributeLocator<?> beginTime = ref(form,
"span[id$=begin\\:outputTime]").getAttribute(TITLE);
+ AttributeLocator<?> completeTime = ref(form,
"span[id$=complete\\:outputTime]").getAttribute(TITLE);
Retriever<Integer> retrieveEvent1Count =
integerAdapter(RETRIEVE_TEXT.locator(events1));
Retriever<Integer> retrieveEvent2Count =
integerAdapter(RETRIEVE_TEXT.locator(events2));