我正在尝试使用rich:calendar
,当日期属性selectedDate
和currentDate
为Date
类型时,它可以工作。当我使用Calendar
时,它不起作用。
当我提交表格时,它会报告:
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
我的XHTML:
<rich:calendar
mode="ajax" id="calendar"
value="#{bean.calendar.selectedDate}"
locale="#{calendarBean.locale}"
datePattern="#{calendarBean.pattern}"
required="true">
</rich:calendar>
和日历豆:
@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;
}
我做错了什么?
Calendar
类有一个time
属性,它表示java.util.Date
,并配有getter和setter。利用它。
value="#{bean.calendar.selectedDate.time}"