Author: nbelaevski
Date: 2008-06-26 14:13:27 -0400 (Thu, 26 Jun 2008)
New Revision: 9254
Modified:
trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
Log:
http://jira.jboss.com/jira/browse/RF-3764
Modified: trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
===================================================================
--- trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2008-06-26
16:29:34 UTC (rev 9253)
+++ trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2008-06-26
18:13:27 UTC (rev 9254)
@@ -47,7 +47,6 @@
import javax.faces.el.ValueBinding;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
-import javax.faces.event.ValueChangeEvent;
import org.ajax4jsf.component.AjaxComponent;
import org.ajax4jsf.context.AjaxContext;
@@ -549,71 +548,59 @@
}
} else {
if (event instanceof CurrentDateChangeEvent) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
+ FacesContext facesContext = getFacesContext();
CurrentDateChangeEvent dateChangeEvent = (CurrentDateChangeEvent) event;
String currentDateString = dateChangeEvent
.getCurrentDateString();
- if (currentDateString != null) {
- // if currentDateString is not null then event cames from
- // apply request phase
- try {
- // 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
+ // if currentDateString is not null then event cames from
+ // apply request phase
+ try {
+ // 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
- // XX nick - kaa - throw exception and review resulting
- // message :)
+ // XX nick - kaa - throw exception and review resulting
+ // message :)
- Date currentDate = convertCurrentDate(currentDateString);
- CurrentDateChangeEvent newDateChangeEvent = new CurrentDateChangeEvent(
- this, currentDate);
- newDateChangeEvent.queue();
- MethodBinding binding = getCurrentDateChangeListener();
+ Date currentDate = getAsDate(getCurrentDate());
+ Date submittedCurrentDate = convertCurrentDate(currentDateString);
+ dateChangeEvent.setCurrentDate(submittedCurrentDate);
+ if (!submittedCurrentDate.equals(currentDate)) {
+ updateCurrentDate(facesContext, submittedCurrentDate);
+ MethodBinding binding = getCurrentDateChangeListener();
if (binding != null) {
binding
.invoke(facesContext,
- new Object[] { event });
+ new Object[] { dateChangeEvent });
}
-
- } catch (Exception e) {
- // 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.toString(), e);
- }
- setValid(false);
- String messageString = e.toString();
- e.printStackTrace();
- FacesMessage message = new FacesMessage(messageString);
- message.setSeverity(FacesMessage.SEVERITY_ERROR);
- facesContext.addMessage(getClientId(facesContext),
- message);
- facesContext.renderResponse();
}
-
- } else {
- Date currentDate1 = dateChangeEvent.getCurrentDate();
- Date currentDate2 = getAsDate(getCurrentDate());
- if (!currentDate1.equals(currentDate2)) {
- updateCurrentDate(facesContext, currentDate1);
- ValueChangeEvent changeEvent = new ValueChangeEvent(
- this, currentDate2, currentDate1);
- changeEvent.queue();
-
+
+ } catch (Exception e) {
+ // 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.toString(), e);
}
-
+ setValid(false);
+ String messageString = e.toString();
+ e.printStackTrace();
+ FacesMessage message = new FacesMessage(messageString);
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ facesContext.addMessage(getClientId(facesContext),
+ message);
+ facesContext.renderResponse();
}
} else {
super.broadcast(event);