Author: akushunin
Date: 2007-07-16 11:20:44 -0400 (Mon, 16 Jul 2007)
New Revision: 1634
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
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/renderkit/CurrentDateEvent.java
Log:
added getConvertedValue method
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-16
13:47:08 UTC (rev 1633)
+++
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-07-16
15:20:44 UTC (rev 1634)
@@ -30,14 +30,15 @@
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.DateTimeConverter;
import javax.faces.event.AbortProcessingException;
@@ -90,50 +91,43 @@
// currentDate processing -------------------------------------------------
private Date currentDate = null;
-
- public Converter getConverter(FacesContext context, UICalendar calendar) {
-
- Converter converter = calendar.getConverter();
- if (converter == null) {
- DateTimeConverter datetime = new DateTimeConverter();
- if (context.getViewRoot().getLocale() == null) {
- datetime.setLocale(getDefaultLocale());
- } else {
- datetime.setLocale(context.getViewRoot().getLocale());
- }
- datetime.setTimeZone(TimeZone.getDefault());
- converter = datetime;
- }
- return converter;
- }
-
- public Object getConvertedValue(FacesContext context,
- UIComponent component, Object currentDate)
- throws ConverterException {
- UICalendar calendar = (UICalendar) component;
- Converter converter = getConverter(context, calendar);
- String valueString = (String) currentDate;
- return converter.getAsObject(context, component, valueString);
-
- }
-
public String getValueAsString(FacesContext context, UIComponent component)
throws IOException {
UICalendar calendar = (UICalendar) component;
Date valueString = calendar.getCurrentDate();
return valueString.toString();
}
-
- public void decode(FacesContext context) {
-
+
+ public void decode(FacesContext context, UIComponent component) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
super.decode(context);
-
+ ExternalContext external = context.getExternalContext();
+ Map requestParams = external.getRequestParameterMap();
+
+ UICalendar calendar = (UICalendar) component;
+ String clientId = calendar.getClientId(context);
+
+ Date currentDate = (Date) requestParams.get(clientId);
+ calendar.setCurrentDate(currentDate);
}
+
+ 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;
+ }
+
+
// --------------------------------------------------------
-
private int getLastDayOfWeek(Calendar calendar) {
int i = calendar.getFirstDayOfWeek();
if (i == calendar.getActualMinimum(Calendar.DAY_OF_WEEK)) {
@@ -193,12 +187,12 @@
FacesContext facesContext = FacesContext.getCurrentInstance();
AjaxContext ajaxContext = AjaxContext
.getCurrentInstance(facesContext);
- ajaxContext.setResponseData(getPreload());
+ ajaxContext.setResponseData(getPreload());
}
-
- //added recently
- if (event instanceof CurrentDateEvent){
- event.getPhaseId();
+
+ // added recently
+ if (event instanceof CurrentDateEvent) {
+ event.getPhaseId();
event.getComponent();
}
}
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-16
13:47:08 UTC (rev 1633)
+++
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-07-16
15:20:44 UTC (rev 1634)
@@ -95,7 +95,7 @@
((UICalendar) component)
.setCurrentDate(convertCurrentDate(currentDateString));
}
-
+
CurrentDateEvent ev = new CurrentDateEvent(component) ;
ev.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
ev.queue();
Modified:
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/renderkit/CurrentDateEvent.java
===================================================================
---
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/renderkit/CurrentDateEvent.java 2007-07-16
13:47:08 UTC (rev 1633)
+++
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/renderkit/CurrentDateEvent.java 2007-07-16
15:20:44 UTC (rev 1634)
@@ -19,6 +19,5 @@
public void processListener(FacesListener listener) {
// TODO Auto-generated method stub
}
-
}
Show replies by date