JBoss Rich Faces SVN: r20065 - modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-11-17 04:34:09 -0500 (Wed, 17 Nov 2010)
New Revision: 20065
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-column.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-component-control.xhtml
Removed:
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting.xhtml
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/list.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/simple.xhtml
Log:
rich:dataTable - sorting divided to two samples: sorting using component control and sorting using column (RFPL-912)
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/list.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/list.xhtml 2010-11-17 09:21:53 UTC (rev 20064)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/list.xhtml 2010-11-17 09:34:09 UTC (rev 20065)
@@ -49,9 +49,13 @@
<span style="color: red">TODO will be used with various types of input and command components as soon as available</span>
</metamer:testPageLink>
- <metamer:testPageLink id="sorting" outcome="sorting" value="Table Sorting">
- Page that contains sortable <b>rich:dataTable</b> (with model containing capitals) and input boxes for all its attributes.
+ <metamer:testPageLink id="sorting-using-component-control" outcome="sorting-using-component-control" value="Table Sorting - Component Control">
+ <b>rich:dataTable</b> (with model containing states and capitals) sortable by <b>rich:componentControl</b>.
</metamer:testPageLink>
+
+ <metamer:testPageLink id="sorting-using-column" outcome="sorting-using-column" value="Table Sorting - Column based">
+ <b>rich:dataTable</b> (with model containing states and capitals) custom sorting by <b>rich:column</b>'s attribute @sortBy, @sortOrder.
+ </metamer:testPageLink>
<metamer:testPageLink id="filtering" outcome="filtering" value="Table filtering">
Page that contains filterable <b>rich:dataTable</b> (with model containing capitals) and input boxes for all its attributes.
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/simple.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/simple.xhtml 2010-11-17 09:21:53 UTC (rev 20064)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/simple.xhtml 2010-11-17 09:34:09 UTC (rev 20065)
@@ -47,7 +47,7 @@
</ui:define>
<ui:define name="component">
-
+
<rich:dataTable id="richDataTable"
filterVar="#{richDataTableBean.attributes['filterVar'].value}"
filteringListeners="#{richDataTableBean.attributes['filteringListeners'].value}"
@@ -110,8 +110,11 @@
</ui:define>
<ui:define name="outOfTemplateAfter">
+
<h:commandButton id="sortStatesButton" value="sort states">
- <rich:componentControl event="click" target="richDataTable" operation="sort"/>
+ <rich:componentControl event="click" target="richDataTable" operation="sort">
+ <f:param value="columnState" />
+ </rich:componentControl>
</h:commandButton>
<h:commandButton id="sortCapitalsButton" value="sort capitals">
@@ -119,7 +122,13 @@
<f:param value="columnCapital" />
</rich:componentControl>
</h:commandButton>
-
+
+ <br/><br/>
+
+ <h:commandButton id="sortTableButton" value="sort table">
+ <rich:componentControl event="click" target="richDataTable" operation="sort" />
+ </h:commandButton>
+
<br/><br/>
<metamer:attributes value="#{richDataTableBean.attributes}" id="attributes" />
Copied: modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-column.xhtml (from rev 20064, modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting.xhtml)
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-column.xhtml (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-column.xhtml 2010-11-17 09:34:09 UTC (rev 20065)
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!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:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:metamer="http://java.sun.com/jsf/composite/metamer" xmlns:rich="http://richfaces.org/rich">
+
+ <!--
+JBoss, Home of Professional Open Source
+Copyright 2010, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="head">
+ <f:metadata>
+ <f:viewParam name="templates" value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ <h:outputStylesheet library="css" name="richDataTable.css"/>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ <br/>
+ <h:outputText value="Show data in table: " />
+ <h:selectBooleanCheckbox id="noDataCheckbox" value="#{richDataTableBean.state}">
+ <a4j:ajax render="richDataTable scroller1"/>
+ </h:selectBooleanCheckbox>
+ <br/><br/>
+ <rich:dataScroller id="scroller1" for="richDataTable" page="#{richDataTableBean.page}" maxPages="7" render="richDataTable"/>
+ </ui:define>
+
+ <ui:define name="component">
+
+ <rich:dataTable id="richDataTable"
+ filterVar="#{richDataTableBean.attributes['filterVar'].value}"
+ filteringListeners="#{richDataTableBean.attributes['filteringListeners'].value}"
+ first="#{richDataTableBean.attributes['first'].value}"
+ iterationState="#{richDataTableBean.attributes['iterationState'].value}"
+ iterationStatusVar="#{richDataTableBean.attributes['iterationStatusVar'].value}"
+ keepSaved="#{richDataTableBean.attributes['keepSaved'].value}"
+ noDataLabel="#{richDataTableBean.attributes['noDataLabel'].value}"
+ relativeRowIndex="#{richDataTableBean.attributes['relativeRowIndex'].value}"
+ rendered="#{richDataTableBean.attributes['rendered'].value}"
+ rowAvailable="#{richDataTableBean.attributes['rowAvailable'].value}"
+ rowCount="#{richDataTableBean.attributes['rowCount'].value}"
+ rowData="#{richDataTableBean.attributes['rowData'].value}"
+ rowIndex="#{richDataTableBean.attributes['rowIndex'].value}"
+ rowKey="#{richDataTableBean.attributes['rowKey'].value}"
+ rowKeyConverter="#{richDataTableBean.attributes['rowKeyConverter'].value}"
+ rows="#{richDataTableBean.attributes['rows'].value}"
+ sortMode="#{richDataTableBean.attributes['sortMode'].value}"
+ sortPriority="#{richDataTableBean.attributes['sortPriority'].value}"
+ sortingListeners="#{richDataTableBean.attributes['sortingListeners'].value}"
+ value="#{richDataTableBean.state ? model.capitals : null}"
+ var="record"
+ >
+
+ <f:facet name="noData">
+ <h:outputText value="There is no data." style="color: red;"/>
+ </f:facet>
+
+ <rich:column id="columnState" sortBy="#{record.state}" sortOrder="#{richDataTableBean.statesOrder}">
+ <f:facet name="header">
+ <a4j:commandLink id="columnHeaderState" value="State" render="richDataTable" action="#{richDataTableBean.sortByStates}"/>
+ </f:facet>
+
+ <h:outputText value="#{record.state}" />
+ <f:facet name="footer">
+ <h:outputText id="columnFooterState" value="State" />
+ </f:facet>
+ </rich:column>
+
+ <rich:column id="columnCapital" sortBy="#{record.name}" sortOrder="#{richDataTableBean.capitalsOrder}" sortingListeners="#{richDataTableBean.sortingListener}">
+ <f:facet name="header">
+ <a4j:commandLink id="columnHeaderCapital" value="Capital" render="richDataTable" action="#{richDataTableBean.sortByCapitals}"/>
+ </f:facet>
+
+ <h:outputText value="#{record.name}" />
+ <f:facet name="footer">
+ <h:outputText id="columnFooterCapital" value="Capital" />
+ </f:facet>
+ </rich:column>
+
+ <f:facet name="footer">
+ <rich:dataScroller id="scroller2" for="richDataTable" page="#{richDataTableBean.page}" maxPages="7" render="richDataTable" />
+ </f:facet>
+
+ </rich:dataTable>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <metamer:attributes value="#{richDataTableBean.attributes}" id="attributes" />
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Copied: modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-component-control.xhtml (from rev 20064, modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting.xhtml)
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-component-control.xhtml (rev 0)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-component-control.xhtml 2010-11-17 09:34:09 UTC (rev 20065)
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!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:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:metamer="http://java.sun.com/jsf/composite/metamer" xmlns:rich="http://richfaces.org/rich">
+
+ <!--
+JBoss, Home of Professional Open Source
+Copyright 2010, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="head">
+ <f:metadata>
+ <f:viewParam name="templates" value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ <h:outputStylesheet library="css" name="richDataTable.css"/>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ <br/>
+ <h:outputText value="Show data in table: " />
+ <h:selectBooleanCheckbox id="noDataCheckbox" value="#{richDataTableBean.state}">
+ <a4j:ajax render="richDataTable scroller1"/>
+ </h:selectBooleanCheckbox>
+ <br/><br/>
+ <rich:dataScroller id="scroller1" for="richDataTable" page="#{richDataTableBean.page}" maxPages="7" render="richDataTable"/>
+ </ui:define>
+
+ <ui:define name="component">
+
+ <rich:dataTable id="richDataTable"
+ filterVar="#{richDataTableBean.attributes['filterVar'].value}"
+ filteringListeners="#{richDataTableBean.attributes['filteringListeners'].value}"
+ first="#{richDataTableBean.attributes['first'].value}"
+ iterationState="#{richDataTableBean.attributes['iterationState'].value}"
+ iterationStatusVar="#{richDataTableBean.attributes['iterationStatusVar'].value}"
+ keepSaved="#{richDataTableBean.attributes['keepSaved'].value}"
+ noDataLabel="#{richDataTableBean.attributes['noDataLabel'].value}"
+ relativeRowIndex="#{richDataTableBean.attributes['relativeRowIndex'].value}"
+ rendered="#{richDataTableBean.attributes['rendered'].value}"
+ rowAvailable="#{richDataTableBean.attributes['rowAvailable'].value}"
+ rowCount="#{richDataTableBean.attributes['rowCount'].value}"
+ rowData="#{richDataTableBean.attributes['rowData'].value}"
+ rowIndex="#{richDataTableBean.attributes['rowIndex'].value}"
+ rowKey="#{richDataTableBean.attributes['rowKey'].value}"
+ rowKeyConverter="#{richDataTableBean.attributes['rowKeyConverter'].value}"
+ rows="#{richDataTableBean.attributes['rows'].value}"
+ sortMode="#{richDataTableBean.attributes['sortMode'].value}"
+ sortPriority="#{richDataTableBean.attributes['sortPriority'].value}"
+ sortingListeners="#{richDataTableBean.attributes['sortingListeners'].value}"
+ value="#{richDataTableBean.state ? model.capitals : null}"
+ var="record"
+ >
+
+ <f:facet name="noData">
+ <h:outputText value="There is no data." style="color: red;"/>
+ </f:facet>
+
+ <rich:column id="columnState" sortBy="#{record.state}" sortOrder="#{richDataTableBean.statesOrder}">
+ <f:facet name="header">
+ State
+ </f:facet>
+
+ <h:outputText value="#{record.state}" />
+ <f:facet name="footer">
+ <h:outputText id="columnFooterState" value="State" />
+ </f:facet>
+ </rich:column>
+
+ <rich:column id="columnCapital" sortBy="#{record.name}" sortOrder="#{richDataTableBean.capitalsOrder}">
+ <f:facet name="header">
+ Capital
+ </f:facet>
+
+ <h:outputText value="#{record.name}" />
+ <f:facet name="footer">
+ <h:outputText id="columnFooterCapital" value="Capital" />
+ </f:facet>
+ </rich:column>
+
+ <f:facet name="footer">
+ <rich:dataScroller id="scroller2" for="richDataTable" page="#{richDataTableBean.page}" maxPages="7" render="richDataTable" />
+ </f:facet>
+
+ </rich:dataTable>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <h:commandButton id="sortStatesButton" value="sort state">
+ <rich:componentControl event="click" target="richDataTable" operation="sort">
+ <f:param value="columnState" />
+ </rich:componentControl>
+ </h:commandButton>
+
+ <h:commandButton id="sortCapitalsButton" value="sort capital">
+ <rich:componentControl event="click" target="richDataTable" operation="sort">
+ <f:param value="columnCapital" />
+ </rich:componentControl>
+ </h:commandButton>
+
+ <br/><br/>
+
+ <h:commandButton id="sortTableButton" value="sort table">
+ <rich:componentControl event="click" target="richDataTable" operation="sort" />
+ </h:commandButton>
+
+ <br/><br/>
+
+ <metamer:attributes value="#{richDataTableBean.attributes}" id="attributes" />
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Deleted: modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting.xhtml 2010-11-17 09:21:53 UTC (rev 20064)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting.xhtml 2010-11-17 09:34:09 UTC (rev 20065)
@@ -1,126 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!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:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
- xmlns:metamer="http://java.sun.com/jsf/composite/metamer" xmlns:rich="http://richfaces.org/rich">
-
- <!--
-JBoss, Home of Professional Open Source
-Copyright 2010, Red Hat, Inc. and individual contributors
-by the @authors tag. See the copyright.txt in the distribution for a
-full listing of individual contributors.
-
-This is free software; you can redistribute it and/or modify it
-under the terms of the GNU Lesser General Public License as
-published by the Free Software Foundation; either version 2.1 of
-the License, or (at your option) any later version.
-
-This software is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public
-License along with this software; if not, write to the Free
-Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-02110-1301 USA, or see the FSF site: http://www.fsf.org.
- -->
-
- <ui:composition template="/templates/template.xhtml">
-
- <ui:define name="head">
- <f:metadata>
- <f:viewParam name="templates" value="#{templateBean.templates}">
- <f:converter converterId="templatesListConverter" />
- </f:viewParam>
- </f:metadata>
- <h:outputStylesheet library="css" name="richDataTable.css"/>
- </ui:define>
-
- <ui:define name="outOfTemplateBefore">
- <br/>
- <h:outputText value="Show data in table: " />
- <h:selectBooleanCheckbox id="noDataCheckbox" value="#{richDataTableBean.state}">
- <a4j:ajax render="richDataTable scroller1"/>
- </h:selectBooleanCheckbox>
- <br/><br/>
- <rich:dataScroller id="scroller1" for="richDataTable" page="#{richDataTableBean.page}" maxPages="7" render="richDataTable"/>
- </ui:define>
-
- <ui:define name="component">
-
- <rich:dataTable id="richDataTable"
- filterVar="#{richDataTableBean.attributes['filterVar'].value}"
- filteringListeners="#{richDataTableBean.attributes['filteringListeners'].value}"
- first="#{richDataTableBean.attributes['first'].value}"
- iterationState="#{richDataTableBean.attributes['iterationState'].value}"
- iterationStatusVar="#{richDataTableBean.attributes['iterationStatusVar'].value}"
- keepSaved="#{richDataTableBean.attributes['keepSaved'].value}"
- noDataLabel="#{richDataTableBean.attributes['noDataLabel'].value}"
- relativeRowIndex="#{richDataTableBean.attributes['relativeRowIndex'].value}"
- rendered="#{richDataTableBean.attributes['rendered'].value}"
- rowAvailable="#{richDataTableBean.attributes['rowAvailable'].value}"
- rowCount="#{richDataTableBean.attributes['rowCount'].value}"
- rowData="#{richDataTableBean.attributes['rowData'].value}"
- rowIndex="#{richDataTableBean.attributes['rowIndex'].value}"
- rowKey="#{richDataTableBean.attributes['rowKey'].value}"
- rowKeyConverter="#{richDataTableBean.attributes['rowKeyConverter'].value}"
- rows="#{richDataTableBean.attributes['rows'].value}"
- sortMode="#{richDataTableBean.attributes['sortMode'].value}"
- sortPriority="#{richDataTableBean.attributes['sortPriority'].value}"
- sortingListeners="#{richDataTableBean.attributes['sortingListeners'].value}"
- value="#{richDataTableBean.state ? model.capitals : null}"
- var="record"
- >
-
- <f:facet name="noData">
- <h:outputText value="There is no data." style="color: red;"/>
- </f:facet>
-
- <rich:column id="columnState" sortBy="#{record.state}" sortOrder="#{richDataTableBean.statesOrder}">
- <f:facet name="header">
- <a4j:commandLink id="columnHeaderState" value="State" render="richDataTable" action="#{richDataTableBean.sortByStates}"/>
- </f:facet>
-
- <h:outputText value="#{record.state}" />
- <f:facet name="footer">
- <h:outputText id="columnFooterState" value="State" />
- </f:facet>
- </rich:column>
-
- <rich:column id="columnCapital" sortBy="#{record.name}" sortOrder="#{richDataTableBean.capitalsOrder}" sortingListeners="#{richDataTableBean.sortingListener}">
- <f:facet name="header">
- <a4j:commandLink id="columnHeaderCapital" value="Capital" render="richDataTable" action="#{richDataTableBean.sortByCapitals}"/>
- </f:facet>
-
- <h:outputText value="#{record.name}" />
- <f:facet name="footer">
- <h:outputText id="columnFooterCapital" value="Capital" />
- </f:facet>
- </rich:column>
-
- <f:facet name="footer">
- <rich:dataScroller id="scroller2" for="richDataTable" page="#{richDataTableBean.page}" maxPages="7" render="richDataTable" />
- </f:facet>
-
- </rich:dataTable>
- </ui:define>
-
- <ui:define name="outOfTemplateAfter">
- <h:commandButton id="sortStatesButton" value="sort state">
- <rich:componentControl event="click" target="richDataTable" operation="sort"/>
- </h:commandButton>
-
- <h:commandButton id="sortCapitalsButton" value="sort capital">
- <rich:componentControl event="click" target="richDataTable" operation="sort">
- <f:param value="columnCapital" />
- </rich:componentControl>
- </h:commandButton>
-
- <br/><br/>
-
- <metamer:attributes value="#{richDataTableBean.attributes}" id="attributes" />
- </ui:define>
-
- </ui:composition>
-</html>
\ No newline at end of file
14 years, 1 month
JBoss Rich Faces SVN: r20064 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jRepeat.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-11-17 04:21:53 -0500 (Wed, 17 Nov 2010)
New Revision: 20064
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jRepeat/TestMatrix.java
Log:
a4j:repeat - TestMatrix - renamed methods to be obvious, extended by testMatrixAfterRefresh
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jRepeat/TestMatrix.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jRepeat/TestMatrix.java 2010-11-17 04:50:22 UTC (rev 20063)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jRepeat/TestMatrix.java 2010-11-17 09:21:53 UTC (rev 20064)
@@ -123,11 +123,22 @@
}
@Test
+ public void testMatrixAfterRerender() {
+ testChanging();
+
+ rerenderAll();
+
+ checkMatrix();
+ }
+
+ @Test
public void testMatrixAfterRefresh() {
testChanging();
- refreshAll();
+ selenium.refresh();
+ selenium.waitForPageToLoad();
+ initializeMatrix();
checkMatrix();
}
@@ -160,7 +171,7 @@
}
}
- private void refreshAll() {
+ private void rerenderAll() {
waitXhr(selenium).click(jq("img#controlsForm\\:reRenderAllImage"));
}
14 years, 1 month
JBoss Rich Faces SVN: r20063 - in modules/docs/trunk/Component_Reference/src/main/docbook/en-US: extras and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2010-11-16 23:50:22 -0500 (Tue, 16 Nov 2010)
New Revision: 20063
Added:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-Table_sorting-Basic_sorting.xml_sample
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-Table_sorting-External_sorting.xml_sample
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/figu-Component_Reference-Table_sorting-Basic_sorting.png
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/figu-Component_Reference-Table_sorting-External_sorting.png
Modified:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml
Log:
Added table filtering and sorting chapters
Modified: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml 2010-11-17 00:13:58 UTC (rev 20062)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml 2010-11-17 04:50:22 UTC (rev 20063)
@@ -1189,9 +1189,8 @@
</para>
</important>
- <!-- TODO: not in M4
<para>
- Tables entries can be filtered by the user using either the basic method built in to the <sgmltag><rich:column></sgmltag> component, or by defining external filters. Refer to <xref linkend="sect-Component_Reference-Tables_and_grids-richcolumn" /> for details on using the <sgmltag><rich:column></sgmltag> component in tables.
+ Tables entries can be filtered by the user through either the basic method built in to the <sgmltag><rich:column></sgmltag> component, or by defining external filters. Refer to <xref linkend="sect-Component_Reference-Tables_and_grids-richcolumn" /> for details on using the <sgmltag><rich:column></sgmltag> component in tables.
</para>
<section id="sect-Component_Reference-Table_filtering-Basic_filtering">
<title>Basic filtering</title>
@@ -1251,7 +1250,6 @@
</mediaobject>
</example>
</section>
- -->
</section>
<section id="sect-Component_Reference-Tables_and_grids-Table_sorting">
@@ -1263,6 +1261,82 @@
This section is currently under development. Any features it describes may not be available in the current release of RichFaces.
</para>
</important>
+
+ <para>
+ Tables entries can be sorted by the user through either the basic method built in to the <sgmltag><rich:column></sgmltag> component, or by defining external sorting algorithms. Refer to <xref linkend="sect-Component_Reference-Tables_and_grids-richcolumn" /> for details on using the <sgmltag><rich:column></sgmltag> component in tables.
+ </para>
+
+ <section id="sect-Component_Reference-Tables_and_grids-Basic_sorting">
+ <title>Basic sorting</title>
+ <para>
+ The built-in sorting functionality of the <sgmltag><rich:column></sgmltag> component allows a user to click the header of a column to sort it in ascending or descending order.
+ </para>
+ <note>
+ <title>Sorting non-English tables</title>
+ <para>
+ To sort a table whose contents are not in English, add the <literal>org.richfaces.datatableUsesViewLocale</literal> context parameter to the project's <filename>web.xml</filename> settings file. Set the value of the context parameter to <literal>true</literal>.
+ </para>
+ </note>
+ <para>
+ Set the <varname>sortBy</varname> attribute to indicate which value to use when sorting the column. Expressions in the <varname>sortBy</varname> attribute must refer to the variable declared in the table's <varname>var</varname> attribute, which is used to fill the contents of the table.
+ </para>
+ <example id="exam-Component_Reference-Table_sorting-Basic_sorting">
+ <title>Basic sorting</title>
+ <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-Table_sorting-Basic_sorting.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ <para>
+ The example uses the basic sorting method on both columns in the table.
+ </para>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/figu-Component_Reference-Table_sorting-Basic_sorting.png" format="PNG" />
+ </imageobject>
+ <textobject>
+ <para>
+ A table of state capitals sorted alphabetically by state.
+ </para>
+ </textobject>
+ </mediaobject>
+ </example>
+ <para>
+ Use the <varname>sortOrder</varname> attribute to set how the table's contents are sorted when it is first loaded. By default, the value of the <varname>sortOrder</varname> attribute is <literal>unsorted</literal>, so that table entries appear in the order the are contained in the data model. Use <code>sortOrder="ascending"</code> to sort the entries in ascending alphabetical or numerical order. Use <code>sortOrder="descending"</code> to sort the entries in descending alphabetical or numerical order. The <varname>sortOrder</varname> attribute can also be used to externally set the sort order of a table when using the external sorting method; refer to <xref linkend="sect-Component_Reference-Table_sorting-External_sorting" /> for details.
+ </para>
+ <para>
+ Use the <varname>sortMode</varname> attribute to determine how multiple columns are sorted. By default, the value of the <varname>sortMode</varname> attribute is <literal>single</literal>, so tables are only sorted by a single column. Each time the header of a column is clicked the entire table is re-sorted according to that column. Set <code>sortMode="multiple"</code> to allow tables to be sorted by a primary column, then by a secondary column, and so on.
+ </para>
+ </section>
+
+ <section id="sect-Component_Reference-Table_sorting-External_sorting">
+ <title>External sorting</title>
+ <para>
+ If you require more advanced sorting using custom functions or expressions, use the external sorting properties of the <sgmltag><rich:column></sgmltag> component.
+ </para>
+ <para>
+ Deactivate the built-in sorting by setting <code>selfSorted="false"</code> for the <sgmltag><rich:column></sgmltag> component. You can then bind the <varname>sortOrder</varname> attribute to bean properties and manage the sorting order externally.
+ </para>
+ <example id="exam-Component_Reference-Table_sorting-External_sorting">
+ <title>External sorting</title>
+ <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-Table_sorting-External_sorting.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ <para>
+ The example uses an external control to manage the table's sorting.
+ </para>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/figu-Component_Reference-Table_sorting-External_sorting.png" format="PNG" />
+ </imageobject>
+ <textobject>
+ <para>
+ A table of vehicle details, sorted using an external control.
+ </para>
+ </textobject>
+ </mediaobject>
+ </example>
+ <para>
+ When using the <code>sortMode="multiple"</code> configuration, set the priority by which columns are sorted with the <varname>sortPriorities</varname> attribute.
+ </para>
+ <para>
+ Use the <varname>sortExpression</varname> attribute to define a bean property to use for sorting the column. The expression checks each table entry against the sorting expression during rendering.
+ </para>
+ </section>
</section>
</chapter>
Added: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-Table_sorting-Basic_sorting.xml_sample
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-Table_sorting-Basic_sorting.xml_sample (rev 0)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-Table_sorting-Basic_sorting.xml_sample 2010-11-17 04:50:22 UTC (rev 20063)
@@ -0,0 +1,14 @@
+<rich:dataTable value="#{capitalsBean.capitals}" var="cap" width="300px">
+ <rich:column sortBy="#{cap.state}">
+ <f:facet name="header">
+ <h:outputText value="State Name"/>
+ </f:facet>
+ <h:outputText value="#{cap.state}"/>
+ </rich:column>
+ <rich:column sortBy="#{cap.name}">
+ <f:facet name="header">
+ <h:outputText value="State Capital"/>
+ </f:facet>
+ <h:outputText value="#{cap.name}"/>
+ </rich:column>
+</rich:dataTable>
Added: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-Table_sorting-External_sorting.xml_sample
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-Table_sorting-External_sorting.xml_sample (rev 0)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-Table_sorting-External_sorting.xml_sample 2010-11-17 04:50:22 UTC (rev 20063)
@@ -0,0 +1,32 @@
+<rich:dataTable value="#{dataTableScrollerBean.allCars}"
+ var="category" rows="20" id="table" reRender="ds2"
+ sortPriority="#{sortingBean.prioritList}">
+ <rich:column id="make" sortBy="#{category.make}"
+ sortOrder="#{sortingBean.makeDirection}" selfSorted="false">
+ <f:facet name="header">
+ <h:outputText styleClass="headerText" value="Make" />
+ </f:facet>
+ <h:outputText value="#{category.make}" />
+ </rich:column>
+ <rich:column id="model" sortBy="#{category.model}"
+ sortOrder="#{sortingBean.modelDirection}" selfSorted="false">
+ <f:facet name="header">
+ <h:outputText styleClass="headerText" value="Model" />
+ </f:facet>
+ <h:outputText value="#{category.model}" />
+ </rich:column>
+ <rich:column id="price" sortBy="#{category.price}"
+ sortOrder="#{sortingBean.priceDirection}" selfSorted="false">
+ <f:facet name="header">
+ <h:outputText styleClass="headerText" value="Price" />
+ </f:facet>
+ <h:outputText value="#{category.price}" />
+ </rich:column>
+ <rich:column id="mileage" sortBy="#{category.mileage}"
+ sortOrder="#{sortingBean.mileageDirection}" selfSorted="false">
+ <f:facet name="header">
+ <h:outputText styleClass="headerText" value="Mileage" />
+ </f:facet>
+ <h:outputText value="#{category.mileage}" />
+ </rich:column>
+</rich:dataTable>
Added: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/figu-Component_Reference-Table_sorting-Basic_sorting.png
===================================================================
(Binary files differ)
Property changes on: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/figu-Component_Reference-Table_sorting-Basic_sorting.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/figu-Component_Reference-Table_sorting-External_sorting.png
===================================================================
(Binary files differ)
Property changes on: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/figu-Component_Reference-Table_sorting-External_sorting.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
14 years, 1 month
JBoss Rich Faces SVN: r20062 - in branches/RF-8742-1/ui/validator: api/src/main/java/org/richfaces/javascript and 11 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-11-16 19:13:58 -0500 (Tue, 16 Nov 2010)
New Revision: 20062
Added:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientScriptService.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientSideScript.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryFunction.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryResource.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptNotFoundException.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientScriptServiceImpl.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java
Removed:
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientScriptService.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientSideScript.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryFunction.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryResource.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScript.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScriptString.java
branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ScriptNotFoundException.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientScriptServiceImpl.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientServiceConfigParser.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/LibraryFunctionImplementation.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ClientScriptServiceTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ServiceConfigParserTest.java
Modified:
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java
branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIValidatorScriptCollectionTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java
Log:
CODING IN PROGRESS - issue RF-9799: CSV code review
https://jira.jboss.org/browse/RF-9799
Copied: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientScriptService.java (from rev 20061, branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientScriptService.java)
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientScriptService.java (rev 0)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientScriptService.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -0,0 +1,45 @@
+/*
+ * $Id$
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.javascript;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * <p class="changed_added_4_0">This interface describes service that determines JavaScript module and function
+ * for Java corresponded version ( both Converter and Validator )</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface ClientScriptService {
+
+ /**
+ * <p class="changed_added_4_0">Get description for client-side version of Java implementation</p>
+ * @param facesContext TODO
+ * @param javaClass either Converter or Validator class.
+ * @return description of client-side script.
+ * @throws ScriptNotFoundException if no JavaScript code associated with Java class.
+ */
+ LibraryFunction getScript(FacesContext facesContext, Class<?> javaClass) throws ScriptNotFoundException;
+
+}
Property changes on: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientScriptService.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientSideScript.java (from rev 20061, branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientSideScript.java)
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientSideScript.java (rev 0)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientSideScript.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -0,0 +1,26 @@
+/**
+ *
+ */
+package org.richfaces.javascript;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation describes client-side version of Converter/validator.
+ * @author asmirnov
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.TYPE)
+public @interface ClientSideScript {
+
+ String library() default "";
+
+ String resource();
+
+ String function();
+
+}
Property changes on: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ClientSideScript.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryFunction.java (from rev 20061, branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryFunction.java)
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryFunction.java (rev 0)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryFunction.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -0,0 +1,39 @@
+/*
+ * $Id$
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.javascript;
+
+/**
+ * <p class="changed_added_4_0">
+ * This class contains information about JavaScript function in external library ( resource )
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface LibraryFunction extends LibraryScript {
+
+
+ String getName();
+
+}
Property changes on: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryFunction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryResource.java (from rev 20061, branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryResource.java)
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryResource.java (rev 0)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryResource.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -0,0 +1,103 @@
+package org.richfaces.javascript;
+
+import java.util.LinkedHashSet;
+
+
+import com.google.common.collect.Sets;
+
+/**
+ * This class represent information about external JavaScript library as JSF resource
+ *
+ * @author asmirnov
+ *
+ */
+public class LibraryResource {
+
+ private final String library;
+
+ private final String resourceName;
+
+ /**
+ * @param library
+ * @param resourceName
+ */
+ public LibraryResource(String library, String resourceName) {
+ this.library = library;
+ this.resourceName = resourceName;
+ }
+
+ /**
+ * @return the library
+ */
+ public String getLibrary() {
+ return library;
+ }
+
+ /**
+ * @return the resourceName
+ */
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((library == null) ? 0 : library.hashCode());
+ result = prime * result + ((resourceName == null) ? 0 : resourceName.hashCode());
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ LibraryResource other = (LibraryResource) obj;
+ if (library == null) {
+ if (other.library != null) {
+ return false;
+ }
+ } else if (!library.equals(other.library)) {
+ return false;
+ }
+ if (resourceName == null) {
+ if (other.resourceName != null) {
+ return false;
+ }
+ } else if (!resourceName.equals(other.resourceName)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return getLibrary()+':'+getResourceName();
+ }
+
+ public static Iterable<LibraryResource> of(Iterable<LibraryScriptString> scripts){
+ LinkedHashSet<LibraryResource> resources = Sets.newLinkedHashSet();
+ for (LibraryScriptString scriptString : scripts) {
+ resources.add(scriptString.getResource());
+ }
+ return resources;
+ }
+}
\ No newline at end of file
Property changes on: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryResource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java (from rev 20061, branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScript.java)
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java (rev 0)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -0,0 +1,38 @@
+/*
+ * $Id$
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.richfaces.javascript;
+
+/**
+ * <p class="changed_added_4_0">
+ * This class contains information about JavaScript associated with JSF object ( converter or validator )
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface LibraryScript {
+
+ LibraryResource getResource();
+
+}
Property changes on: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScript.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java (from rev 20061, branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScriptString.java)
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java (rev 0)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -0,0 +1,13 @@
+package org.richfaces.javascript;
+
+import org.ajax4jsf.javascript.ScriptString;
+
+/**
+ * This interface describes JavaScript object with possible dependent resource.
+ * @author asmirnov
+ *
+ */
+public interface LibraryScriptString extends LibraryScript, ScriptString {
+
+
+}
\ No newline at end of file
Property changes on: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/LibraryScriptString.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptNotFoundException.java (from rev 20061, branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ScriptNotFoundException.java)
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptNotFoundException.java (rev 0)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptNotFoundException.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -0,0 +1,24 @@
+package org.richfaces.javascript;
+
+public class ScriptNotFoundException extends Exception {
+
+ public ScriptNotFoundException() {
+ // TODO Auto-generated constructor stub
+ }
+
+ public ScriptNotFoundException(String message) {
+ super(message);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ScriptNotFoundException(Throwable cause) {
+ super(cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public ScriptNotFoundException(String message, Throwable cause) {
+ super(message, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+}
Property changes on: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/javascript/ScriptNotFoundException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientScriptService.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientScriptService.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientScriptService.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -1,45 +0,0 @@
-/*
- * $Id$
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.richfaces.validator;
-
-import javax.faces.context.FacesContext;
-
-/**
- * <p class="changed_added_4_0">This interface describes service that determines JavaScript module and function
- * for Java corresponded version ( both Converter and Validator )</p>
- * @author asmirnov(a)exadel.com
- *
- */
-public interface ClientScriptService {
-
- /**
- * <p class="changed_added_4_0">Get description for client-side version of Java implementation</p>
- * @param facesContext TODO
- * @param javaClass either Converter or Validator class.
- * @return description of client-side script.
- * @throws ScriptNotFoundException if no JavaScript code associated with Java class.
- */
- LibraryFunction getScript(FacesContext facesContext, Class<?> javaClass) throws ScriptNotFoundException;
-
-}
Deleted: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientSideScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientSideScript.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ClientSideScript.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -1,26 +0,0 @@
-/**
- *
- */
-package org.richfaces.validator;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation describes client-side version of Converter/validator.
- * @author asmirnov
- *
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.TYPE)
-public @interface ClientSideScript {
-
- String library() default "";
-
- String resource();
-
- String function();
-
-}
Deleted: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryFunction.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryFunction.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryFunction.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -1,39 +0,0 @@
-/*
- * $Id$
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.richfaces.validator;
-
-/**
- * <p class="changed_added_4_0">
- * This class contains information about JavaScript function in external library ( resource )
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public interface LibraryFunction extends LibraryScript {
-
-
- String getName();
-
-}
Deleted: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryResource.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryResource.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryResource.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -1,103 +0,0 @@
-package org.richfaces.validator;
-
-import java.util.LinkedHashSet;
-
-
-import com.google.common.collect.Sets;
-
-/**
- * This class represent information about external JavaScript library as JSF resource
- *
- * @author asmirnov
- *
- */
-public class LibraryResource {
-
- private final String library;
-
- private final String resourceName;
-
- /**
- * @param library
- * @param resourceName
- */
- public LibraryResource(String library, String resourceName) {
- this.library = library;
- this.resourceName = resourceName;
- }
-
- /**
- * @return the library
- */
- public String getLibrary() {
- return library;
- }
-
- /**
- * @return the resourceName
- */
- public String getResourceName() {
- return resourceName;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((library == null) ? 0 : library.hashCode());
- result = prime * result + ((resourceName == null) ? 0 : resourceName.hashCode());
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- LibraryResource other = (LibraryResource) obj;
- if (library == null) {
- if (other.library != null) {
- return false;
- }
- } else if (!library.equals(other.library)) {
- return false;
- }
- if (resourceName == null) {
- if (other.resourceName != null) {
- return false;
- }
- } else if (!resourceName.equals(other.resourceName)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return getLibrary()+':'+getResourceName();
- }
-
- public static Iterable<LibraryResource> of(Iterable<LibraryScriptString> scripts){
- LinkedHashSet<LibraryResource> resources = Sets.newLinkedHashSet();
- for (LibraryScriptString scriptString : scripts) {
- resources.add(scriptString.getResource());
- }
- return resources;
- }
-}
\ No newline at end of file
Deleted: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScript.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScript.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -1,38 +0,0 @@
-/*
- * $Id$
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.richfaces.validator;
-
-/**
- * <p class="changed_added_4_0">
- * This class contains information about JavaScript associated with JSF object ( converter or validator )
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public interface LibraryScript {
-
- LibraryResource getResource();
-
-}
Deleted: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScriptString.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScriptString.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/LibraryScriptString.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -1,13 +0,0 @@
-package org.richfaces.validator;
-
-import org.ajax4jsf.javascript.ScriptString;
-
-/**
- * This interface describes JavaScript object with possible dependent resource.
- * @author asmirnov
- *
- */
-public interface LibraryScriptString extends LibraryScript, ScriptString {
-
-
-}
\ No newline at end of file
Deleted: branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ScriptNotFoundException.java
===================================================================
--- branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ScriptNotFoundException.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/api/src/main/java/org/richfaces/validator/ScriptNotFoundException.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -1,24 +0,0 @@
-package org.richfaces.validator;
-
-public class ScriptNotFoundException extends Exception {
-
- public ScriptNotFoundException() {
- // TODO Auto-generated constructor stub
- }
-
- public ScriptNotFoundException(String message) {
- super(message);
- // TODO Auto-generated constructor stub
- }
-
- public ScriptNotFoundException(Throwable cause) {
- super(cause);
- // TODO Auto-generated constructor stub
- }
-
- public ScriptNotFoundException(String message, Throwable cause) {
- super(message, cause);
- // TODO Auto-generated constructor stub
- }
-
-}
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/application/ValidatorModule.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -28,19 +28,19 @@
import javax.validation.ValidationException;
import org.richfaces.el.ValueExpressionAnalayserImpl;
+import org.richfaces.javascript.ClientScriptService;
+import org.richfaces.javascript.ClientScriptServiceImpl;
+import org.richfaces.javascript.ClientServiceConfigParser;
+import org.richfaces.javascript.LibraryFunction;
import org.richfaces.validator.BeanValidator;
import org.richfaces.validator.BeanValidatorFactory;
import org.richfaces.validator.BeanValidatorService;
import org.richfaces.validator.BeanValidatorServiceImpl;
-import org.richfaces.validator.ClientScriptService;
-import org.richfaces.validator.ClientScriptServiceImpl;
-import org.richfaces.validator.ClientServiceConfigParser;
import org.richfaces.validator.ConverterServiceImpl;
import org.richfaces.validator.DummyBeanValidatorService;
import org.richfaces.validator.FacesConverterService;
import org.richfaces.validator.FacesValidatorService;
import org.richfaces.validator.FacesValidatorServiceImpl;
-import org.richfaces.validator.LibraryFunction;
import org.richfaces.validator.NullValidator;
import org.richfaces.validator.ObjectValidator;
import org.richfaces.validator.RichFacesBeanValidatorFactory;
Copied: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientScriptServiceImpl.java (from rev 20061, branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientScriptServiceImpl.java)
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientScriptServiceImpl.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientScriptServiceImpl.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -0,0 +1,74 @@
+/**
+ *
+ */
+package org.richfaces.javascript;
+
+import java.util.Map;
+
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.component.util.Strings;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ClientScriptServiceImpl implements ClientScriptService {
+
+ private static final String TEXT_JAVASCRIPT = "text/javascript";
+
+ private static final String ORG_RICHFACES_CSV = "org.richfaces.csv";
+
+ private final Map<Class<?>, LibraryFunction> defaultMapping;
+
+ public ClientScriptServiceImpl(Map<Class<?>, LibraryFunction> defaultMapping) {
+ this.defaultMapping = defaultMapping;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.validator.ClientScriptService#getScript(java.lang.Class)
+ */
+ public LibraryFunction getScript(FacesContext facesContext, Class<?> javaClass) throws ScriptNotFoundException {
+ if (null == facesContext || null == javaClass) {
+ throw new NullPointerException();
+ }
+ LibraryFunction function;
+ try {
+ function = getScriptResource(facesContext, javaClass);
+ } catch (ScriptNotFoundException e) {
+ if (defaultMapping.containsKey(javaClass)) {
+ function = defaultMapping.get(javaClass);
+ } else {
+ function = getScriptFromAnnotation(javaClass);
+ }
+ }
+ return function;
+ }
+
+ private LibraryFunction getScriptFromAnnotation(Class<?> javaClass) throws ScriptNotFoundException {
+ if (javaClass.isAnnotationPresent(ClientSideScript.class)) {
+ ClientSideScript clientSideScript = javaClass.getAnnotation(ClientSideScript.class);
+ return new LibraryFunctionImplementation(clientSideScript.library(), clientSideScript.resource(), clientSideScript.function());
+ } else {
+ throw new ScriptNotFoundException();
+ }
+ }
+
+ private LibraryFunction getScriptResource(FacesContext facesContext, Class<?> javaClass)
+ throws ScriptNotFoundException {
+ ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
+ String resourceName = javaClass.getSimpleName() + ".js";
+ Resource facesResource = resourceHandler.createResource(resourceName, ORG_RICHFACES_CSV, TEXT_JAVASCRIPT);
+ if (null != facesResource) {
+ final String functionName = Strings.firstToLowerCase(javaClass.getSimpleName());
+ return new LibraryFunctionImplementation(ORG_RICHFACES_CSV,resourceName, functionName);
+ } else {
+ throw new ScriptNotFoundException();
+ }
+ }
+
+}
Property changes on: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientScriptServiceImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java (from rev 20061, branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientServiceConfigParser.java)
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -0,0 +1,67 @@
+/**
+ *
+ */
+package org.richfaces.javascript;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.xml.bind.JAXB;
+
+import org.richfaces.validator.model.ClientSideScripts;
+import org.richfaces.validator.model.Component;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.Maps;
+
+/**
+ * @author asmirnov
+ *
+ */
+public final class ClientServiceConfigParser {
+
+ private ClientServiceConfigParser() {
+ }
+
+ public static Map<Class<?>, LibraryFunction> parseConfig(String name) {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (null == loader) {
+ loader = ClientServiceConfigParser.class.getClassLoader();
+ }
+ Builder<Class<?>, LibraryFunction> resultBuilder = ImmutableMap.builder();
+ try {
+ Enumeration<URL> resources = loader.getResources(name);
+ while (resources.hasMoreElements()) {
+ URL url = (URL) resources.nextElement();
+ resultBuilder.putAll(parse(loader, url));
+ }
+ } catch (IOException e) {
+ return Collections.emptyMap();
+ }
+ return resultBuilder.build();
+ }
+
+ static Map<Class<?>, LibraryFunction> parse(ClassLoader loader, URL url) {
+ Map<Class<?>, LibraryFunction> result = Maps.newHashMap();
+ try {
+ ClientSideScripts clientSideScripts = JAXB.unmarshal(url, ClientSideScripts.class);
+ for (Component component : clientSideScripts.getComponent()) {
+ Class<?> componentClass = loader.loadClass(component.getType());
+ LibraryFunctionImplementation function = new LibraryFunctionImplementation(component.getLibrary(),
+ component.getResource(), component.getFunction());
+ result.put(componentClass, function);
+ }
+ } catch (ClassNotFoundException e) {
+ throw new FacesException("Class for component not found",e);
+ } catch (Exception e) {
+ throw new FacesException("Error parsing config file "+url,e);
+ }
+ return result;
+ }
+
+}
Property changes on: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java (from rev 20061, branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/LibraryFunctionImplementation.java)
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -0,0 +1,25 @@
+package org.richfaces.javascript;
+
+
+final class LibraryFunctionImplementation implements LibraryFunction {
+ private final LibraryResource library;
+ private final String functionName;
+
+ LibraryFunctionImplementation(LibraryResource library, String functionName) {
+ this.library = library;
+ this.functionName = functionName;
+ }
+
+ LibraryFunctionImplementation(String library, String resource, String functionName) {
+ this.library = new LibraryResource(library, resource);
+ this.functionName = functionName;
+ }
+
+ public LibraryResource getResource() {
+ return library;
+ }
+
+ public String getName() {
+ return functionName;
+ }
+}
\ No newline at end of file
Property changes on: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/javascript/LibraryFunctionImplementation.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -3,7 +3,7 @@
import java.util.Collection;
import java.util.Collections;
-import org.richfaces.validator.LibraryResource;
+import org.richfaces.javascript.LibraryResource;
public class AjaxOnlyScript extends ValidatorScriptBase {
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -2,7 +2,7 @@
import java.util.Collection;
-import org.richfaces.validator.LibraryScriptString;
+import org.richfaces.javascript.LibraryScriptString;
public class ClientAndAjaxScript extends ClientOnlyScript{
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -3,8 +3,8 @@
import java.util.Collection;
import java.util.LinkedHashSet;
-import org.richfaces.validator.LibraryResource;
-import org.richfaces.validator.LibraryScriptString;
+import org.richfaces.javascript.LibraryResource;
+import org.richfaces.javascript.LibraryScriptString;
import com.google.common.collect.Sets;
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -24,12 +24,12 @@
import org.richfaces.component.UIValidatorScript;
import org.richfaces.component.behavior.ClientValidatorBehavior;
import org.richfaces.component.behavior.ConverterNotFoundException;
-import org.richfaces.validator.ClientScriptService;
+import org.richfaces.javascript.ClientScriptService;
+import org.richfaces.javascript.LibraryFunction;
+import org.richfaces.javascript.LibraryScriptString;
+import org.richfaces.javascript.ScriptNotFoundException;
import org.richfaces.validator.ConverterDescriptor;
import org.richfaces.validator.FacesObjectDescriptor;
-import org.richfaces.validator.LibraryFunction;
-import org.richfaces.validator.LibraryScriptString;
-import org.richfaces.validator.ScriptNotFoundException;
import org.richfaces.validator.ValidatorDescriptor;
import com.google.common.collect.Lists;
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ComponentValidatorScript.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -3,7 +3,7 @@
import java.util.Collection;
import org.ajax4jsf.javascript.ScriptString;
-import org.richfaces.validator.LibraryResource;
+import org.richfaces.javascript.LibraryResource;
public interface ComponentValidatorScript extends ScriptString {
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -24,9 +24,9 @@
package org.richfaces.renderkit.html;
import org.ajax4jsf.javascript.JSFunction;
-import org.richfaces.validator.LibraryResource;
-import org.richfaces.validator.LibraryFunction;
-import org.richfaces.validator.LibraryScriptString;
+import org.richfaces.javascript.LibraryFunction;
+import org.richfaces.javascript.LibraryResource;
+import org.richfaces.javascript.LibraryScriptString;
/**
* <p class="changed_added_4_0">
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/NullConverterScript.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -4,8 +4,8 @@
package org.richfaces.renderkit.html;
import org.ajax4jsf.javascript.JSLiteral;
-import org.richfaces.validator.LibraryResource;
-import org.richfaces.validator.LibraryScriptString;
+import org.richfaces.javascript.LibraryResource;
+import org.richfaces.javascript.LibraryScriptString;
/**
* This class represents "dummy" converter call ( just refference to "value" variable )
Modified: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptRenderer.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -16,7 +16,7 @@
import javax.faces.render.Renderer;
import org.richfaces.component.UIValidatorScript;
-import org.richfaces.validator.LibraryResource;
+import org.richfaces.javascript.LibraryResource;
import com.google.common.collect.Sets;
Deleted: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientScriptServiceImpl.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientScriptServiceImpl.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientScriptServiceImpl.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -1,74 +0,0 @@
-/**
- *
- */
-package org.richfaces.validator;
-
-import java.util.Map;
-
-import javax.faces.application.Resource;
-import javax.faces.application.ResourceHandler;
-import javax.faces.context.FacesContext;
-
-import org.richfaces.component.util.Strings;
-
-/**
- * @author asmirnov
- *
- */
-public class ClientScriptServiceImpl implements ClientScriptService {
-
- private static final String TEXT_JAVASCRIPT = "text/javascript";
-
- private static final String ORG_RICHFACES_CSV = "org.richfaces.csv";
-
- private final Map<Class<?>, LibraryFunction> defaultMapping;
-
- public ClientScriptServiceImpl(Map<Class<?>, LibraryFunction> defaultMapping) {
- this.defaultMapping = defaultMapping;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.validator.ClientScriptService#getScript(java.lang.Class)
- */
- public LibraryFunction getScript(FacesContext facesContext, Class<?> javaClass) throws ScriptNotFoundException {
- if (null == facesContext || null == javaClass) {
- throw new NullPointerException();
- }
- LibraryFunction function;
- try {
- function = getScriptResource(facesContext, javaClass);
- } catch (ScriptNotFoundException e) {
- if (defaultMapping.containsKey(javaClass)) {
- function = defaultMapping.get(javaClass);
- } else {
- function = getScriptFromAnnotation(javaClass);
- }
- }
- return function;
- }
-
- private LibraryFunction getScriptFromAnnotation(Class<?> javaClass) throws ScriptNotFoundException {
- if (javaClass.isAnnotationPresent(ClientSideScript.class)) {
- ClientSideScript clientSideScript = javaClass.getAnnotation(ClientSideScript.class);
- return new LibraryFunctionImplementation(clientSideScript.library(), clientSideScript.resource(), clientSideScript.function());
- } else {
- throw new ScriptNotFoundException();
- }
- }
-
- private LibraryFunction getScriptResource(FacesContext facesContext, Class<?> javaClass)
- throws ScriptNotFoundException {
- ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
- String resourceName = javaClass.getSimpleName() + ".js";
- Resource facesResource = resourceHandler.createResource(resourceName, ORG_RICHFACES_CSV, TEXT_JAVASCRIPT);
- if (null != facesResource) {
- final String functionName = Strings.firstToLowerCase(javaClass.getSimpleName());
- return new LibraryFunctionImplementation(ORG_RICHFACES_CSV,resourceName, functionName);
- } else {
- throw new ScriptNotFoundException();
- }
- }
-
-}
Deleted: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientServiceConfigParser.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientServiceConfigParser.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/ClientServiceConfigParser.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -1,67 +0,0 @@
-/**
- *
- */
-package org.richfaces.validator;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Map;
-
-import javax.faces.FacesException;
-import javax.xml.bind.JAXB;
-
-import org.richfaces.validator.model.ClientSideScripts;
-import org.richfaces.validator.model.Component;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMap.Builder;
-import com.google.common.collect.Maps;
-
-/**
- * @author asmirnov
- *
- */
-public final class ClientServiceConfigParser {
-
- private ClientServiceConfigParser() {
- }
-
- public static Map<Class<?>, LibraryFunction> parseConfig(String name) {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- if (null == loader) {
- loader = ClientServiceConfigParser.class.getClassLoader();
- }
- Builder<Class<?>, LibraryFunction> resultBuilder = ImmutableMap.builder();
- try {
- Enumeration<URL> resources = loader.getResources(name);
- while (resources.hasMoreElements()) {
- URL url = (URL) resources.nextElement();
- resultBuilder.putAll(parse(loader, url));
- }
- } catch (IOException e) {
- return Collections.emptyMap();
- }
- return resultBuilder.build();
- }
-
- static Map<Class<?>, LibraryFunction> parse(ClassLoader loader, URL url) {
- Map<Class<?>, LibraryFunction> result = Maps.newHashMap();
- try {
- ClientSideScripts clientSideScripts = JAXB.unmarshal(url, ClientSideScripts.class);
- for (Component component : clientSideScripts.getComponent()) {
- Class<?> componentClass = loader.loadClass(component.getType());
- LibraryFunctionImplementation function = new LibraryFunctionImplementation(component.getLibrary(),
- component.getResource(), component.getFunction());
- result.put(componentClass, function);
- }
- } catch (ClassNotFoundException e) {
- throw new FacesException("Class for component not found",e);
- } catch (Exception e) {
- throw new FacesException("Error parsing config file "+url,e);
- }
- return result;
- }
-
-}
Deleted: branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/LibraryFunctionImplementation.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/LibraryFunctionImplementation.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/main/java/org/richfaces/validator/LibraryFunctionImplementation.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -1,24 +0,0 @@
-package org.richfaces.validator;
-
-final class LibraryFunctionImplementation implements LibraryFunction {
- private final LibraryResource library;
- private final String functionName;
-
- LibraryFunctionImplementation(LibraryResource library, String functionName) {
- this.library = library;
- this.functionName = functionName;
- }
-
- LibraryFunctionImplementation(String library, String resource, String functionName) {
- this.library = new LibraryResource(library, resource);
- this.functionName = functionName;
- }
-
- public LibraryResource getResource() {
- return library;
- }
-
- public String getName() {
- return functionName;
- }
-}
\ No newline at end of file
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Bean.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -9,8 +9,8 @@
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
+import org.richfaces.javascript.LibraryResource;
import org.richfaces.renderkit.html.ComponentValidatorScript;
-import org.richfaces.validator.LibraryResource;
/**
* @author asmirnov
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/Script.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -1,7 +1,7 @@
package org.richfaces.component;
-import org.richfaces.validator.LibraryResource;
-import org.richfaces.validator.LibraryScriptString;
+import org.richfaces.javascript.LibraryResource;
+import org.richfaces.javascript.LibraryScriptString;
final class Script implements LibraryScriptString {
private final String name;
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIValidatorScriptCollectionTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIValidatorScriptCollectionTest.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/component/UIValidatorScriptCollectionTest.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -6,10 +6,10 @@
import java.util.Collection;
import org.junit.Test;
+import org.richfaces.javascript.LibraryResource;
+import org.richfaces.javascript.LibraryScriptString;
import org.richfaces.renderkit.html.ClientOnlyScript;
import org.richfaces.renderkit.html.ComponentValidatorScript;
-import org.richfaces.validator.LibraryResource;
-import org.richfaces.validator.LibraryScriptString;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
Copied: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java (from rev 20061, branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ClientScriptServiceTest.java)
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -0,0 +1,126 @@
+/**
+ *
+ */
+package org.richfaces.javascript;
+
+import static org.easymock.EasyMock.expect;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
+import java.util.Map;
+
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.validation.constraints.Max;
+
+import org.jboss.test.faces.mock.Environment;
+import org.jboss.test.faces.mock.Environment.Feature;
+import org.jboss.test.faces.mock.Mock;
+import org.jboss.test.faces.mock.MockController;
+import org.jboss.test.faces.mock.MockFacesEnvironment;
+import org.jboss.test.faces.mock.MockTestRunner;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.richfaces.javascript.ClientScriptServiceImpl;
+import org.richfaces.javascript.LibraryFunction;
+import org.richfaces.javascript.ScriptNotFoundException;
+import org.richfaces.validator.ValidatorWithFacesResource;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * @author asmirnov
+ *
+ */
+(a)RunWith(MockTestRunner.class)
+public class ClientScriptServiceTest {
+
+ private static final String TEXT_JAVASCRIPT = "text/javascript";
+
+ private static final String ORG_RICHFACES_CSV = "org.richfaces.csv";
+
+ private static final String RESOURCE_NAME = ValidatorWithFacesResource.class.getSimpleName() + ".js";
+
+ @Mock
+ @Environment({ Feature.APPLICATION })
+ private MockFacesEnvironment environment;
+
+ @Mock
+ private ResourceHandler resourceHandler;
+
+ private MockController controller;
+
+ @Mock
+ private Resource resource;
+
+ @Mock
+ private LibraryFunction function;
+
+ private ClientScriptServiceImpl serviceImpl;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ expect(environment.getApplication().getResourceHandler()).andStubReturn(resourceHandler);
+ Map<Class<?>, LibraryFunction> defaultMapping = ImmutableMap
+ .<Class<?>, LibraryFunction> of(Max.class, function);
+ serviceImpl = new ClientScriptServiceImpl(defaultMapping);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ controller.verify();
+ controller.release();
+ }
+
+ /**
+ * Test method for {@link org.richfaces.javascript.ClientScriptServiceImpl#getScript(FacesContext, java.lang.Class)}.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGetScriptAsJsfResource() throws Exception {
+ LibraryFunction script = getScript(resource, ValidatorWithFacesResource.class);
+ assertEquals(RESOURCE_NAME, script.getResource().getResourceName());
+ assertEquals(ORG_RICHFACES_CSV, script.getResource().getLibrary());
+ assertEquals("validatorWithFacesResource", script.getName());
+ }
+
+ @Test
+ public void testGetScriptFromAnnotation() throws Exception {
+ LibraryFunction script = getScript(null, ValidatorWithFacesResource.class);
+ assertEquals("baz.js", script.getResource().getResourceName());
+ assertEquals("bar", script.getResource().getLibrary());
+ assertEquals("foo", script.getName());
+ }
+
+ @Test
+ public void testGetScriptFromDefaultMapping() throws Exception {
+ LibraryFunction script = getScript(null, Max.class);
+ assertSame(function, script);
+ }
+
+ @Test
+ public void testGetScriptOverrideAnnotation() throws Exception {
+ Map<Class<?>, LibraryFunction> defaultMapping = ImmutableMap.<Class<?>, LibraryFunction> of(
+ ValidatorWithFacesResource.class, function);
+ serviceImpl = new ClientScriptServiceImpl(defaultMapping);
+ LibraryFunction script = getScript(null, ValidatorWithFacesResource.class);
+ assertSame(function, script);
+ }
+
+ private LibraryFunction getScript(Resource resource, Class<?> serverSideType) throws ScriptNotFoundException {
+ expect(resourceHandler.createResource(serverSideType.getSimpleName() + ".js", ORG_RICHFACES_CSV, TEXT_JAVASCRIPT)).andReturn(resource);
+ controller.replay();
+ LibraryFunction script = serviceImpl.getScript(environment.getFacesContext(), serverSideType);
+ return script;
+ }
+
+}
Property changes on: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ClientScriptServiceTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java (from rev 20061, branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ServiceConfigParserTest.java)
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java (rev 0)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -0,0 +1,45 @@
+package org.richfaces.javascript;
+
+import static org.junit.Assert.*;
+
+import java.util.Map;
+
+import javax.faces.FacesException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.richfaces.javascript.ClientServiceConfigParser;
+import org.richfaces.javascript.LibraryFunction;
+
+public class ServiceConfigParserTest {
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testParseConfig() {
+ Map<Class<?>, LibraryFunction> parseConfig = ClientServiceConfigParser.parseConfig("csv.xml");
+ assertEquals(2, parseConfig.size());
+ assertTrue(parseConfig.containsKey(String.class));
+ LibraryFunction libraryFunction = parseConfig.get(String.class);
+ assertEquals("stringConverter", libraryFunction.getName());
+ assertEquals("csv.js", libraryFunction.getResource().getResourceName());
+ assertEquals("org.richfaces", libraryFunction.getResource().getLibrary());
+ }
+
+ @Test(expected=FacesException.class)
+ public void testParseBadConfig() {
+ Map<Class<?>, LibraryFunction> parseConfig = ClientServiceConfigParser.parseConfig("badcsv.xml");
+ }
+ @Test()
+ public void testParseNoConfig() {
+ Map<Class<?>, LibraryFunction> parseConfig = ClientServiceConfigParser.parseConfig("non-exists-csv.xml");
+ assertEquals(0, parseConfig.size());
+ }
+}
Property changes on: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -18,11 +18,11 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.application.ServiceTracker;
-import org.richfaces.validator.ClientScriptService;
+import org.richfaces.javascript.ClientScriptService;
+import org.richfaces.javascript.LibraryFunction;
+import org.richfaces.javascript.LibraryScriptString;
+import org.richfaces.javascript.ScriptNotFoundException;
import org.richfaces.validator.ConverterDescriptor;
-import org.richfaces.validator.LibraryFunction;
-import org.richfaces.validator.LibraryScriptString;
-import org.richfaces.validator.ScriptNotFoundException;
import org.richfaces.validator.ValidatorDescriptor;
import com.google.common.collect.Iterables;
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -27,12 +27,12 @@
import org.jboss.test.faces.mock.MockTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.richfaces.javascript.LibraryFunction;
+import org.richfaces.javascript.LibraryResource;
+import org.richfaces.javascript.LibraryScriptString;
+import org.richfaces.javascript.ScriptNotFoundException;
import org.richfaces.validator.ConverterDescriptor;
import org.richfaces.validator.FacesObjectDescriptor;
-import org.richfaces.validator.LibraryFunction;
-import org.richfaces.validator.LibraryResource;
-import org.richfaces.validator.LibraryScriptString;
-import org.richfaces.validator.ScriptNotFoundException;
import org.richfaces.validator.ValidatorDescriptor;
import com.google.common.collect.Lists;
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererTestBase.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -7,7 +7,7 @@
import org.jboss.test.faces.mock.Mock;
import org.richfaces.component.behavior.BehaviorTestBase;
import org.richfaces.component.behavior.ClientValidatorBehavior;
-import org.richfaces.validator.LibraryResource;
+import org.richfaces.javascript.LibraryResource;
import com.google.common.collect.ImmutableMap;
Deleted: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ClientScriptServiceTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ClientScriptServiceTest.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ClientScriptServiceTest.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -1,122 +0,0 @@
-/**
- *
- */
-package org.richfaces.validator;
-
-import static org.easymock.EasyMock.expect;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-
-import java.util.Map;
-
-import javax.faces.application.Resource;
-import javax.faces.application.ResourceHandler;
-import javax.validation.constraints.Max;
-
-import org.jboss.test.faces.mock.Environment;
-import org.jboss.test.faces.mock.Environment.Feature;
-import org.jboss.test.faces.mock.Mock;
-import org.jboss.test.faces.mock.MockController;
-import org.jboss.test.faces.mock.MockFacesEnvironment;
-import org.jboss.test.faces.mock.MockTestRunner;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- * @author asmirnov
- *
- */
-(a)RunWith(MockTestRunner.class)
-public class ClientScriptServiceTest {
-
- private static final String TEXT_JAVASCRIPT = "text/javascript";
-
- private static final String ORG_RICHFACES_CSV = "org.richfaces.csv";
-
- private static final String RESOURCE_NAME = ValidatorWithFacesResource.class.getSimpleName() + ".js";
-
- @Mock
- @Environment({ Feature.APPLICATION })
- private MockFacesEnvironment environment;
-
- @Mock
- private ResourceHandler resourceHandler;
-
- private MockController controller;
-
- @Mock
- private Resource resource;
-
- @Mock
- private LibraryFunction function;
-
- private ClientScriptServiceImpl serviceImpl;
-
- /**
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- expect(environment.getApplication().getResourceHandler()).andStubReturn(resourceHandler);
- Map<Class<?>, LibraryFunction> defaultMapping = ImmutableMap
- .<Class<?>, LibraryFunction> of(Max.class, function);
- serviceImpl = new ClientScriptServiceImpl(defaultMapping);
- }
-
- /**
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- controller.verify();
- controller.release();
- }
-
- /**
- * Test method for {@link org.richfaces.validator.ClientScriptServiceImpl#getScript(FacesContext, java.lang.Class)}.
- *
- * @throws Exception
- */
- @Test
- public void testGetScriptAsJsfResource() throws Exception {
- LibraryFunction script = getScript(resource, ValidatorWithFacesResource.class);
- assertEquals(RESOURCE_NAME, script.getResource().getResourceName());
- assertEquals(ORG_RICHFACES_CSV, script.getResource().getLibrary());
- assertEquals("validatorWithFacesResource", script.getName());
- }
-
- @Test
- public void testGetScriptFromAnnotation() throws Exception {
- LibraryFunction script = getScript(null, ValidatorWithFacesResource.class);
- assertEquals("baz.js", script.getResource().getResourceName());
- assertEquals("bar", script.getResource().getLibrary());
- assertEquals("foo", script.getName());
- }
-
- @Test
- public void testGetScriptFromDefaultMapping() throws Exception {
- LibraryFunction script = getScript(null, Max.class);
- assertSame(function, script);
- }
-
- @Test
- public void testGetScriptOverrideAnnotation() throws Exception {
- Map<Class<?>, LibraryFunction> defaultMapping = ImmutableMap.<Class<?>, LibraryFunction> of(
- ValidatorWithFacesResource.class, function);
- serviceImpl = new ClientScriptServiceImpl(defaultMapping);
- LibraryFunction script = getScript(null, ValidatorWithFacesResource.class);
- assertSame(function, script);
- }
-
- private LibraryFunction getScript(Resource resource, Class<?> serverSideType) throws ScriptNotFoundException {
- expect(resourceHandler.createResource(serverSideType.getSimpleName() + ".js", ORG_RICHFACES_CSV, TEXT_JAVASCRIPT)).andReturn(resource);
- controller.replay();
- LibraryFunction script = serviceImpl.getScript(environment.getFacesContext(), serverSideType);
- return script;
- }
-
-}
Deleted: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ServiceConfigParserTest.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ServiceConfigParserTest.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ServiceConfigParserTest.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -1,43 +0,0 @@
-package org.richfaces.validator;
-
-import static org.junit.Assert.*;
-
-import java.util.Map;
-
-import javax.faces.FacesException;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-public class ServiceConfigParserTest {
-
- @Before
- public void setUp() throws Exception {
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testParseConfig() {
- Map<Class<?>, LibraryFunction> parseConfig = ClientServiceConfigParser.parseConfig("csv.xml");
- assertEquals(2, parseConfig.size());
- assertTrue(parseConfig.containsKey(String.class));
- LibraryFunction libraryFunction = parseConfig.get(String.class);
- assertEquals("stringConverter", libraryFunction.getName());
- assertEquals("csv.js", libraryFunction.getResource().getResourceName());
- assertEquals("org.richfaces", libraryFunction.getResource().getLibrary());
- }
-
- @Test(expected=FacesException.class)
- public void testParseBadConfig() {
- Map<Class<?>, LibraryFunction> parseConfig = ClientServiceConfigParser.parseConfig("badcsv.xml");
- }
- @Test()
- public void testParseNoConfig() {
- Map<Class<?>, LibraryFunction> parseConfig = ClientServiceConfigParser.parseConfig("non-exists-csv.xml");
- assertEquals(0, parseConfig.size());
- }
-}
Modified: branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java
===================================================================
--- branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java 2010-11-16 17:05:51 UTC (rev 20061)
+++ branches/RF-8742-1/ui/validator/ui/src/test/java/org/richfaces/validator/ValidatorWithFacesResource.java 2010-11-17 00:13:58 UTC (rev 20062)
@@ -1,5 +1,7 @@
package org.richfaces.validator;
+import org.richfaces.javascript.ClientSideScript;
+
@ClientSideScript(function="foo",library="bar",resource="baz.js")
public class ValidatorWithFacesResource {
14 years, 1 month
JBoss Rich Faces SVN: r20061 - in modules/tests/metamer/trunk: application/src/main/webapp/resources/metamer and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-11-16 12:05:51 -0500 (Tue, 16 Nov 2010)
New Revision: 20061
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jPoll/simple.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTimeWatcher.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/resources/script/clientTime-updateDifference.js
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestInterval.java
Log:
a4j:poll - improved sample to use metamer:clientTimeWatcher and added default values (RFPL-293)
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/a4jPoll/simple.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/a4jPoll/simple.xhtml 2010-11-16 17:04:02 UTC (rev 20060)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/a4jPoll/simple.xhtml 2010-11-16 17:05:51 UTC (rev 20061)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!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:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"
xmlns:metamer="http://java.sun.com/jsf/composite/metamer">
<!--
@@ -33,6 +33,7 @@
<f:viewParam name="templates" value="#{templateBean.templates}">
<f:converter converterId="templatesListConverter" />
</f:viewParam>
+ <f:viewParam name="enabled" value="#{a4jPollBean.attributes['enabled'].value}" />
</f:metadata>
<h:outputStylesheet library="css" name="a4jPoll.css"/>
<h:outputScript library="script" name="date-format.js" />
@@ -51,37 +52,47 @@
immediate="#{a4jPollBean.attributes['immediate'].value}"
interval="#{a4jPollBean.attributes['interval'].value}"
onbeforedomupdate="#{a4jPollBean.attributes['onbeforedomupdate'].value}"
- onbegin="#{a4jPollBean.attributes['onbegin'].value}"
- oncomplete="#{a4jPollBean.attributes['oncomplete'].value}"
- ontimer="#{a4jPollBean.attributes['ontimer'].value}"
+ onbegin="#{rich:element('timeWatcher:grid')}.begin(); #{a4jPollBean.attributes['onbegin'].value}"
+ oncomplete="#{rich:element('timeWatcher:grid')}.complete(); #{a4jPollBean.attributes['oncomplete'].value}"
+ ontimer="#{rich:element('timeWatcher:grid')}.event(); #{rich:element('timeWatcher:grid')}.difference(); #{a4jPollBean.attributes['ontimer'].value}"
rendered="#{a4jPollBean.attributes['rendered'].value}"
value="#{a4jPollBean.attributes['value'].value}"
>
- <a4j:ajax event="timer" render="time" />
+ <a4j:ajax event="timer" render="output" />
</a4j:poll>
</h:panelGroup>
- <h:panelGroup id="time">
+ <script type="text/javascript">
+ //<![CDATA[
+ var lastCounter = null;
+ //]]>
+ </script>
+
+ <h:panelGroup id="output">
<h:outputText value="Server: " />
<h:outputText id="serverDate" value="#{a4jPollBean.date}" title="#{a4jPollBean.date.time}">
<f:convertDateTime pattern="dd.MM.yyyy HH:mm:ss.SSS" />
</h:outputText>
***
- <h:outputText value="Client: " />
- <h:outputText id="clientDate" value="" title="" />
- <script type="text/javascript">
+ <h:outputText value="Counter: " />
+ <h:outputText id="outputCounter" value="#{a4jPollBean.counter}"/>
+ <span id="counterDelta"></span>
+ <script type="text/javascript">
//<![CDATA[
- var now = new Date();
- jQuery("div.content span[id$=clientDate]")
- .text(now.format("UTC:dd.mm.yyyy HH:MM:ss.l", false))
- .attr("title", now.getTime());
+ var counterDelta = document.getElementById('counterDelta');
+ document.title = lastCounter;
+ if (lastCounter) {
+ counterDelta.innerHTML = '(delta: ' + (#{a4jPollBean.counter} - lastCounter) + ')';
+ }
+ lastCounter = #{a4jPollBean.counter};
//]]>
</script>
- ***
- <h:outputText value="Counter: " />
- <h:outputText id="outputCounter" value="#{a4jPollBean.counter}"/>
</h:panelGroup>
+
+ <metamer:clientTimeWatcher id="timeWatcher" reverseOrder="true" />
</ui:define>
+
+
<ui:define name="outOfTemplateAfter">
<metamer:attributes value="#{a4jPollBean.attributes}" id="attributes" />
Modified: modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTimeWatcher.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTimeWatcher.xhtml 2010-11-16 17:04:02 UTC (rev 20060)
+++ modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTimeWatcher.xhtml 2010-11-16 17:05:51 UTC (rev 20061)
@@ -11,6 +11,7 @@
<h:body>
<composite:interface>
<composite:attribute name="events" type="java.lang.Integer" default="1" />
+ <composite:attribute name="reverseOrder" type="java.lang.Boolean" default="false" shortDescription="use when you are getting negative values since event time is always lower than begin times" />
</composite:interface>
<composite:implementation>
@@ -52,7 +53,7 @@
var differenceElement = #{rich:element('difference')};
var beginTimeElement = this.getBeginElement();
var eventTimeId = "#{rich:clientId('event1')}".replace(/1$/, "");
- Metamer.ClientTime.updateDifference(differenceElement, beginTimeElement, eventTimeId);
+ Metamer.ClientTime.updateDifference(differenceElement, beginTimeElement, eventTimeId, #{cc.attrs.reverseOrder});
}
grid.getBeginElement = function() {
Modified: 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 2010-11-16 17:04:02 UTC (rev 20060)
+++ modules/tests/metamer/trunk/application/src/main/webapp/resources/script/clientTime-updateDifference.js 2010-11-16 17:05:51 UTC (rev 20061)
@@ -6,7 +6,7 @@
Metamer.ClientTime = {};
}
-Metamer.ClientTime.updateDifference = function (differenceTimeElement, beginTimeElement, eventTimeId) {
+Metamer.ClientTime.updateDifference = function (differenceTimeElement, beginTimeElement, eventTimeId, reverseOrder) {
var maxEventTime = 0;
for (var i = 1; i < 100; i++) {
@@ -24,5 +24,11 @@
var beginTime = parseInt(beginTimeElement.title);
- jQuery(differenceTimeElement).text(beginTime - maxEventTime);
+ var difference = beginTime - maxEventTime;
+
+ if (reverseOrder) {
+ difference = 0 - difference;
+ }
+
+ jQuery(differenceTimeElement).text(difference);
}
\ No newline at end of file
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestInterval.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestInterval.java 2010-11-16 17:04:02 UTC (rev 20060)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jPoll/TestInterval.java 2010-11-16 17:05:51 UTC (rev 20061)
@@ -56,7 +56,7 @@
IntervalAttributes attributes = new IntervalAttributes();
JQueryLocator time = pjq("span[id$=time]");
- AttributeLocator<?> clientTime = pjq("span[id$=clientDate]").getAttribute(Attribute.TITLE);
+ AttributeLocator<?> clientTime = pjq("span[id$=event1:outputTime]").getAttribute(Attribute.TITLE);
long startTime;
@@ -65,7 +65,7 @@
@Override
public URL getTestUrl() {
- return buildUrl(contextPath, "faces/components/a4jPoll/simple.xhtml");
+ return buildUrl(contextPath, "faces/components/a4jPoll/simple.xhtml?enabled=false");
}
@BeforeMethod
14 years, 1 month
JBoss Rich Faces SVN: r20060 - in modules/tests/metamer/trunk/application/src/main: webapp/components/a4jAttachQueue and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-11-16 12:04:02 -0500 (Tue, 16 Nov 2010)
New Revision: 20060
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JQueueBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jAttachQueue/extending.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jAttachQueue/nested.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jAttachQueue/nestedExtension.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jQueue/formQueue.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jQueue/globalQueue.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTimeWatcher.xhtml
Log:
used metamer:clientTimeWatcher in all queue/attachQueue samples (RFPL-923)
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JQueueBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JQueueBean.java 2010-11-16 17:02:12 UTC (rev 20059)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JQueueBean.java 2010-11-16 17:04:02 UTC (rev 20060)
@@ -62,6 +62,7 @@
// initialize attributes
attributes = Attributes.getUIComponentAttributes(UIQueue.class, getClass());
attributes.setAttribute("rendered", true);
+ attributes.setAttribute("requestDelay", 750);
// hidden attributes
attributes.remove("status");
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/a4jAttachQueue/extending.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/a4jAttachQueue/extending.xhtml 2010-11-16 17:02:12 UTC (rev 20059)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/a4jAttachQueue/extending.xhtml 2010-11-16 17:04:02 UTC (rev 20060)
@@ -39,13 +39,6 @@
function add(element) {
element.innerHTML = 1 + parseInt(element.innerHTML);
}
-
- function updateDifferenceTime() {
- var eventTime = parseInt(jQuery(#{rich:element('eventTime:outputTime')}).attr('title'));
- var beginTime = parseInt(jQuery(#{rich:element('beginTime:outputTime')}).attr('title'));
-
- jQuery(#{rich:element('differenceTime')}).text(beginTime - eventTime);
- }
</script>
</ui:define>
@@ -68,8 +61,8 @@
<fieldset>
<legend><a4j:ajax event="keyup" ></legend>
- <a4j:ajax event="keyup" render="output1, output2" execute="@form" onbegin="add(#{rich:element('requests')}); refresh(#{rich:element('beginTime:outputTime')}); "
- oncomplete="refresh(#{rich:element('completeTime:outputTime')}); updateDifferenceTime();" onbeforedomupdate="add(#{rich:element('updates')});">
+ <a4j:ajax event="keyup" render="output1, output2" execute="@form" onbegin="add(#{rich:element('requests')}); #{rich:element('timeWatcher:grid')}.begin(); "
+ oncomplete="#{rich:element('timeWatcher:grid')}.complete(); #{rich:element('timeWatcher:grid')}.difference();" onbeforedomupdate="add(#{rich:element('updates')});">
<div><a4j:attachQueue /></div>
@@ -84,8 +77,8 @@
requestGroupingId="#{a4jAttachQueueBean.attributes['requestGroupingId'].value}"
timeout="#{a4jAttachQueueBean.attributes['timeout'].value}"/>
- <h:inputText id="input1" value="#{a4jAttachQueueBean.text1}" onkeyup="add(#{rich:element('events')}); refresh(#{rich:element('eventTime:outputTime')});"/>
- <h:inputText id="input2" value="#{a4jAttachQueueBean.text2}" onkeyup="add(#{rich:element('events')}); refresh(#{rich:element('eventTime:outputTime')});"/>
+ <h:inputText id="input1" value="#{a4jAttachQueueBean.text1}" onkeyup="add(#{rich:element('events')}); #{rich:element('timeWatcher:grid')}.event();"/>
+ <h:inputText id="input2" value="#{a4jAttachQueueBean.text2}" onkeyup="add(#{rich:element('events')}); #{rich:element('timeWatcher:grid')}.event();"/>
</a4j:ajax>
</fieldset>
@@ -101,15 +94,9 @@
<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="eventTime" label="Event Time:" />
- <metamer:clientTime id="beginTime" label="Begin Time:" />
- <metamer:clientTime id="completeTime" label="Complete Time:" />
- </h:panelGrid>
+ <metamer:clientTimeWatcher id="timeWatcher" />
</ui:define>
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 17:02:12 UTC (rev 20059)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/a4jAttachQueue/nested.xhtml 2010-11-16 17:04:02 UTC (rev 20060)
@@ -105,8 +105,6 @@
<h:outputText value="0" id="updates" />
</h:panelGrid>
-
-
<metamer:clientTimeWatcher id="timeWatcher" events="2" />
</ui:define>
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/a4jAttachQueue/nestedExtension.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/a4jAttachQueue/nestedExtension.xhtml 2010-11-16 17:02:12 UTC (rev 20059)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/a4jAttachQueue/nestedExtension.xhtml 2010-11-16 17:04:02 UTC (rev 20060)
@@ -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>
@@ -71,9 +62,9 @@
<legend><a4j:ajax event='click' ... ></legend>
<a4j:ajax event="click" execute="@form"
- onbegin="add(#{rich:element('requests')}); refresh(#{rich:element('beginTime:outputTime')}); "
+ onbegin="add(#{rich:element('requests')}); #{rich:element('timeWatcher:grid')}.begin(); "
onbeforedomupdate="add(#{rich:element('updates')});"
- oncomplete="refresh(#{rich:element('completeTime:outputTime')}); updateDifferenceTime(); ">
+ oncomplete="#{rich:element('timeWatcher:grid')}.complete(); #{rich:element('timeWatcher:grid')}.difference(); ">
<div><a4j:attachQueue id="..1" /></div>
@@ -89,25 +80,25 @@
timeout="#{a4jAttachQueueBean.attributes['timeout'].value}" />
<h:inputText id="input1" value="#{a4jAttachQueueBean.text1}"
- onclick="add(#{rich:element('events1')}); refresh(#{rich:element('eventTime1:outputTime')}); " />
+ onclick="add(#{rich:element('events1')}); #{rich:element('timeWatcher:grid')}.event(1); " />
<a4j:commandButton
- onclick="add(#{rich:element('events1')}); refresh(#{rich:element('eventTime1:outputTime')}); "
+ onclick="add(#{rich:element('events1')}); #{rich:element('timeWatcher:grid')}.event(1); "
id="a4jCommandButton1" value="First button" />
<fieldset>
<legend><a4j:ajax event='valueChange' ... ></legend>
<a4j:ajax event="valueChange" render="output2" execute="@form"
- onbegin="add(#{rich:element('requests')}); refresh(#{rich:element('beginTime:outputTime')}); "
+ onbegin="add(#{rich:element('requests')}); #{rich:element('timeWatcher:grid')}.begin(); "
onbeforedomupdate="add(#{rich:element('updates')});"
- oncomplete="refresh(#{rich:element('completeTime:outputTime')}); updateDifferenceTime();">
+ oncomplete="#{rich:element('timeWatcher:grid')}.complete(); #{rich:element('timeWatcher:grid')}.difference(); ">
<h:inputText id="input2" value="#{a4jAttachQueueBean.text2}"
- onclick="add(#{rich:element('events1')}); refresh(#{rich:element('eventTime1:outputTime')}); "
- onchange="add(#{rich:element('events2')}); refresh(#{rich:element('eventTime2:outputTime')}); " />
+ onclick="add(#{rich:element('events1')}); #{rich:element('timeWatcher:grid')}.event(1); "
+ onchange="add(#{rich:element('events2')}); #{rich:element('timeWatcher:grid')}.event(2); " />
<a4j:commandButton
id="a4jCommandButton2" value="First button"
- onclick="add(#{rich:element('events1')}); refresh(#{rich:element('eventTime1:outputTime')}); " />
+ onclick="add(#{rich:element('events1')}); #{rich:element('timeWatcher:grid')}.event(1); " />
<div><a4j:attachQueue id="..2" /></div>
@@ -144,15 +135,10 @@
<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:" />
+ <metamer:clientTimeWatcher id="timeWatcher" events="2" />
</h:panelGrid>
</ui:define>
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/a4jQueue/formQueue.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/a4jQueue/formQueue.xhtml 2010-11-16 17:02:12 UTC (rev 20059)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/a4jQueue/formQueue.xhtml 2010-11-16 17:04:02 UTC (rev 20060)
@@ -83,16 +83,16 @@
<h:panelGrid columns="2">
<h:outputText value="Event 1:" />
- <h:inputText id="input1" value="#{a4jQueueBean.text}" onkeypress="add(#{rich:element('events1')}); refresh(#{rich:element('eventTime1:outputTime')}); "
+ <h:inputText id="input1" value="#{a4jQueueBean.text}" onkeypress="add(#{rich:element('events1')}); #{rich:element('timeWatcher:grid')}.event(1); "
disabled="#{not (facesContext.maximumSeverity==null)}">
- <a4j:ajax event="keypress" onbegin="add(#{rich:element('requests')}); refresh(#{rich:element('beginTime:outputTime')}); " render="outtext"
- oncomplete="refresh(#{rich:element('completeTime:outputTime')});" onbeforedomupdate="add(#{rich:element('updates')}); " />
+ <a4j:ajax event="keypress" onbegin="add(#{rich:element('requests')}); #{rich:element('timeWatcher:grid')}.begin(); " render="outtext"
+ oncomplete="#{rich:element('timeWatcher:grid')}.complete(); #{rich:element('timeWatcher:grid')}.difference();" onbeforedomupdate="add(#{rich:element('updates')}); " />
</h:inputText>
<h:outputText value="Event 2:" />
- <h:inputText id="input2" value="#{a4jQueueBean.text}" onkeypress="add(#{rich:element('events2')}); refresh(#{rich:element('eventTime2:outputTime')}); "
+ <h:inputText id="input2" value="#{a4jQueueBean.text}" onkeypress="add(#{rich:element('events2')}); #{rich:element('timeWatcher:grid')}.event(2) "
disabled="#{not (facesContext.maximumSeverity==null)}">
- <a4j:ajax event="keypress" onbegin="add(#{rich:element('requests')}); refresh(#{rich:element('beginTime:outputTime')}); " render="outtext"
- oncomplete="refresh(#{rich:element('completeTime:outputTime')});" onbeforedomupdate="add(#{rich:element('updates')}); " />
+ <a4j:ajax event="keypress" onbegin="add(#{rich:element('requests')}); #{rich:element('timeWatcher:grid')}.begin(); " render="outtext"
+ oncomplete="#{rich:element('timeWatcher:grid')}.complete(); #{rich:element('timeWatcher:grid')}.difference();" onbeforedomupdate="add(#{rich:element('updates')}); " />
</h:inputText>
@@ -109,12 +109,8 @@
</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" />
+
</h:form>
</rich:panel>
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/a4jQueue/globalQueue.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/a4jQueue/globalQueue.xhtml 2010-11-16 17:02:12 UTC (rev 20059)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/a4jQueue/globalQueue.xhtml 2010-11-16 17:04:02 UTC (rev 20060)
@@ -65,9 +65,9 @@
<h:form id="form" name="queueTestForm">
<h:panelGrid columns="2">
<h:outputText value="Type here:" />
- <h:inputText id="input1" value="#{a4jQueueBean.text}" onkeypress="add(#{rich:element('events1')}); refresh(#{rich:element('eventTime1:outputTime')}); "
+ <h:inputText id="input1" value="#{a4jQueueBean.text}" onkeypress="add(#{rich:element('events1')}); #{rich:element('timeWatcher:grid')}.event(); "
disabled="#{not (facesContext.maximumSeverity==null)}">
- <a4j:ajax event="keypress" onbegin="add(#{rich:element('requests')}); refresh(#{rich:element('beginTime:outputTime')}); " render="outtext" oncomplete="refresh(#{rich:element('completeTime:outputTime')}); "
+ <a4j:ajax event="keypress" onbegin="add(#{rich:element('requests')}); #{rich:element('timeWatcher:grid')}.begin(); " render="outtext" oncomplete="#{rich:element('timeWatcher:grid')}.complete(); #{rich:element('timeWatcher:grid')}.difference(); "
onbeforedomupdate="add(#{rich:element('updates')});"/>
</h:inputText>
@@ -82,11 +82,7 @@
</h:panelGrid>
- <h:panelGrid columns="1">
- <metamer:clientTime id="eventTime1" label="Event Time:" />
- <metamer:clientTime id="beginTime" label="Begin Time:" />
- <metamer:clientTime id="completeTime" label="Complete Time:" />
- </h:panelGrid>
+ <metamer:clientTimeWatcher id="timeWatcher" />
</h:form>
Modified: modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTimeWatcher.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTimeWatcher.xhtml 2010-11-16 17:02:12 UTC (rev 20059)
+++ modules/tests/metamer/trunk/application/src/main/webapp/resources/metamer/clientTimeWatcher.xhtml 2010-11-16 17:04:02 UTC (rev 20060)
@@ -51,7 +51,7 @@
grid.difference = function() {
var differenceElement = #{rich:element('difference')};
var beginTimeElement = this.getBeginElement();
- var eventTimeId = "#{rich:clientId('event1')}".replace("1", "");
+ var eventTimeId = "#{rich:clientId('event1')}".replace(/1$/, "");
Metamer.ClientTime.updateDifference(differenceElement, beginTimeElement, eventTimeId);
}
14 years, 1 month
JBoss Rich Faces SVN: r20059 - in modules/tests/metamer/trunk: application/src/main/webapp/resources/metamer and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
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));
14 years, 1 month
JBoss Rich Faces SVN: r20058 - modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-11-16 11:16:33 -0500 (Tue, 16 Nov 2010)
New Revision: 20058
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JPollBean.java
Log:
added defaults for a4j:poll - simple (enabled: true, interval: 2500)
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JPollBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JPollBean.java 2010-11-16 16:14:39 UTC (rev 20057)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/A4JPollBean.java 2010-11-16 16:16:33 UTC (rev 20058)
@@ -58,8 +58,9 @@
logger.debug("initializing bean " + getClass().getName());
attributes = Attributes.getUIComponentAttributes(UIPoll.class, getClass());
+ attributes.setAttribute("enabled", true);
attributes.setAttribute("rendered", true);
- attributes.setAttribute("interval", 5000);
+ attributes.setAttribute("interval", 2500);
attributes.setAttribute("action", "increaseCounterAction");
attributes.setAttribute("actionListener", "increaseCounterActionListener");
}
14 years, 1 month
JBoss Rich Faces SVN: r20057 - in modules/tests/metamer/trunk: ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-11-16 11:14:39 -0500 (Tue, 16 Nov 2010)
New Revision: 20057
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataGrid/simple.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataGrid.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/AbstractDataGridTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestSimple.java
Log:
rich:dataGrid - added testNoDataFaces (needs to move checkbox near the component since it references grid's id in @render) (RFPL-672, RFPL-744)
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richDataGrid/simple.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richDataGrid/simple.xhtml 2010-11-16 01:39:10 UTC (rev 20056)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richDataGrid/simple.xhtml 2010-11-16 16:14:39 UTC (rev 20057)
@@ -37,16 +37,14 @@
<h:outputStylesheet library="css" name="richDataGrid.css" />
</ui:define>
- <ui:define name="outOfTemplateBefore">
- <br/>
- <h:outputText value="Show data in table: " />
- <h:selectBooleanCheckbox id="noDataCheckbox" value="#{richDataGridBean.state}">
- <a4j:ajax render="richDataGrid"/>
- </h:selectBooleanCheckbox>
- <br/><br/>
- </ui:define>
-
<ui:define name="component">
+ <h:panelGroup layout="div">
+ <h:outputText value="Show data in table: " />
+ <h:selectBooleanCheckbox id="noDataCheckbox" value="#{richDataGridBean.state}">
+ <a4j:ajax render="richDataGrid"/>
+ </h:selectBooleanCheckbox>
+ </h:panelGroup>
+
<rich:dataGrid id="richDataGrid"
captionFacet="#{richDataGridBean.attributes['captionFacet'].value}"
columns="#{richDataGridBean.attributes['columns'].value}"
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataGrid.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataGrid.java 2010-11-16 01:39:10 UTC (rev 20056)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataGrid.java 2010-11-16 16:14:39 UTC (rev 20057)
@@ -22,6 +22,7 @@
package org.richfaces.tests.metamer.ftest.model;
import static org.jboss.test.selenium.locator.reference.ReferencedLocator.ref;
+import static org.jboss.test.selenium.locator.reference.ReferencedLocator.referenceInferred;
import static org.jboss.test.selenium.locator.LocatorFactory.*;
import java.util.Iterator;
@@ -42,6 +43,7 @@
ReferencedLocator<JQueryLocator> rows = ref(root, "> tbody.rf-dg-body > tr.rf-dg-r");
JQueryLocator rowToNonEmptyElement = jq("td.rf-dg-c:not(:empty)");
JQueryLocator rowToElement = jq("td.rf-dg-c");
+ ReferencedLocator<JQueryLocator> noDataElement = ref(root, "td.rf-dg-nd-c");
public DataGrid(JQueryLocator root) {
super(root);
@@ -74,4 +76,8 @@
public Iterator<JQueryLocator> iterateElements() {
return rows.getDescendants(rowToNonEmptyElement).iterator();
}
+
+ public boolean isNoData() {
+ return selenium.isElementPresent(noDataElement);
+ }
}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/AbstractDataGridTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/AbstractDataGridTest.java 2010-11-16 01:39:10 UTC (rev 20056)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/AbstractDataGridTest.java 2010-11-16 16:14:39 UTC (rev 20057)
@@ -57,6 +57,7 @@
JQueryLocator attributeColumns = pjq("input[id$=columnsInput]");
JQueryLocator attributeElements = pjq("input[id$=elementsInput]");
JQueryLocator attributeFirst = pjq("input[id$=firstInput]");
+ JQueryLocator attributeShowData = pjq("input:checkbox[id$=noDataCheckbox]");
DataGrid dataGrid = new DataGrid(jq("table.rf-dg[id$=richDataGrid]"));
@@ -159,7 +160,7 @@
expectedRows = ceil((float) expectedElements / columns);
expectedColumns = columns;
-
+
if (first >= ELEMENTS_TOTAL) {
expectedColumns = 0;
}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestSimple.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestSimple.java 2010-11-16 01:39:10 UTC (rev 20056)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataGrid/TestSimple.java 2010-11-16 16:14:39 UTC (rev 20057)
@@ -22,6 +22,9 @@
package org.richfaces.tests.metamer.ftest.richDataGrid;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
import java.net.URL;
@@ -63,4 +66,13 @@
public void testFirstAttribute() {
verifyGrid();
}
+
+ @Test
+ public void testNoDataFacet() {
+ guardXhr(selenium).click(attributeShowData);
+
+ assertEquals(dataGrid.getColumnCount(), 0);
+ assertEquals(dataGrid.getElementCount(), 0);
+ assertTrue(dataGrid.isNoData());
+ }
}
14 years, 1 month
JBoss Rich Faces SVN: r20056 - in sandbox/trunk/ui/fileupload/ui/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-11-15 20:39:10 -0500 (Mon, 15 Nov 2010)
New Revision: 20056
Added:
sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js
Modified:
sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss
sandbox/trunk/ui/fileupload/ui/src/main/templates/fileupload.template.xml
Log:
RF-9496
Modified: sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss
===================================================================
--- sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss 2010-11-16 00:20:58 UTC (rev 20055)
+++ sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss 2010-11-16 01:39:10 UTC (rev 20056)
@@ -23,7 +23,7 @@
overflow-y: auto;
}
-.rf-fu-btns-lft, .rf-fu-btns-rgh {
+.rf-fu-btns-lft, .rf-fu-btns-rgh, .rf-fu-itm-lft, .rf-fu-itm-rgh {
display: inline-block;
overflow: hidden;
}
@@ -53,13 +53,19 @@
/*TODO Add disabled state for buttons*/
+.rf-fu-btn-add, .rf-fu-btn-uld, .rf-fu-btn-clr, .rf-fu-itm-lbl, .rf-fu-itm-lnk {
+ font-family: '#{richSkin.generalFamilyFont}';
+ font-size: '#{richSkin.generalSizeFont}';
+}
+
+.rf-fu-btn-add, .rf-fu-btn-uld, .rf-fu-btn-clr, .rf-fu-itm-lbl {
+ color: '#{richSkin.generalTextColor}';
+}
+
.rf-fu-btn-add, .rf-fu-btn-uld, .rf-fu-btn-clr {
background-position: 2px 2px;
background-repeat: no-repeat;
- color: '#{richSkin.generalTextColor}';
display: inline-block;
- font-family: '#{richSkin.generalFamilyFont}';
- font-size: '#{richSkin.generalSizeFont}';
padding: 3px 5px 3px 21px;
}
@@ -96,3 +102,26 @@
top: 0;
}
+.rf-fu-itm {
+ border-bottom-color: '#{richSkin.panelBorderColor}';
+ border-bottom-style: solid;
+ border-bottom-width: 1px;
+ padding: 12px;
+ white-space: nowrap;
+}
+
+.rf-fu-itm-lft, .rf-fu-itm-rgh {
+ vertical-align: middle;
+}
+
+.rf-fu-itm-lft {
+ width: 85%;
+}
+
+.rf-fu-itm-rgh {
+ width: 14%;
+}
+
+.rf-fu-itm-lnk {
+ color: '#{richSkin.generalLinkColor}';
+}
\ No newline at end of file
Added: sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js
===================================================================
--- sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js (rev 0)
+++ sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js 2010-11-16 01:39:10 UTC (rev 20056)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+(function(richfaces, jQuery) {
+ richfaces.ui = richfaces.ui || {};
+
+ richfaces.ui.FileUpload = richfaces.BaseComponent.extendClass({
+
+ name: "FileUpload",
+
+ init: function (id) {
+ this.id = id;
+ this.element = jQuery(this.attachToDom());
+ var header = this.element.children(".rf-fu-hdr:first");
+ var buttons = header.children(".rf-fu-btns-lft:first").children(".rf-fu-btn");
+ this.addButton = buttons.first();
+// this.uploadButton = buttons.last();
+// this.clearButton = header.children(".rf-fu-btns-rgh:first").children(".rf-fu-btn:first");
+ this.inputContainer = this.addButton.find(".rf-fu-inp-cntr:first");
+ this.input = this.inputContainer.children("input");
+ this.list = this.element.children(".rf-fu-lst:first");
+ this.cleanInput = this.input.clone();
+ this.addProxy = jQuery.proxy(this.__add, this)
+ this.input.change(this.addProxy);
+ },
+
+ __add: function () {
+ this.input.hide();
+ this.input.unbind("change", this.addProxy);
+ var item = new Item(this.input);
+ this.list.append(item.html());
+ this.input = this.cleanInput.clone();
+ this.inputContainer.append(this.input);
+ this.input.change(this.addProxy);
+ }
+ });
+
+ var Item = function(input) {
+ this.input = input;
+ };
+
+ jQuery.extend(Item.prototype, {
+ html: function() { //TODO Optimize concatenation of strings.
+ return '<div class="rf-fu-itm">'
+ + '<span class="rf-fu-itm-lft">'
+ + '<span class="rf-fu-itm-lbl">' + this.input.val() + '</span>'
+ + '</span>'
+ + '<span class="rf-fu-itm-rgh">'
+ + '<a href="#" class="rf-fu-itm-lnk">Delete</a>'
+ + '</span>'
+ + '</div>';
+ }
+ });
+}(window.RichFaces, jQuery));
Modified: sandbox/trunk/ui/fileupload/ui/src/main/templates/fileupload.template.xml
===================================================================
--- sandbox/trunk/ui/fileupload/ui/src/main/templates/fileupload.template.xml 2010-11-16 00:20:58 UTC (rev 20055)
+++ sandbox/trunk/ui/fileupload/ui/src/main/templates/fileupload.template.xml 2010-11-16 01:39:10 UTC (rev 20056)
@@ -33,6 +33,7 @@
<cdk:renderer-type>org.richfaces.FileUploadRenderer</cdk:renderer-type>
<cdk:resource-dependency library="org.richfaces" name="fileupload.ecss" />
<cdk:resource-dependency library="org.richfaces" name="base-component.reslib" />
+ <cdk:resource-dependency library="org.richfaces" name="fileupload.js" />
</cc:interface>
<cc:implementation>
<div id="#{clientId}" class="rf-fu">
@@ -57,6 +58,7 @@
</span>
</div>
<div class="rf-fu-lst" />
+ <script type="text/javascript">new RichFaces.ui.FileUpload('#{clientId}');</script>
</div>
</cc:implementation>
</cdk:root>
14 years, 1 month