Author: akushunin
Date: 2007-07-31 11:58:47 -0400 (Tue, 31 Jul 2007)
New Revision: 1958
Modified:
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
Log:
TODO tasks were made
Some unused methods deleted
Modified: trunk/sandbox/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
===================================================================
---
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-07-31
15:58:04 UTC (rev 1957)
+++
trunk/sandbox/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-07-31
15:58:47 UTC (rev 1958)
@@ -44,6 +44,8 @@
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.event.AjaxEvent;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.richfaces.model.CalendarDataModel;
import org.richfaces.model.CalendarDataModelItem;
import org.richfaces.renderkit.CalendarDataModelItemAdaptor;
@@ -60,6 +62,8 @@
public static final String COMPONENT_TYPE = "org.richfaces.Calendar";
private static final String COMPONENT_FAMILY = "org.richfaces.Calendar";
+
+ private final static Log log = LogFactory.getLog(UICalendar.class);
public abstract Locale getLocale();
@@ -127,38 +131,29 @@
// currentDate processing -------------------------------------------------
-// public String getValueAsString(FacesContext context, UIComponent component)
-// throws IOException {
-// UICalendar calendar = (UICalendar) component;
-// Date valueString = calendar.getCurrentDate();
-// return valueString.toString();
-// }
-
public Calendar getCalendar() {
return Calendar.getInstance(getTimeZone(), getLocale());
}
-// public Converter getDateConverter() {
-// DateTimeConverter datetime = new DateTimeConverter();
-// return datetime;
-// }
-
public Date getConvertedValue(FacesContext context, String currentDateString)
throws ConverterException {
DateTimeConverter datetime = new DateTimeConverter();
- datetime.setPattern(getDatePattern());
+ datetime.setPattern("m/y");
Date newCurrentDate = (Date) datetime.getAsObject(context, this,
currentDateString);
return newCurrentDate;
}
protected void validateValue(FacesContext context, Object newValue) {
- //TODO nick - nick - do we need this?
- //store converted value in submitted value to ease client-side code's life
- //see org.richfaces.renderkit.CalendarRendererBase.getSelectedDate(FacesContext,
UICalendar) for more
+ // TODO nick - nick - do we need this?
+ // store converted value in submitted value to ease client-side code's
+ // life
+ // see
+ // org.richfaces.renderkit.CalendarRendererBase.getSelectedDate(FacesContext,
+ // UICalendar) for more
setSubmittedValue(newValue);
-
+
super.validateValue(context, newValue);
}
@@ -176,8 +171,11 @@
setCurrentDate(currentDate);
}
} catch (Exception e) {
- //TODO nick - kaa - missed setValid(false) !
- //TODO nick - kaa - add log.debug(...)
+ setValid(false);
+ //XXX nick - kaa - add log.debug(...)
+ if (log.isDebugEnabled()) {
+ log.debug(" updateCurrentDate method throws exception:
"+e.getMessage(),e);
+ }
String messageString = e.getMessage();
FacesMessage message = new FacesMessage(messageString);
message.setSeverity(FacesMessage.SEVERITY_ERROR);
@@ -266,24 +264,34 @@
// if currentDateString is not null then event cames from
// apply request phase
try {
- //TODO nick - kaa - we should use datePattern attribute-based converter only for
selectedDate
- // current date string always has predefined format: m/y
- // review
org.richfaces.renderkit.CalendarRendererBase.convertCurrentDate(String) method
- // for more
+ // XXX nick - kaa - we should use datePattern
+ // attribute-based converter only for selectedDate
+ // current date string always has predefined format: m/y
+ // review
+ // org.richfaces.renderkit.CalendarRendererBase.convertCurrentDate(String)
+ // method
+ // for more
Date currentDate = getConvertedValue(facesContext,
currentDateString);
CurrentDateChangeEvent newDateChangeEvent = new CurrentDateChangeEvent(
this, currentDate);
newDateChangeEvent.queue();
} catch (Exception e) {
- //TODO nick - kaa - add log.debug(...)
- //TODO nick - kaa - we should stop processing on exc. setValid(false) and then call
FacesContext.renderResponse(...)
- // update model phase shouldn't start
+ // XXX nick - kaa - add log.debug(...)
+ // XXX nick - kaa - we should stop processing on exc.
+ // setValid(false) and then call
+ // FacesContext.renderResponse(...)
+ // update model phase shouldn't start
+ if (log.isDebugEnabled()) {
+ log.debug(" currentDate convertion fails with following exception:
"+e.getMessage(),e);
+ }
+ setValid(false);
String messageString = e.getMessage();
FacesMessage message = new FacesMessage(messageString);
message.setSeverity(FacesMessage.SEVERITY_ERROR);
facesContext.addMessage(getClientId(facesContext),
message);
+ facesContext.renderResponse();
}
} else {
@@ -352,15 +360,7 @@
return (Date[]) dates.toArray(new Date[dates.size()]);
}
-// public void encodeAjaxChild(FacesContext context, String path, Set ids,
-// Set renderedAreas) throws IOException {
-//
-// Renderer renderer = this.getRenderer(context);
-// if (renderer instanceof AjaxChildrenEncoder) {
-// ((AjaxChildrenEncoder) renderer).encodeAjaxChild(context, path,
-// ids, renderedAreas);
-// }
-// }
+
}
class AdaptingCollection extends AbstractCollection {
Show replies by date