Author: akushunin
Date: 2007-07-17 06:59:41 -0400 (Tue, 17 Jul 2007)
New Revision: 1653
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/test/java/org/richfaces/component/CalendarComponentTest.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
02:16:54 UTC (rev 1652)
+++
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-07-17
10:59:41 UTC (rev 1653)
@@ -41,6 +41,7 @@
import javax.faces.context.FacesContext;
import javax.faces.convert.ConverterException;
import javax.faces.convert.DateTimeConverter;
+import javax.faces.el.ValueBinding;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
import javax.faces.render.Renderer;
@@ -98,24 +99,7 @@
Date valueString = calendar.getCurrentDate();
return valueString.toString();
}
-
- 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 {
@@ -125,7 +109,32 @@
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 void updateModel(FacesContext context) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ ValueBinding vb = getValueBinding("currentDate");
+ if (vb != null) {
+ vb.setValue(context, getLocalValue());//??
+ setValue(null);
+ setLocalValueSet(false);
+ return;
+ }
+ }
// --------------------------------------------------------
private int getLastDayOfWeek(Calendar calendar) {
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
02:16:54 UTC (rev 1652)
+++
branches/3.0.2/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-07-17
10:59:41 UTC (rev 1653)
@@ -27,6 +27,7 @@
import java.util.Map;
import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.event.FacesEvent;
@@ -96,17 +97,18 @@
.setCurrentDate(convertCurrentDate(currentDateString));
}
- CurrentDateEvent ev = new CurrentDateEvent(component) ;
- ev.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
- ev.queue();
+// CurrentDateEvent ev = new CurrentDateEvent(component) ;
+// ev.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
+// ev.queue();
new AjaxEvent(component).queue();
-
}
+
+
public void encodeChildren(FacesContext context, UIComponent calendar)
- throws IOException {
-
+ throws IOException {
+
}
public void writeMarkupScriptBody(FacesContext context,
Modified:
branches/3.0.2/sandbox/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java
===================================================================
---
branches/3.0.2/sandbox/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java 2007-07-17
02:16:54 UTC (rev 1652)
+++
branches/3.0.2/sandbox/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java 2007-07-17
10:59:41 UTC (rev 1653)
@@ -10,6 +10,7 @@
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlForm;
import javax.faces.component.html.HtmlOutputText;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
@@ -22,12 +23,35 @@
*
*/
public class CalendarComponentTest extends AbstractAjax4JsfTestCase {
+
+
+ private UIComponent form;
+ private UICalendar calendar;
+
public CalendarComponentTest(String name) {
super(name);
}
-
- public void testTidy() throws Exception {
+
+ public void setUp()throws Exception{
+
+ super.setUp();
+
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ calendar = (UICalendar) application.createComponent(UICalendar.COMPONENT_TYPE);
+ calendar.setLocale(Locale.CHINESE);
+ Calendar calendarObject = Calendar.getInstance();
+ calendarObject.set(2001, Calendar.SEPTEMBER, 11);
+ calendar.setId("calendar");
+
+ form.getChildren().add(calendar);
+
+ }
+
+/* public void testTidy() throws Exception {
UIViewRoot viewRoot = facesContext.getViewRoot();
List children = viewRoot.getChildren();
UIComponent calendar = application.createComponent(UICalendar.COMPONENT_TYPE);
@@ -40,7 +64,7 @@
HtmlPage renderView = renderView();
System.out.println(renderView.asXml());
}
-
+*/
public void testPreloadRanges() throws Exception {
UICalendar calendar = (UICalendar)
application.createComponent(UICalendar.COMPONENT_TYPE);
calendar.setLocale(Locale.FRENCH);
@@ -92,4 +116,19 @@
assertEquals(calendar.getPreloadDateRangeEnd(), range[range.length - 1]);
assertEquals(35, range.length);
}
+
+ public void testCalendarRenderer()throws Exception{
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ System.out.println(page.asXml());
+
+
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ form = null;
+ calendar = null;
+ }
}