Author: lfryc(a)redhat.com
Date: 2011-01-12 07:56:03 -0500 (Wed, 12 Jan 2011)
New Revision: 20964
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/comparator.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/filtering.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/sorting.xhtml
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichColumnBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/list.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/simple.xhtml
Log:
rich:column - initial samples ready for automation (RFPL-729)
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichColumnBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichColumnBean.java 2011-01-12
12:53:23 UTC (rev 20963)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichColumnBean.java 2011-01-12
12:56:03 UTC (rev 20964)
@@ -22,30 +22,52 @@
package org.richfaces.tests.metamer.bean;
import java.io.Serializable;
+import java.util.Comparator;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
-import javax.faces.bean.SessionScoped;
+import javax.faces.bean.ViewScoped;
+import org.richfaces.component.SortOrder;
import org.richfaces.component.UIColumn;
+import org.richfaces.model.Filter;
import org.richfaces.tests.metamer.Attributes;
+import org.richfaces.tests.metamer.model.Capital;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Managed bean for rich:column
- *
+ *
* @author <a href="mailto:pjha@redhat.com">Prabhat Jha</a>, <a
href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
* @version $Revision$
*/
@ManagedBean(name = "richColumnBean")
-@SessionScoped
+@ViewScoped
public class RichColumnBean implements Serializable {
+ public static final Comparator<Capital> STATE_NAME_LENGTH_COMPARATOR = new
Comparator<Capital>() {
+ @Override
+ public int compare(Capital o1, Capital o2) {
+ return o1.getState().length() - o2.getState().length();
+ }
+ };
+
private static final long serialVersionUID = -1L;
private static Logger logger;
- private Attributes attributes;
-
+
+ private Attributes attributes;
+ private String stateNameToFilter;
+ private SortOrder sortOrder = SortOrder.ascending;
+
+ private final Filter<Capital> stateFilter = new Filter<Capital>() {
+
+ @Override
+ public boolean accept(Capital c) {
+ return c.getState().toLowerCase().contains(stateNameToFilter == null ?
"" : stateNameToFilter.toLowerCase());
+ }
+ };
+
/**
* Initializes the managed bean.
*/
@@ -55,9 +77,18 @@
logger.debug("initializing bean " + getClass().getName());
attributes = Attributes.getComponentAttributesFromFacesConfig(UIColumn.class,
getClass());
- attributes.setAttribute("colspan", 1);
attributes.setAttribute("rendered", true);
- attributes.setAttribute("rowspan", 1);
+ attributes.setAttribute("colspan", 2);
+ attributes.setAttribute("rowspan", 2);
+ attributes.setAttribute("breakRowBefore", true);
+
+ // attributes which needs to be tested another way
+ attributes.remove("filter");
+ attributes.remove("filterValue");
+ attributes.remove("filterExpression");
+ attributes.remove("comparator");
+ attributes.remove("sortBy");
+ attributes.remove("sortOrder");
}
public Attributes getAttributes() {
@@ -68,5 +99,31 @@
this.attributes = attributes;
}
+ public Comparator<Capital> getStateNameLengthComparator() {
+ return STATE_NAME_LENGTH_COMPARATOR;
+ }
+
+ public Filter<Capital> getStateNameFilter() {
+ return stateFilter;
+ }
+ public String getStateNameToFilter() {
+ return stateNameToFilter;
+ }
+
+ public void setStateNameToFilter(String stateNameToFilter) {
+ this.stateNameToFilter = stateNameToFilter;
+ }
+
+ public SortOrder[] getSortOrders() {
+ return SortOrder.values();
+ }
+
+ public void setSortOrder(SortOrder sortOrder) {
+ this.sortOrder = sortOrder;
+ }
+
+ public SortOrder getSortOrder() {
+ return sortOrder;
+ }
}
Copied:
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/comparator.xhtml
(from rev 20961,
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/simple.xhtml)
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/comparator.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/comparator.xhtml 2011-01-12
12:56:03 UTC (rev 20964)
@@ -0,0 +1,83 @@
+<?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:metamer="http://java.sun.com/jsf/composite/metamer"
+
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
+
+ <!--
+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:param name="componentId" value="richDataTable" />
+
+ <ui:define name="head">
+ <f:metadata>
+ <f:viewParam name="templates"
value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ <h:form id="attributes">
+ <fieldset>
+ <h:panelGrid columns="2">
+ <h:outputLabel for="sortOrderInput" value="Sort
Order:" />
+ <h:selectOneRadio id="sortOrderInput"
value="#{richColumnBean.sortOrder}">
+ <f:selectItems value="#{richColumnBean.sortOrders}" />
+ <a4j:ajax render="#{nestedComponentId}" />
+ </h:selectOneRadio>
+ </h:panelGrid>
+ </fieldset>
+ </h:form>
+ </ui:define>
+
+ <ui:define name="component">
+
+ <rich:dataTable id="richDataTable"
+ rendered="true"
+ value="#{model.capitals}"
+ var="record">
+
+ <f:facet name="header">
+ <rich:column>
+ Sorted by custom <tt>comparator</tt>
+ </rich:column>
+ </f:facet>
+
+ <rich:column id="columnState"
comparator="#{richColumnBean.stateNameLengthComparator}"
sortOrder="#{richColumnBean.sortOrder}">
+ <f:facet name="header">State</f:facet>
+ <h:outputText id="state"
value="#{record.state}" />
+ </rich:column>
+
+ <rich:column id="columnCapital">
+ <f:facet name="header">Capital</f:facet>
+ <h:outputText id="capital"
value="#{record.name}" />
+ </rich:column>
+ </rich:dataTable>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/filtering.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/filtering.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/filtering.xhtml 2011-01-12
12:56:03 UTC (rev 20964)
@@ -0,0 +1,103 @@
+<?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:metamer="http://java.sun.com/jsf/composite/metamer"
+
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
+
+ <!--
+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>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ <fieldset>
+ <h:panelGrid columns="2">
+ <h:outputLabel value="Filter State:"
for="stateNameToFilter" />
+ <h:inputText id="stateNameToFilter"
value="#{richColumnBean.stateNameToFilter}">
+ <a4j:ajax event="keyup"
render="#{nestedPrefix}richDataTable1 #{nestedPrefix}richDataTable2" />
+ </h:inputText>
+ </h:panelGrid>
+ </fieldset>
+
+ </ui:define>
+
+ <ui:define name="component">
+
+ <h:panelGrid columns="3">
+ <rich:dataTable id="richDataTable1"
+ rendered="true"
+ value="#{model.capitals}"
+ var="record">
+
+ <f:facet name="header">
+ <rich:column>Filter by <tt>filter</tt></rich:column>
+ </f:facet>
+
+ <rich:column id="columnState1"
filter="#{richColumnBean.stateNameFilter}">
+ <f:facet name="header">State</f:facet>
+ <h:outputText id="state"
value="#{record.state}" />
+ </rich:column>
+
+ <rich:column id="columnCapital1">
+ <f:facet name="header">Capital</f:facet>
+ <h:outputText id="capital"
value="#{record.name}" />
+ </rich:column>
+ </rich:dataTable>
+
+ <rich:dataTable id="richDataTable2"
+ rendered="true"
+ value="#{model.capitals}"
+ var="record">
+
+ <f:facet name="header">
+ <rich:column>Filter by
<tt>filterExpression</tt></rich:column>
+ </f:facet>
+
+ <rich:column id="columnState2"
filterExpression="#{fn:contains(fn:toLowerCase(record.state),
fn:toLowerCase(richColumnBean.stateNameToFilter))}">
+ <f:facet name="header">State</f:facet>
+ <h:outputText id="state"
value="#{record.state}" />
+ </rich:column>
+
+ <rich:column id="columnCapital2">
+ <f:facet name="header">Capital</f:facet>
+ <h:outputText id="capital"
value="#{record.name}" />
+ </rich:column>
+ </rich:dataTable>
+ </h:panelGrid>
+
+
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/list.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/list.xhtml 2011-01-12
12:53:23 UTC (rev 20963)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/list.xhtml 2011-01-12
12:56:03 UTC (rev 20964)
@@ -34,7 +34,19 @@
<metamer:testPageLink id="simple" outcome="simple"
value="Simple">
Simple page that contains a table with two columns
</metamer:testPageLink>
-
+
+ <metamer:testPageLink id="comparator" outcome="comparator"
value="Custom Comparator">
+ Data table with first column with customized sorting (sorted by length of
the state name) using <tt>Comparator<?></tt>
+ </metamer:testPageLink>
+
+ <metamer:testPageLink id="sorting" outcome="sorting"
value="Sorting">
+ Data table with first column with customized sorting (sorted by length of
the state name) using expression
+ </metamer:testPageLink>
+
+ <metamer:testPageLink id="filtering"
outcome="filtering" value="Filtering">
+ Two data tables with first column filtered by custom
<tt>Filter<?></tt> and by expression
+ </metamer:testPageLink>
+
</ui:define>
</ui:composition>
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/simple.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/simple.xhtml 2011-01-12
12:53:23 UTC (rev 20963)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/simple.xhtml 2011-01-12
12:56:03 UTC (rev 20964)
@@ -41,44 +41,34 @@
</ui:define>
<ui:define name="component">
-
<rich:dataTable id="richDataTable"
rendered="true"
value="#{model.capitals}"
rows="5"
var="record">
+ <f:facet name="header">
+ <rich:columnGroup>
+ <rich:column
colspan="#{richColumnBean.attributes['colspan'].value}"><tt>colspan=#{richColumnBean.attributes['colspan'].value}</tt></rich:column>
+ <rich:column
breakRowBefore="#{richColumnBean.attributes['breakRowBefore'].value}"><tt>breakBefore=#{richColumnBean.attributes['breakRowBefore'].value}</tt></rich:column>
+ <rich:column
rowspan="#{richColumnBean.attributes['rowspan'].value}"><tt>rowspan=#{richColumnBean.attributes['rowspan'].value}</tt></rich:column>
+ <rich:column breakRowBefore="true">Dummy</rich:column>
+ <rich:column
breakRowBefore="#{richColumnBean.attributes['rowspan'].value >
1}">Breaked by <tt>rowspan</tt> > 1</rich:column>
+ </rich:columnGroup>
+ </f:facet>
+
<rich:column id="columnState"
-
breakRowBefore="#{richColumnBean.attributes['breakRowBefore'].value}"
-
colspan="#{richColumnBean.attributes['colspan'].value}"
comparator="#{richColumnBean.attributes['comparator'].value}"
filter="#{richColumnBean.attributes['filter'].value}"
filterValue="#{richColumnBean.attributes['filterValue'].value}"
rendered="#{richColumnBean.attributes['rendered'].value}"
-
rowspan="#{richColumnBean.attributes['rowspan'].value}"
sortOrder="#{richColumnBean.attributes['sortOrder'].value}"
- >
- <f:facet name="header">
- <h:outputText id="columnHeaderState"
value="State" />
- </f:facet>
-
+ >
<h:outputText id="state"
value="#{record.state}" />
-
- <f:facet name="footer">
- <h:outputText id="columnFooterState"
value="State" />
- </f:facet>
</rich:column>
<rich:column id="columnCapital">
- <f:facet name="header">
- <h:outputText id="columnHeaderCapital"
value="Capital" />
- </f:facet>
-
<h:outputText id="capital"
value="#{record.name}" />
-
- <f:facet name="footer">
- <h:outputText id="columnFooterCapital"
value="Capital" />
- </f:facet>
</rich:column>
</rich:dataTable>
</ui:define>
Copied:
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/sorting.xhtml
(from rev 20961,
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/simple.xhtml)
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/sorting.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richColumn/sorting.xhtml 2011-01-12
12:56:03 UTC (rev 20964)
@@ -0,0 +1,84 @@
+<?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:metamer="http://java.sun.com/jsf/composite/metamer"
+
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
+
+ <!--
+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:param name="componentId" value="richDataTable" />
+
+ <ui:define name="head">
+ <f:metadata>
+ <f:viewParam name="templates"
value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ <h:form id="attributes">
+ <fieldset>
+ <h:panelGrid columns="2">
+ <h:outputLabel for="sortOrderInput" value="Sort
Order:" />
+ <h:selectOneRadio id="sortOrderInput"
value="#{richColumnBean.sortOrder}">
+ <f:selectItems value="#{richColumnBean.sortOrders}" />
+ <a4j:ajax render="#{nestedComponentId}" />
+ </h:selectOneRadio>
+ </h:panelGrid>
+ </fieldset>
+ </h:form>
+ </ui:define>
+
+ <ui:define name="component">
+
+ <rich:dataTable id="richDataTable"
+ rendered="true"
+ value="#{model.capitals}"
+ var="record">
+
+ <f:facet name="header">
+ <rich:column>
+ <tt>sortBy="\#{fn:length(record.state)}"</tt>
+ </rich:column>
+ </f:facet>
+
+ <rich:column id="columnState"
sortBy="#{fn:length(record.state)}"
sortOrder="#{richColumnBean.sortOrder}">
+ <f:facet name="header">State</f:facet>
+ <h:outputText id="state"
value="#{record.state}" />
+ </rich:column>
+
+ <rich:column id="columnCapital">
+ <f:facet name="header">Capital</f:facet>
+ <h:outputText id="capital"
value="#{record.name}" />
+ </rich:column>
+ </rich:dataTable>
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file