在列上使用 rich:calendar 过滤 rich:dataTable
我正在使用 richfaces 4.0,并在 rich:dataTable 上添加一些列过滤器。现在,由于我正在过滤包含日期的列,因此我想使用 rich:calendar 来过滤表的内容。因此,按照我找到的示例,我将以下代码添加到 .xhtml 页面:
<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>
在服务器端,我在过滤器类中添加了以下代码:
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;
}
};
}
当我使用日历更改日期时,我看到日志属性正确,但有问题,因为我在最后遇到异常
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' 无法被理解为日期。: javax.faces.convert.ConverterException: main:rerunListTable :j_idt38: '中欧夏令时间 10 月 12 日星期三 00:00:00 2011' 不能被理解为日期。
我哪里错了? 谢谢 菲尔
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现问题了!我为 aodFilter 属性使用了错误的类型,它是 java.util.Date,我之前使用过 String。
使用正确的类型并添加过滤器逻辑,一切正常。
请注意,我必须解决另一个小问题,因为我不知道 JSF 是在不使用我自己的时区的情况下转换日期的。
顺便说一句,我按照
此处的建议将这些行添加到 web.xml 中 f:convertDateTime 显示错误的日期 一切都好
谢谢
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
to the web.xml as suggested here f:convertDateTime displays wrong Date and everything was ok
thanks