filterExpression with columns - only last column is filterin
mcnig Jul 20, 2009 9:21 AMHello Everybody
When I use a table with rich:column with the attribute filterExpression everything works as it should! But as soon as a use rich:columns with the attribute filterExpression I get a miss behaviour: Only the last column is getting filtered... Is that a feature or a bug???
I have to use columns (or c:foreach which has the same behaviour). Does anybody have an idea how I can get multiple columns filtered?
I use Richfaces 3.3.1 GA. (in a SEAM context) . Thx in advance!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <f:view contentType="text/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:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:fn="http://java.sun.com/jsp/jstl/functions"> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Filter Values Example</title></head> <body><h:form id="mischt"> <h:inputText value="#{filterValBean.filterVal1}"> <a4j:support event="onkeyup" reRender="tableColumns,tableColunn" ignoreDupResponses="true" requestDelay="400" focus="input" /> </h:inputText> <h:inputText value="#{filterValBean.filterVal2}"> <a4j:support event="onkeyup" reRender="tableColumns,tableColunn" ignoreDupResponses="true" requestDelay="400" focus="input" /> </h:inputText> <br /> <br/><hr/><b>rich:columns</b><br/><br/> <rich:dataTable value="#{filterValBean.filterValList}" var="currentRow" id="tableColumns"> <rich:columns value="#{filterValBean.filterValList.get(0)}" var="currentCol" index="index" id="uniqueID#{index}" filterExpression="${fn:containsIgnoreCase(currentRow[index],filterValBean.getFilterValNr(index))}"> <f:facet name="header"><h:outputText value="header #{index}" /></f:facet> <h:outputText value="#{currentRow[index]} (#{filterValBean.getFilterValNr(index)})" /> </rich:columns> </rich:dataTable> <br/><hr/><b>rich:column (2x)</b><br/><br/> <rich:dataTable value="#{filterValBean.filterValList}" var="currentRow" id="tableColunn"> <rich:column filterExpression="${fn:containsIgnoreCase(currentRow[0],filterValBean.getFilterValNr(0))}"> <f:facet name="header"><h:outputText value="header 0" /></f:facet> <h:outputText value="#{currentRow[0]} (#{filterValBean.getFilterValNr(0)})" /> </rich:column> <rich:column filterExpression="${fn:containsIgnoreCase(currentRow[1],filterValBean.getFilterValNr(1))}"> <f:facet name="header"><h:outputText value="header 1" /></f:facet> <h:outputText value="#{currentRow[1]} (#{filterValBean.getFilterValNr(1)})" /> </rich:column> </rich:dataTable> </h:form></body></html> </f:view>
package sandbox.experimental; import java.util.ArrayList; import java.util.List; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; @Name("filterValBean") @Scope(ScopeType.SESSION) public class FilterValBean { private String filterVal1; private String filterVal2; private List< String > filterVals = new ArrayList< String >(); public List< List< String >> getFilterValList() { List< List< String >> filterVals = new ArrayList< List< String > >(); List< String > val; val = new ArrayList< String >(); val.add("hi"); val.add("everybody!"); filterVals.add(val); for (int i = 0; i < 4; i++) { val = new ArrayList< String >(); val.add("hello " + i); val.add("world " + i); filterVals.add(val); } val = new ArrayList< String >(); val.add("Howdy!"); val.add("Terra"); filterVals.add(val); val = new ArrayList< String >(); val.add("goodbye"); val.add("world"); filterVals.add(val); return filterVals; } public String getFilterVal1() { return filterVal1; } public void setFilterVal1(final String filterVal) { this.filterVal1 = filterVal; } public String getFilterVal2() { return filterVal2; } public void setFilterVal2(final String filterVal) { this.filterVal2 = filterVal; } public String getFilterValNr(final int i){ if(i == 0){ //yes, that's a joke ;-) return filterVal1; } return filterVal2; } }