ExtendedDataTable not working nice with filterMethod
granite2009 Mar 29, 2010 4:43 PMI want to change filtering from startWith to contain in extendedDataTable. I got the logic to work but the layout is broken. First the input box is on the first row instead of the second row. Second, sort cannot work at the same time since once I click on the input box, it triggers a sort immediately. Is there anything I should doing to filterMethod works nice with extendedDataTable?
I am using SEAM 2.2, richfaces 3.x, jBoss 5.1 . These code are mostly generated by jBoss tools 3.1 on Eclipse 3.5
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">
<ui:define name="body">
<h:form>
<rich:extendedDataTable id="table" var="form" reRender="datascroller"
value="#{formList.resultList}" rows="10" sortMode="single">
<rich:column sortable="true" sortBy="#{form.id}" label="ID"
filterBy="#{form.id}" filterEvent="onkeyup" width="50px">
<f:facet name="header">Id</f:facet>
#{form.id}
</rich:column>
<rich:column filterMethod="#{formList.filterTitle}" label="Title" width="100px">
<f:facet name="header"><h:outputText value="Title"/></f:facet>
<f:facet name="header2">
<h:inputText value="#{formList.filterValue}">
<a4j:support ajaxSingle="true" requestDelay="500" event="onchange" reRender="table,datascroller"></a4j:support>
</h:inputText>
</f:facet>
<s:link id="form" value="#{form.title}" view="/form.xhtml">
<f:param name="formId" value="#{form.id}" />
</s:link>
<rich:toolTip>Edit</rich:toolTip>
</rich:column>
<f:facet name="footer">
<rich:datascroller id="datascroller" renderIfSinglePage="false"/>
</f:facet>
</rich:extendedDataTable>
</ui:define>
</ui:composition>
@Name("formList")
public class FormList extends EntityQuery<Form>
{
/**
*
*/
private static final long serialVersionUID = 1L;
private String filterValue="";
public FormList()
{
setEjbql("select Form from Form Form");
}
public boolean filterTitle(Object parmForm) {
if (getFilterValue().length()==0) {
return true;
}
Form form = (Form)parmForm;
String title=form.getTitle().toLowerCase();
int i=title.indexOf(this.filterValue.toLowerCase());
if (i>=0) {
return true;
} else {
return false;
}
}
public void setFilterValue(String filterValue) {
this.filterValue = filterValue;
}
public String getFilterValue() {
return filterValue;
}
}