开发者

<rich:calendar> doesn't accept java.util.Calendar

开发者 https://www.devze.com 2023-03-14 03:31 出处:网络
I\'m trying to use rich:calendar and it works when date properties selectedDate and currentDate are Date type. When I use Calendar, it doesn\'t work.

I'm trying to use rich:calendar and it works when date properties selectedDate and currentDate are Date type. When I use Calendar, it doesn't work.

When I submit a form, it reports:

SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/PORTAL] threw exception [javax.el.ELException: /test.xhtml @58,36 value="#{bean.calendar.selectedDate}": Cannot convert 24.6.11 0:00 of type class java.util.Date to class java.util.Calendar] with root cause
javax.el.ELException: /test.xhtml @58,36 value="#{bean.calendar.selectedDate}": Cannot convert 24.6.11 0:00 of type class java.util.Date to class java.util.Calendar

My XHTML:

<rich:calendar 
  mode="ajax" id="calendar"
  value="#{bean.calendar.selectedDate}"  
  locale="#{calendarBean.locale}"  
  datePatter开发者_JS百科n="#{calendarBean.pattern}"                        
  required="true">                   
</rich:calendar>

And calendar bean:

@ManagedBean
public class CalendarBean
{    
  private Calendar currentDate;  
  private Calendar selectedDate;

  public Calendar getCurrentDate() {  
    return currentDate;  
  }  
  public void setCurrentDate(Calendar currentDate) {  
    this.currentDate = currentDate;  
  } 
  public Calendar getSelectedDate() { 
    return selectedDate;  
  }  
  public void setSelectedDate(Calendar selectedDate) {  
    this.selectedDate = selectedDate;  
  }

What I'm doing wrong?


The Calendar class has a time property which represents a java.util.Date, complete with a getter and setter. Make use of it.

value="#{bean.calendar.selectedDate.time}"  
0

精彩评论

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

关注公众号