1

I'm using richfaces 4.0 and I'm adding some column filters on a rich:dataTable. Now, since I'm filtering a column that contains date, I would like to use a rich:calendar to filter the content of the table. So, following the examples I found, I added the following code to the .xhtml page:

<rich:column filter="#{rerunFilter.aodFilterImpl}">
    <f:facet name="header">
        <h:outputText value="Aod Rerun" />
        <br/>
        <rich:calendar id="aod"
                   datePattern="yyyy-MM-dd"
                   showWeekDaysBar="false"
                   showFooter="false"
                   value="#{rerunFilter.aodFilter}"
                   popup="true">
            <a4j:ajax event="change" render="main:rerunListTable" execute="@this"/>
        </rich:calendar>
    </f:facet>
    <h:outputText value="#{item.aod}">
        <f:convertDateTime pattern="yyyy-MM-dd" />
    </h:outputText>
</rich:column>

On the server side, I've the filter class where I added the following code:

private String aodFilter;

public String getAodFilter() {
    return aodFilter;
}

public void setAodFilter(String aodFilter) {
    logger.info("Received "+aodFilter);
    this.aodFilter = aodFilter;
}

public Filter<?> getAodFilterImpl() {
    return new Filter<Rerun>() {
        public boolean accept(Rerun item) {
            String aod = getAodFilter();
            logger.info("Invoked with "+aod+" Item date "+item.getAod());
            return true;

        }
    };
}

When I change the date, using the calendar, I saw in the log the property is correctly but there's something wrong, since I got an exception at the end

11:50:54,484 GRAVE [org.richfaces.log.Context] (http--127.0.0.1-8080-1) main:rerunListTable:j_idt38: 'Wed Oct 12 00:00:00 CEST 2011' could not be understood as a date.: javax.faces.convert.ConverterException: main:rerunListTable:j_idt38: 'Wed Oct 12 00:00:00 CEST 2011' could not be understood as a date.

Where am I wrong? thanks fil

Mat
  • 202,337
  • 40
  • 393
  • 406
filmac
  • 177
  • 2
  • 15

1 Answers1

1

I found the issue! I was using the wrong type for the aodFilter property, it's a java.util.Date, I used a String before. Using the right type and adding the filter logic, everything works. Just a note, I've to solve another little issue since the I didn't recognize JSF was converting date without using my own timezone. By the way, I added those lines

<context-param>
    <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
    <param-value>true</param-value>
</context-param>

to the web.xml as suggested here f:convertDateTime displays wrong Date and everything was ok thanks

Community
  • 1
  • 1
filmac
  • 177
  • 2
  • 15