开发者

Handle Date change on primefaces's calendar

I'm working on a JSF 2.0 project using Mojarra, PrimeFaces 2.2.1 and Tomcat 6.x.

My application is internationalized. I use the calendar of primefaces like this:

<p:calendar value="#{boxItem.agendaDate}" mode="inline" 
      showOtherMonths="true" styleClass="agendaHBox"
      selectListener="#{boxItem.handleAgendaDateChange}" 
      onSelectUpdate="@form"/>

The problem occurs when my locale is different than English and I use selectListener attribute.

For example, it happens when locale is set to Spanish. When the calendar appears, it is set to the current date: March 2011 24th. When I click other day like 25th march 2011, the selectListener method is being called, but the date I receive is "Thu May 03 00:00:00 CEST 2012" and the agenda suddenly changes to March 2012 5th.

The selectListener method is :

public void handleAgendaDateChange(DateSelectEvent event)
{
   System.err.println("handleAgendaDateChange = " + event.getDate());
}

If I remove selectListener att开发者_开发知识库ribute, the calendar behaves correctly (stays as March 2011 and selects 17th), but in this case I have issues handling date changes.

I need some code that will run when user selects a new date in the calendar control and pass it out to backend with Ajax request. How I can do that without the selectListener ?


It seems that p:calendar is buggy if you use it with a different locale than en (as to this list of open issues related to calendar and locale).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜