diff --git a/src/main/java/org/richfaces/component/UISchedule.java b/src/main/java/org/richfaces/component/UISchedule.java index 4538fa0..c746136 100644 --- a/src/main/java/org/richfaces/component/UISchedule.java +++ b/src/main/java/org/richfaces/component/UISchedule.java @@ -45,6 +45,37 @@ public abstract class UISchedule extends UIComponentBase implements ScheduleComm public static final String COMPONENT_TYPE = "org.richfaces.Schedule"; + /** + * Values of switchType attribute + */ + public static final String SWITCH_TYPE_AJAX = "ajax"; + + public static final String SWITCH_TYPE_CLIENT = "client"; + + public static final String SWITCH_TYPE_SERVER = "server"; + + public static final String VIEW_AGENDA_DAY = "agendaDay"; + + public static final String VIEW_AGENDA_WEEK = "agendaWeek"; + + public static final String VIEW_BASIC_DAY = "basicDay"; + + public static final String VIEW_BASIC_WEEK = "basicWeek"; + + /** + * Values of view attribute. + */ + public static final String VIEW_MONTH = "month"; + + /** + * Values of weekMode attribute. + */ + public static final String WEEK_MODE_FIXED = "fixed"; + + public static final String WEEK_MODE_LIQUID = "liquid"; + + public static final String WEEK_MODE_VARIABLE = "variable"; + public static final boolean DEFAULT_ALL_DAY_DEFAULT = true; public static final boolean DEFAULT_ALL_DAY_SLOT = true; @@ -93,37 +124,6 @@ public abstract class UISchedule extends UIComponentBase implements ScheduleComm public static final String DEFAULT_WEEK_MODE = WEEK_MODE_FIXED; - /** - * Values of switchType attribute - */ - public static final String SWITCH_TYPE_AJAX = "ajax"; - - public static final String SWITCH_TYPE_CLIENT = "client"; - - public static final String SWITCH_TYPE_SERVER = "server"; - - public static final String VIEW_AGENDA_DAY = "agendaDay"; - - public static final String VIEW_AGENDA_WEEK = "agendaWeek"; - - public static final String VIEW_BASIC_DAY = "basicDay"; - - public static final String VIEW_BASIC_WEEK = "basicWeek"; - - /** - * Values of view attribute. - */ - public static final String VIEW_MONTH = "month"; - - /** - * Values of weekMode attribute. - */ - public static final String WEEK_MODE_FIXED = "fixed"; - - public static final String WEEK_MODE_LIQUID = "liquid"; - - public static final String WEEK_MODE_VARIABLE = "variable"; - private DataModel model; // -------------------------- STATIC METHODS -------------------------- diff --git a/src/main/java/org/richfaces/renderkit/ScheduleRendererBase.java b/src/main/java/org/richfaces/renderkit/ScheduleRendererBase.java index 763d131..f1ccfd9 100644 --- a/src/main/java/org/richfaces/renderkit/ScheduleRendererBase.java +++ b/src/main/java/org/richfaces/renderkit/ScheduleRendererBase.java @@ -27,6 +27,9 @@ import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.context.ResponseWriter; import java.io.IOException; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Collections; import java.util.Date; @@ -71,6 +74,8 @@ public abstract class ScheduleRendererBase extends AjaxComponentRendererBase { private static final String VIEW_PARAM = "view"; + private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + // -------------------------- STATIC METHODS -------------------------- /** @@ -157,8 +162,8 @@ public abstract class ScheduleRendererBase extends AjaxComponentRendererBase { try { if (DATE_RANGE_CHANGE_EVENT.equals(eventTypeParam)) { - Date startDate = new Date(Long.parseLong(startDateParam) * 1000); - Date endDate = new Date(Long.parseLong(endDateParam) * 1000); + Date startDate = DATE_FORMAT.parse(startDateParam); + Date endDate = DATE_FORMAT.parse(endDateParam); new ScheduleDateRangeChangeEvent(component, startDate, endDate).queue(); } else if (ITEM_MOVE_EVENT.equals(eventTypeParam)) { int dayDelta = Integer.parseInt(dayDeltaParam); @@ -174,16 +179,16 @@ public abstract class ScheduleRendererBase extends AjaxComponentRendererBase { } else if (VIEW_CHANGE_EVENT.equals(eventTypeParam)) { new ScheduleViewChangeEvent(component, viewParam).queue(); } else if (DATE_SELECT_EVENT.equals(eventTypeParam)) { - Date startDate = new Date(Long.parseLong(startDateParam) * 1000); + Date startDate = DATE_FORMAT.parse(startDateParam); boolean allDay = Boolean.parseBoolean(allDayParam); new ScheduleDateSelectEvent(component, startDate, allDay).queue(); } else if (DATE_RANGE_SELECT_EVENT.equals(eventTypeParam)) { - Date startDate = new Date(Long.parseLong(startDateParam) * 1000); - Date endDate = new Date(Long.parseLong(endDateParam) * 1000); + Date startDate = DATE_FORMAT.parse(startDateParam); + Date endDate = DATE_FORMAT.parse(endDateParam); boolean allDay = Boolean.parseBoolean(allDayParam); new ScheduleDateRangeSelectEvent(component, startDate, endDate, allDay).queue(); } - } catch (NumberFormatException ex) { + } catch (ParseException ex) { throw new FacesException("Cannot convert request parmeters", ex); } } diff --git a/src/main/resources/org/richfaces/renderkit/html/scripts/richfaces.schedule.js b/src/main/resources/org/richfaces/renderkit/html/scripts/richfaces.schedule.js index bbfd4cb..6a4c25e 100644 --- a/src/main/resources/org/richfaces/renderkit/html/scripts/richfaces.schedule.js +++ b/src/main/resources/org/richfaces/renderkit/html/scripts/richfaces.schedule.js @@ -23,7 +23,7 @@ RichFaces.Schedule = function(id, locale, options, dateRangeChangeEventName, ite * for new Date(long) - milliseconds since epoch. */ var formatDateParam = function(date) { - return Math.round(date.getTime() / 1000); + return jQuery.fullCalendar.formatDate(date, "yyyy-MM-dd HH:mm:ss"); }; /** * Compares two dates with with an accuracy of a day.