Commit 0d5735188673e2253ef43a097abdd5b7ac04e632
1 parent
9d55c675
Fixed problem with calculating dates when client and server were on different time zones.
Fixed invalid rearanging causing invalid forward reference.
Showing
3 changed files
with
43 additions
and
38 deletions
@@ -45,6 +45,37 @@ public abstract class UISchedule extends UIComponentBase implements ScheduleComm | @@ -45,6 +45,37 @@ public abstract class UISchedule extends UIComponentBase implements ScheduleComm | ||
45 | 45 | ||
46 | public static final String COMPONENT_TYPE = "org.richfaces.Schedule"; | 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 | public static final boolean DEFAULT_ALL_DAY_DEFAULT = true; | 79 | public static final boolean DEFAULT_ALL_DAY_DEFAULT = true; |
49 | 80 | ||
50 | public static final boolean DEFAULT_ALL_DAY_SLOT = true; | 81 | public static final boolean DEFAULT_ALL_DAY_SLOT = true; |
@@ -93,37 +124,6 @@ public abstract class UISchedule extends UIComponentBase implements ScheduleComm | @@ -93,37 +124,6 @@ public abstract class UISchedule extends UIComponentBase implements ScheduleComm | ||
93 | 124 | ||
94 | public static final String DEFAULT_WEEK_MODE = WEEK_MODE_FIXED; | 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 | private DataModel model; | 127 | private DataModel model; |
128 | 128 | ||
129 | // -------------------------- STATIC METHODS -------------------------- | 129 | // -------------------------- STATIC METHODS -------------------------- |
@@ -27,6 +27,9 @@ import javax.faces.component.UIComponent; | @@ -27,6 +27,9 @@ import javax.faces.component.UIComponent; | ||
27 | import javax.faces.context.FacesContext; | 27 | import javax.faces.context.FacesContext; |
28 | import javax.faces.context.ResponseWriter; | 28 | import javax.faces.context.ResponseWriter; |
29 | import java.io.IOException; | 29 | import java.io.IOException; |
30 | +import java.text.DateFormat; | ||
31 | +import java.text.ParseException; | ||
32 | +import java.text.SimpleDateFormat; | ||
30 | import java.util.Calendar; | 33 | import java.util.Calendar; |
31 | import java.util.Collections; | 34 | import java.util.Collections; |
32 | import java.util.Date; | 35 | import java.util.Date; |
@@ -71,6 +74,8 @@ public abstract class ScheduleRendererBase extends AjaxComponentRendererBase { | @@ -71,6 +74,8 @@ public abstract class ScheduleRendererBase extends AjaxComponentRendererBase { | ||
71 | 74 | ||
72 | private static final String VIEW_PARAM = "view"; | 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 | // -------------------------- STATIC METHODS -------------------------- | 79 | // -------------------------- STATIC METHODS -------------------------- |
75 | 80 | ||
76 | /** | 81 | /** |
@@ -157,8 +162,8 @@ public abstract class ScheduleRendererBase extends AjaxComponentRendererBase { | @@ -157,8 +162,8 @@ public abstract class ScheduleRendererBase extends AjaxComponentRendererBase { | ||
157 | 162 | ||
158 | try { | 163 | try { |
159 | if (DATE_RANGE_CHANGE_EVENT.equals(eventTypeParam)) { | 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 | new ScheduleDateRangeChangeEvent(component, startDate, endDate).queue(); | 167 | new ScheduleDateRangeChangeEvent(component, startDate, endDate).queue(); |
163 | } else if (ITEM_MOVE_EVENT.equals(eventTypeParam)) { | 168 | } else if (ITEM_MOVE_EVENT.equals(eventTypeParam)) { |
164 | int dayDelta = Integer.parseInt(dayDeltaParam); | 169 | int dayDelta = Integer.parseInt(dayDeltaParam); |
@@ -174,16 +179,16 @@ public abstract class ScheduleRendererBase extends AjaxComponentRendererBase { | @@ -174,16 +179,16 @@ public abstract class ScheduleRendererBase extends AjaxComponentRendererBase { | ||
174 | } else if (VIEW_CHANGE_EVENT.equals(eventTypeParam)) { | 179 | } else if (VIEW_CHANGE_EVENT.equals(eventTypeParam)) { |
175 | new ScheduleViewChangeEvent(component, viewParam).queue(); | 180 | new ScheduleViewChangeEvent(component, viewParam).queue(); |
176 | } else if (DATE_SELECT_EVENT.equals(eventTypeParam)) { | 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 | boolean allDay = Boolean.parseBoolean(allDayParam); | 183 | boolean allDay = Boolean.parseBoolean(allDayParam); |
179 | new ScheduleDateSelectEvent(component, startDate, allDay).queue(); | 184 | new ScheduleDateSelectEvent(component, startDate, allDay).queue(); |
180 | } else if (DATE_RANGE_SELECT_EVENT.equals(eventTypeParam)) { | 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 | boolean allDay = Boolean.parseBoolean(allDayParam); | 188 | boolean allDay = Boolean.parseBoolean(allDayParam); |
184 | new ScheduleDateRangeSelectEvent(component, startDate, endDate, allDay).queue(); | 189 | new ScheduleDateRangeSelectEvent(component, startDate, endDate, allDay).queue(); |
185 | } | 190 | } |
186 | - } catch (NumberFormatException ex) { | 191 | + } catch (ParseException ex) { |
187 | throw new FacesException("Cannot convert request parmeters", ex); | 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,7 +23,7 @@ RichFaces.Schedule = function(id, locale, options, dateRangeChangeEventName, ite | ||
23 | * for new Date(long) - milliseconds since epoch. | 23 | * for new Date(long) - milliseconds since epoch. |
24 | */ | 24 | */ |
25 | var formatDateParam = function(date) { | 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 | * Compares two dates with with an accuracy of a day. | 29 | * Compares two dates with with an accuracy of a day. |
Please
register
or
login
to post a comment