Commit 0d5735188673e2253ef43a097abdd5b7ac04e632

Authored by bernard
1 parent 9d55c675

Fixed problem with calculating dates when client and server were on different time zones.

Fixed invalid rearanging causing invalid forward reference.
... ... @@ -45,6 +45,37 @@ public abstract class UISchedule extends UIComponentBase implements ScheduleComm
45 45
46 46 public static final String COMPONENT_TYPE = "org.richfaces.Schedule";
47 47
  48 + /**
  49 + * Values of switchType attribute
  50 + */
  51 + public static final String SWITCH_TYPE_AJAX = "ajax";
  52 +
  53 + public static final String SWITCH_TYPE_CLIENT = "client";
  54 +
  55 + public static final String SWITCH_TYPE_SERVER = "server";
  56 +
  57 + public static final String VIEW_AGENDA_DAY = "agendaDay";
  58 +
  59 + public static final String VIEW_AGENDA_WEEK = "agendaWeek";
  60 +
  61 + public static final String VIEW_BASIC_DAY = "basicDay";
  62 +
  63 + public static final String VIEW_BASIC_WEEK = "basicWeek";
  64 +
  65 + /**
  66 + * Values of view attribute.
  67 + */
  68 + public static final String VIEW_MONTH = "month";
  69 +
  70 + /**
  71 + * Values of weekMode attribute.
  72 + */
  73 + public static final String WEEK_MODE_FIXED = "fixed";
  74 +
  75 + public static final String WEEK_MODE_LIQUID = "liquid";
  76 +
  77 + public static final String WEEK_MODE_VARIABLE = "variable";
  78 +
48 79 public static final boolean DEFAULT_ALL_DAY_DEFAULT = true;
49 80
50 81 public static final boolean DEFAULT_ALL_DAY_SLOT = true;
... ... @@ -93,37 +124,6 @@ public abstract class UISchedule extends UIComponentBase implements ScheduleComm
93 124
94 125 public static final String DEFAULT_WEEK_MODE = WEEK_MODE_FIXED;
95 126
96   - /**
97   - * Values of switchType attribute
98   - */
99   - public static final String SWITCH_TYPE_AJAX = "ajax";
100   -
101   - public static final String SWITCH_TYPE_CLIENT = "client";
102   -
103   - public static final String SWITCH_TYPE_SERVER = "server";
104   -
105   - public static final String VIEW_AGENDA_DAY = "agendaDay";
106   -
107   - public static final String VIEW_AGENDA_WEEK = "agendaWeek";
108   -
109   - public static final String VIEW_BASIC_DAY = "basicDay";
110   -
111   - public static final String VIEW_BASIC_WEEK = "basicWeek";
112   -
113   - /**
114   - * Values of view attribute.
115   - */
116   - public static final String VIEW_MONTH = "month";
117   -
118   - /**
119   - * Values of weekMode attribute.
120   - */
121   - public static final String WEEK_MODE_FIXED = "fixed";
122   -
123   - public static final String WEEK_MODE_LIQUID = "liquid";
124   -
125   - public static final String WEEK_MODE_VARIABLE = "variable";
126   -
127 127 private DataModel model;
128 128
129 129 // -------------------------- STATIC METHODS --------------------------
... ...
... ... @@ -27,6 +27,9 @@ import javax.faces.component.UIComponent;
27 27 import javax.faces.context.FacesContext;
28 28 import javax.faces.context.ResponseWriter;
29 29 import java.io.IOException;
  30 +import java.text.DateFormat;
  31 +import java.text.ParseException;
  32 +import java.text.SimpleDateFormat;
30 33 import java.util.Calendar;
31 34 import java.util.Collections;
32 35 import java.util.Date;
... ... @@ -71,6 +74,8 @@ public abstract class ScheduleRendererBase extends AjaxComponentRendererBase {
71 74
72 75 private static final String VIEW_PARAM = "view";
73 76
  77 + private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  78 +
74 79 // -------------------------- STATIC METHODS --------------------------
75 80
76 81 /**
... ... @@ -157,8 +162,8 @@ public abstract class ScheduleRendererBase extends AjaxComponentRendererBase {
157 162
158 163 try {
159 164 if (DATE_RANGE_CHANGE_EVENT.equals(eventTypeParam)) {
160   - Date startDate = new Date(Long.parseLong(startDateParam) * 1000);
161   - Date endDate = new Date(Long.parseLong(endDateParam) * 1000);
  165 + Date startDate = DATE_FORMAT.parse(startDateParam);
  166 + Date endDate = DATE_FORMAT.parse(endDateParam);
162 167 new ScheduleDateRangeChangeEvent(component, startDate, endDate).queue();
163 168 } else if (ITEM_MOVE_EVENT.equals(eventTypeParam)) {
164 169 int dayDelta = Integer.parseInt(dayDeltaParam);
... ... @@ -174,16 +179,16 @@ public abstract class ScheduleRendererBase extends AjaxComponentRendererBase {
174 179 } else if (VIEW_CHANGE_EVENT.equals(eventTypeParam)) {
175 180 new ScheduleViewChangeEvent(component, viewParam).queue();
176 181 } else if (DATE_SELECT_EVENT.equals(eventTypeParam)) {
177   - Date startDate = new Date(Long.parseLong(startDateParam) * 1000);
  182 + Date startDate = DATE_FORMAT.parse(startDateParam);
178 183 boolean allDay = Boolean.parseBoolean(allDayParam);
179 184 new ScheduleDateSelectEvent(component, startDate, allDay).queue();
180 185 } else if (DATE_RANGE_SELECT_EVENT.equals(eventTypeParam)) {
181   - Date startDate = new Date(Long.parseLong(startDateParam) * 1000);
182   - Date endDate = new Date(Long.parseLong(endDateParam) * 1000);
  186 + Date startDate = DATE_FORMAT.parse(startDateParam);
  187 + Date endDate = DATE_FORMAT.parse(endDateParam);
183 188 boolean allDay = Boolean.parseBoolean(allDayParam);
184 189 new ScheduleDateRangeSelectEvent(component, startDate, endDate, allDay).queue();
185 190 }
186   - } catch (NumberFormatException ex) {
  191 + } catch (ParseException ex) {
187 192 throw new FacesException("Cannot convert request parmeters", ex);
188 193 }
189 194 }
... ...
... ... @@ -23,7 +23,7 @@ RichFaces.Schedule = function(id, locale, options, dateRangeChangeEventName, ite
23 23 * for new Date(long) - milliseconds since epoch.
24 24 */
25 25 var formatDateParam = function(date) {
26   - return Math.round(date.getTime() / 1000);
  26 + return jQuery.fullCalendar.formatDate(date, "yyyy-MM-dd HH:mm:ss");
27 27 };
28 28 /**
29 29 * Compares two dates with with an accuracy of a day.
... ...
Please register or login to post a comment