Author: akushunin
Date: 2007-07-17 08:46:44 -0400 (Tue, 17 Jul 2007)
New Revision: 1656
Modified:
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
Log:
Modified:
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java
===================================================================
---
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-07-17
12:41:01 UTC (rev 1655)
+++
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-07-17
12:46:44 UTC (rev 1656)
@@ -41,6 +41,7 @@
import javax.faces.context.FacesContext;
import javax.faces.convert.ConverterException;
import javax.faces.convert.DateTimeConverter;
+import javax.faces.el.MethodBinding;
import javax.faces.el.ValueBinding;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
@@ -99,43 +100,58 @@
Date valueString = calendar.getCurrentDate();
return valueString.toString();
}
-
- public Date getConvertedValue(FacesContext context,
- String currentDateString) throws ConverterException {
-
- DateTimeConverter datetime = new DateTimeConverter();
- datetime.setPattern("MM/yyyy");
- Date newCurrentDate =(Date)datetime.getAsObject(context, this, currentDateString);
- return newCurrentDate;
- }
-
-/* public void queueEvent(FacesEvent event) {
- FacesEvent resultEvent = event;
- if (event instanceof CurrentDateEvent) {
- event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
- } else {
- event.setPhaseId(PhaseId.INVOKE_APPLICATION);
- }
- resultEvent = wrapTreeEvent(event);
- super.queueEvent(resultEvent);
+ public Date getConvertedValue(FacesContext context, String currentDateString)
+ throws ConverterException {
+
+ DateTimeConverter datetime = new DateTimeConverter();
+ datetime.setPattern("MM/yyyy");
+ Date newCurrentDate = (Date) datetime.getAsObject(context, this,
+ currentDateString);
+ return newCurrentDate;
}
-
-*/
- public void updateModel(FacesContext context) {
- if (context == null) {
- throw new NullPointerException();
- }
+ public void updateModel(FacesContext context) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
ValueBinding vb = getValueBinding("currentDate");
if (vb != null) {
- vb.setValue(context, getLocalValue());//??
+ vb.setValue(context, getLocalCurrentDate());
setValue(null);
setLocalValueSet(false);
- return;
+ return;
}
- }
+ }
+
+ protected Date getLocalCurrentDate() {
+
+ return this.currentDate;
+ }
+ protected void setLocalCurrentDate(Date currentDate){
+
+ this.currentDate = currentDate;
+ }
+
+ public Object saveState(FacesContext context) {
+
+ Object values[] = new Object[2];
+ values[0] = super.saveState(context);
+ values[1] = saveAttachedState(context, currentDate);
+ return (values);
+
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+
+ Object values[] = (Object[]) state;
+ super.restoreState(context, values[0]);
+ currentDate = (Date) restoreAttachedState(context, values[1]);
+
+ }
+
// --------------------------------------------------------
private int getLastDayOfWeek(Calendar calendar) {
int i = calendar.getFirstDayOfWeek();
@@ -199,11 +215,12 @@
ajaxContext.setResponseData(getPreload());
}
- // added recently
+ /* added recently
if (event instanceof CurrentDateEvent) {
event.getPhaseId();
event.getComponent();
}
+ */
}
public Object getPreload() {
@@ -217,8 +234,7 @@
HashMap args = new HashMap();
args.put("startDate", CalendarRendererBase
.formatDate(preloadDateRange[0]));
- args
- .put("days", new AdaptingCollection(
+ args.put("days", new AdaptingCollection(
calendarDataModelItems));
return args;
}
Modified:
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
---
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-07-17
12:41:01 UTC (rev 1655)
+++
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-07-17
12:46:44 UTC (rev 1656)
@@ -86,6 +86,7 @@
super.doDecode(context, component);
String clientId = component.getClientId(context);
+
Map requestParameterMap = context.getExternalContext()
.getRequestParameterMap();
@@ -96,6 +97,9 @@
((UICalendar) component)
.setCurrentDate(convertCurrentDate(currentDateString));
}
+
+
+
// CurrentDateEvent ev = new CurrentDateEvent(component) ;
// ev.setPhaseId(PhaseId.PROCESS_VALIDATIONS);