Author: ilya_shaikovsky
Date: 2008-03-26 13:42:39 -0400 (Wed, 26 Mar 2008)
New Revision: 7273
Added:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/filteringFeature/
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/filteringFeature/FilteringBean.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/examples/FilteringBean.java
Modified:
trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/examples/externalFiltering.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/examples/simpleFiltering.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/externalFilteringUsage.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/filteringUsage.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/inplaceInput/examples/controlsCustomization.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature/sortingUsage.xhtml
Log:
filtering example finished
Added:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/filteringFeature/FilteringBean.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/filteringFeature/FilteringBean.java
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/filteringFeature/FilteringBean.java 2008-03-26
17:42:39 UTC (rev 7273)
@@ -0,0 +1,59 @@
+package org.richfaces.demo.filteringFeature;
+
+import java.util.ArrayList;
+
+import javax.faces.model.SelectItem;
+
+import org.richfaces.demo.capitals.Capital;
+
+/**
+ * @author Ilya Shaikovsky
+ *
+ */
+public class FilteringBean {
+
+ private String filterZone = "5";
+ private String filterValue="";
+ private ArrayList<SelectItem> filterZones = new ArrayList<SelectItem>();
+
+ public boolean filterStates(Object current) {
+ Capital currentCapital = (Capital)current;
+ if (filterValue.length()==0) {
+ return true;
+ }
+ if (currentCapital.getState().toLowerCase().startsWith(filterValue.toLowerCase())) {
+ return true;
+ }else {
+ return false;
+ }
+ }
+
+ public FilteringBean() {
+ for (int i = 5; i < 11; i++) {
+ SelectItem select = new SelectItem();
+ select.setLabel("-" + i);
+ select.setValue(i);
+ filterZones.add(select);
+ }
+ }
+
+ public String getFilterValue() {
+ return filterValue;
+ }
+
+ public void setFilterValue(String filterValue) {
+ this.filterValue = filterValue;
+ }
+
+ public String getFilterZone() {
+ return filterZone;
+ }
+
+ public void setFilterZone(String filterZone) {
+ this.filterZone = filterZone;
+ }
+
+ public ArrayList<SelectItem> getFilterZones() {
+ return filterZones;
+ }
+}
Modified: trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml 2008-03-26
17:27:27 UTC (rev 7272)
+++ trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml 2008-03-26
17:42:39 UTC (rev 7273)
@@ -303,6 +303,11 @@
<managed-bean-class>org.richfaces.datatablescroller.SortingBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>filteringBean</managed-bean-name>
+
<managed-bean-class>org.richfaces.demo.filteringFeature.FilteringBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
<navigation-rule>
<from-view-id>/richfaces/include/examples/wstep1.xhtml</from-view-id>
<navigation-case>
Added:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/examples/FilteringBean.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/examples/FilteringBean.java
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/examples/FilteringBean.java 2008-03-26
17:42:39 UTC (rev 7273)
@@ -0,0 +1,59 @@
+package org.richfaces.demo.filteringFeature;
+
+import java.util.ArrayList;
+
+import javax.faces.model.SelectItem;
+
+import org.richfaces.demo.capitals.Capital;
+
+/**
+ * @author Ilya Shaikovsky
+ *
+ */
+public class FilteringBean {
+
+ private String filterZone = "5";
+ private String filterValue="";
+ private ArrayList<SelectItem> filterZones = new ArrayList<SelectItem>();
+
+ public boolean filterStates(Object current) {
+ Capital currentCapital = (Capital)current;
+ if (filterValue.length()==0) {
+ return true;
+ }
+ if (currentCapital.getState().toLowerCase().startsWith(filterValue.toLowerCase())) {
+ return true;
+ }else {
+ return false;
+ }
+ }
+
+ public FilteringBean() {
+ for (int i = 5; i < 11; i++) {
+ SelectItem select = new SelectItem();
+ select.setLabel("-" + i);
+ select.setValue(i);
+ filterZones.add(select);
+ }
+ }
+
+ public String getFilterValue() {
+ return filterValue;
+ }
+
+ public void setFilterValue(String filterValue) {
+ this.filterValue = filterValue;
+ }
+
+ public String getFilterZone() {
+ return filterZone;
+ }
+
+ public void setFilterZone(String filterZone) {
+ this.filterZone = filterZone;
+ }
+
+ public ArrayList<SelectItem> getFilterZones() {
+ return filterZones;
+ }
+}
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/examples/externalFiltering.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/examples/externalFiltering.xhtml 2008-03-26
17:27:27 UTC (rev 7272)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/examples/externalFiltering.xhtml 2008-03-26
17:42:39 UTC (rev 7273)
@@ -1,25 +1,43 @@
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
-
xmlns:ui="http://java.sun.com/jsf/facelets"
-
xmlns:h="http://java.sun.com/jsf/html"
-
xmlns:f="http://java.sun.com/jsf/core"
-
xmlns:a4j="http://richfaces.org/a4j"
-
xmlns:rich="http://richfaces.org/rich">
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich"
+
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<h:form>
- <rich:dataTable value="#{capitalsBean.capitals}" var="cap"
width="500px">
+ <rich:dataTable value="#{capitalsBean.capitals}" var="cap"
id="table">
<f:facet name="header">
- <h:outputText value="Filtering Example"/>
+ <rich:columnGroup>
+ <rich:column colspan="2">
+ <h:outputText value="Filtering Example" />
+ </rich:column>
+ <rich:column breakBefore="true">
+ <h:outputText value="State Name" />
+ </rich:column>
+ <rich:column>
+ <h:outputText value="State Time Zone" />
+ </rich:column>
+ </rich:columnGroup>
</f:facet>
- <rich:column>
+ <rich:column filterMethod="#{filteringBean.filterStates}">
<f:facet name="header">
- <h:graphicImage
value="/images/ico_DataTable.gif"></h:graphicImage>
+ <h:inputText value="#{filteringBean.filterValue}"
id="input">
+ <a4j:support event="onkeyup" reRender="table"
+ ignoreDupResponses="true" requestDelay="700"
focus="input" />
+ </h:inputText>
</f:facet>
- <h:graphicImage value="#{cap.stateFlag}"/>
+ <h:outputText value="#{cap.state}" />
</rich:column>
- <rich:column filterBy="#{cap.state}" filterDefaultLabel="click to
filter">
- <h:outputText value="#{cap.state}"></h:outputText>
- </rich:column>
- <rich:column filterBy="#{cap.name}" filterDefaultLabel="click to
filter">
- <h:outputText value="#{cap.name}"/>
+ <rich:column
+ filterExpression="#{fn:containsIgnoreCase(cap.timeZone,
filteringBean.filterZone)}">
+ <f:facet name="header">
+ <h:selectOneMenu value="#{filteringBean.filterZone}">
+ <f:selectItems value="#{filteringBean.filterZones}" />
+ <a4j:support event="onchange" reRender="table" />
+ </h:selectOneMenu>
+ </f:facet>
+ <h:outputText value="#{cap.timeZone}" />
</rich:column>
</rich:dataTable>
</h:form>
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/examples/simpleFiltering.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/examples/simpleFiltering.xhtml 2008-03-26
17:27:27 UTC (rev 7272)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/examples/simpleFiltering.xhtml 2008-03-26
17:42:39 UTC (rev 7273)
@@ -5,35 +5,29 @@
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:form>
- <style>
- .rich-inplace-view{
- color:gray;
- border-bottom-color:gray;
- }
- .body{
- background-color:red !important;
- }
- </style>
- <input type="text" value="123" style="background :
transparent; border : 0"/>
- <rich:dataTable value="#{capitalsBean.capitals}" var="cap"
width="500px" rows="15">
+ <rich:dataTable value="#{capitalsBean.capitals}" var="cap">
<f:facet name="header">
- <h:outputText value="Filtering Example"/>
+ <rich:columnGroup>
+ <rich:column colspan="2" >
+ <h:outputText value="Filtering Example"/>
+ </rich:column>
+ <rich:column breakBefore="true">
+ <h:outputText value="State Name"/>
+ </rich:column>
+ <rich:column>
+ <h:outputText value="State Capital"/>
+ </rich:column>
+ </rich:columnGroup>
</f:facet>
- <rich:column filterBy="#{cap.state}" filterDefaultLabel="click to
filter">
+ <rich:column filterBy="#{cap.state}" filterEvent="onkeyup">
+ <f:facet name="header">
+ <h:outputText value=" " title="Hack due to bug. Shuold be remoevd
till release"></h:outputText>
+ </f:facet>
<h:outputText value="#{cap.state}"/>
</rich:column>
- <rich:column filterBy="#{cap.name}" filterDefaultLabel="click to
filter">
+ <rich:column filterBy="#{cap.name}" filterEvent="onkeyup">
<h:outputText value="#{cap.name}"/>
</rich:column>
- <rich:column>
- <f:facet name="header">
- <h:outputText value="State time zone:"/>
- </f:facet>
- <h:outputText value="#{cap.timeZone}"/>
- </rich:column>
- <f:facet name="footer">
- <rich:datascroller renderIfSinglePage="false"/>
- </f:facet>
</rich:dataTable>
</h:form>
</ui:composition>
\ No newline at end of file
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/externalFilteringUsage.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/externalFilteringUsage.xhtml 2008-03-26
17:27:27 UTC (rev 7272)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/externalFilteringUsage.xhtml 2008-03-26
17:42:39 UTC (rev 7273)
@@ -8,15 +8,37 @@
<ui:define name="sample">
<p>
- SHORT DESCRIPTION
+ In order to use <b>Filtering Feature</b> of
<b>rich:dataTable</b> with some custom filtering
+ functions and controls one should use next available attributes on columns:
</p>
-
+ <ul>
+ <li>
+ <b>filterExpression</b> - Attribute which allows to define expression
+ evaluated to boolean value. This expression should check if the object
+ satisfies filtering condition.
+ </li>
+ <li>
+ <b>filterMethod</b> - Attribute which should be defined with method
binding.
+ This method should accept on Object parameter and return bioolean value.
+ So, this method also should be used to check if the object satisfies
+ filtering condition.
+ </li>
+ </ul>
+ <p>
+ In next simple example we use <b>filterMethod</b> and
<b>filterExpression</b> for the first
+ and second columns filtering correspondingly.
+ </p>
<div class="sample-container" >
<ui:include
src="/richfaces/filteringFeature/examples/externalFiltering.xhtml"/>
<ui:include src="/templates/include/sourceview.xhtml">
<ui:param name="sourcepath"
value="/richfaces/filteringFeature/examples/externalFiltering.xhtml"/>
</ui:include>
+ <ui:include src="/templates/include/sourceview.xhtml">
+ <ui:param name="sourcepath"
value="/richfaces/filteringFeature/examples/FilteringBean.java"/>
+ <ui:param name="openlabel" value="View FilteringBean.java
Source" />
+ <ui:param name="sourcetype" value="java" />
+ </ui:include>
</div>
<p>
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/filteringUsage.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/filteringUsage.xhtml 2008-03-26
17:27:27 UTC (rev 7272)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature/filteringUsage.xhtml 2008-03-26
17:42:39 UTC (rev 7273)
@@ -6,22 +6,53 @@
xmlns:rich="http://richfaces.org/rich">
<ui:composition template="/templates/component-sample.xhtml">
<ui:define name="sample">
-
+ <style>
+ .top{
+ vertical-align:top;
+ }
+ </style>
+ <p><b>
+ Rich Data Table</b> has columns <b>filtering feature</b> built-in.
Simplest way to add filtering
+ capability is to define <b>filterBy </b>attribute at column you need to
be filterable.
+ </p>
<p>
- SHORT DESCRIPTION
+ In this attribute you should define iterable object property which should be
+ used when filetring performed.
</p>
-
- <div class="sample-container" >
+ <p>
+ In this example you could see that two first columns filtered after corresponding
+ input changed.
+ </p>
+ <h:panelGrid columns="2" columnClasses="top">
+ <div class="sample-container" jsfc="h:panelGroup">
<ui:include
src="/richfaces/filteringFeature/examples/simpleFiltering.xhtml"/>
<ui:include src="/templates/include/sourceview.xhtml">
<ui:param name="sourcepath"
value="/richfaces/filteringFeature/examples/simpleFiltering.xhtml"/>
</ui:include>
</div>
-
- <p>
- DESCRIPTION
- </p>
+ <h:panelGroup>
+ <fieldset>
+ <legend><b>Details of usage</b></legend>
+ <p>
+ In order to get or change current filtering value <b>filterValue
</b>attribute
+ provided. It should be defined with initial filtering value on the page
+ or as value binding to get/change it on server.
+ </p>
+ <p>
+ This is built-in feature. It uses "<b>startsWith</b>"
function to make filtering.
+ </p>
+ <p>
+ If <b>filterBy </b>attribute set - column will render default inputs
with
+ default filtering behaviour
+ </p>
+ <p>
+ In order to change default filtering behaviour - another definition used.
+ An example shown at second tab("External Filtering")
+ </p>
+ </fieldset>
+ </h:panelGroup>
+ </h:panelGrid>
</ui:define>
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature.xhtml 2008-03-26
17:27:27 UTC (rev 7272)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/filteringFeature.xhtml 2008-03-26
17:42:39 UTC (rev 7273)
@@ -11,9 +11,9 @@
<rich:tab label="Built-In Filtering Usage">
<ui:include src="/richfaces/filteringFeature/filteringUsage.xhtml"/>
</rich:tab>
- <ui:include src="/templates/include/tagInfo.xhtml">
- <ui:param name="path" value="rich/filtering"/>
- </ui:include>
+ <rich:tab label="External Filtering Usage">
+ <ui:include
src="/richfaces/filteringFeature/externalFilteringUsage.xhtml"/>
+ </rich:tab>
</rich:tabPanel>
</ui:define>
</ui:composition>
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/inplaceInput/examples/controlsCustomization.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/inplaceInput/examples/controlsCustomization.xhtml 2008-03-26
17:27:27 UTC (rev 7272)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/inplaceInput/examples/controlsCustomization.xhtml 2008-03-26
17:42:39 UTC (rev 7273)
@@ -17,5 +17,4 @@
</rich:inplaceInput>
- <rich:spacer width="100%" height="40px" />
</ui:composition>
\ No newline at end of file
Modified:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature/sortingUsage.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature/sortingUsage.xhtml 2008-03-26
17:27:27 UTC (rev 7272)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/sortingFeature/sortingUsage.xhtml 2008-03-26
17:42:39 UTC (rev 7273)
@@ -9,7 +9,7 @@
<p><b>
Rich Data Table</b> has columns <b>sorting feature</b> built-in.
Simplest way to add sorting
- capability is to define <b>sortBy </b>attribute at column you need to be
sorted.
+ capability is to define <b>sortBy </b>attribute at column you need to be
sortable.
</p>
<p>
In this attribute you should define iterable object property which should be