Author: amarkhel
Date: 2010-11-17 11:58:18 -0500 (Wed, 17 Nov 2010)
New Revision: 20080
Added:
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelImpl.java
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelItemImpl.java
Modified:
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
Log:
RF-9683 Calendar component: data model support, RF-9684 Calendar component: AJAX
scrolling. Demo is updated.
Modified: trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
===================================================================
---
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java 2010-11-17
16:53:40 UTC (rev 20079)
+++
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java 2010-11-17
16:58:18 UTC (rev 20080)
@@ -4,11 +4,11 @@
import java.util.Locale;
import javax.faces.bean.ManagedBean;
-import javax.faces.bean.RequestScoped;
+import javax.faces.bean.SessionScoped;
import javax.faces.event.ValueChangeEvent;
@ManagedBean
-@RequestScoped
+@SessionScoped
public class CalendarBean {
private Locale locale;
@@ -17,6 +17,7 @@
private Date selectedDate;
private boolean showApply = true;
private boolean useCustomDayLabels;
+ private String mode = "client";
public CalendarBean() {
@@ -25,6 +26,14 @@
pattern = "d/M/yy HH:mm";
}
+ public String getMode() {
+ return mode;
+ }
+
+ public void setMode(String mode) {
+ this.mode = mode;
+ }
+
public Locale getLocale() {
return locale;
}
Added:
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelImpl.java
===================================================================
--- trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelImpl.java
(rev 0)
+++
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelImpl.java 2010-11-17
16:58:18 UTC (rev 20080)
@@ -0,0 +1,70 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.demo;
+
+import java.util.Date;
+import java.util.Random;
+
+import javax.faces.bean.ApplicationScoped;
+import javax.faces.bean.ManagedBean;
+
+import org.richfaces.model.CalendarDataModel;
+import org.richfaces.model.CalendarDataModelItem;
+
+/**
+ * @author Nick Belaevski - mailto:nbelaevski@exadel.com
+ * created 30.06.2007
+ *
+ */
+@ManagedBean(name="calendarDataModel")
+@ApplicationScoped
+public class CalendarDataModelImpl implements CalendarDataModel {
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.CalendarDataModel#getData(java.util.Date[])
+ */
+ public CalendarDataModelItem[] getData(Date[] dateArray) {
+ if (dateArray == null) {
+ return null;
+ }
+
+ CalendarDataModelItem[] items = new CalendarDataModelItem[dateArray.length];
+ for (int i = 0; i < dateArray.length; i++) {
+ items[i] = createDataModelItem(dateArray[i]);
+ }
+
+ return items;
+ }
+
+ protected CalendarDataModelItem createDataModelItem(Date date) {
+ CalendarDataModelItemImpl item = new CalendarDataModelItemImpl();
+
+ if (new Random().nextInt(10) > 5) {
+ item.setEnabled(true);
+
+ } else {
+ item.setEnabled(false);
+ }
+
+ return item;
+ }
+}
Added:
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelItemImpl.java
===================================================================
---
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelItemImpl.java
(rev 0)
+++
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelItemImpl.java 2010-11-17
16:58:18 UTC (rev 20080)
@@ -0,0 +1,58 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.demo;
+
+import org.richfaces.model.CalendarDataModelItem;
+
+/**
+ * @author Nick Belaevski - mailto:nbelaevski@exadel.com
+ * created 04.07.2007
+ *
+ */
+public class CalendarDataModelItemImpl implements CalendarDataModelItem {
+
+ private boolean enabled = true;
+ private String styleClass = "";
+
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.CalendarDataModelItem#isEnabled()
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * @param enabled the enabled to set
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public String getStyleClass() {
+ return styleClass;
+ }
+
+ public void setStyleClass(String styleClass) {
+ this.styleClass = styleClass;
+ }
+}
Modified: trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-17 16:53:40
UTC (rev 20079)
+++ trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-17 16:58:18
UTC (rev 20080)
@@ -39,6 +39,8 @@
<calendar:calendar value="#{calendarBean.selectedDate}"
id="calendar"
locale="#{calendarBean.locale}" popup="#{calendarBean.popup}"
datePattern="#{calendarBean.pattern}"
+ dataModel="#{calendarDataModel}"
+ mode="#{calendarBean.mode}"
showApplyButton="#{calendarBean.showApply}" cellWidth="24px"
cellHeight="22px" style="width:200px">
<f:convertDateTime pattern="#{calendarBean.pattern}"
@@ -73,6 +75,13 @@
<f:selectItem itemLabel="d/MMM/y" itemValue="d/MMM/y" />
<f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy"
/>
</h:selectOneMenu>
+
+ <h:outputText value="Mode" />
+ <h:selectOneMenu value="#{calendarBean.mode}"
onchange="submit()">
+ <f:selectItem itemValue="client"/>
+ <f:selectItem itemValue="ajax"/>
+ </h:selectOneMenu><br/>
+
</h:panelGrid>
</h:panelGrid>
</h:form>