Author: ppitonak(a)redhat.com
Date: 2010-12-09 05:50:23 -0500 (Thu, 09 Dec 2010)
New Revision: 20473
Added:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/CalendarModel.java
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/CalendarModelItem.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richCalendar/dataModel.xhtml
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richCalendar/list.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richCalendar/simple.xhtml
Log:
https://jira.jboss.org/browse/RF-9178
* added new sample for calendar with data model
Added:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/CalendarModel.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/CalendarModel.java
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/CalendarModel.java 2010-12-09
10:50:23 UTC (rev 20473)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.model;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import javax.faces.bean.ApplicationScoped;
+import javax.faces.bean.ManagedBean;
+
+import org.richfaces.model.CalendarDataModel;
+import org.richfaces.model.CalendarDataModelItem;
+
+/**
+ * Managed bean with calendar's model.
+ *
+ * @author Ilya Shaikovsky, Exadel
+ * @version $Revision$
+ */
+@ManagedBean
+@ApplicationScoped
+public class CalendarModel implements CalendarDataModel {
+
+ private static final String WEEKEND_DAY_CLASS = "yellowDay";
+ private static final String BUSY_DAY_CLASS = "aquaDay";
+ private static final String BOUNDARY_DAY_CLASS = "rf-ca-boundary-dates";
+
+ private boolean checkBusyDay(Calendar calendar) {
+ return (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.TUESDAY ||
calendar.get(Calendar.DAY_OF_WEEK) == Calendar.THURSDAY);
+ }
+
+ private boolean checkWeekend(Calendar calendar) {
+ return (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY ||
calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY);
+ }
+
+ public CalendarDataModelItem[] getData(Date[] dateArray) {
+ CalendarDataModelItem[] modelItems = new CalendarModelItem[dateArray.length];
+ Calendar current = GregorianCalendar.getInstance();
+ Calendar today = GregorianCalendar.getInstance();
+ today.setTime(new Date());
+ for (int i = 0; i < dateArray.length; i++) {
+ current.setTime(dateArray[i]);
+ CalendarModelItem modelItem = new CalendarModelItem();
+ if (current.before(today)) {
+ modelItem.setEnabled(false);
+ modelItem.setStyleClass(BOUNDARY_DAY_CLASS);
+ } else if (checkBusyDay(current)) {
+ modelItem.setEnabled(false);
+ modelItem.setStyleClass(BUSY_DAY_CLASS);
+ } else if (checkWeekend(current)) {
+ modelItem.setEnabled(false);
+ modelItem.setStyleClass(WEEKEND_DAY_CLASS);
+ } else {
+ modelItem.setEnabled(true);
+ modelItem.setStyleClass("");
+ }
+ modelItems[i] = modelItem;
+ }
+
+ return modelItems;
+ }
+}
Property changes on:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/CalendarModel.java
___________________________________________________________________
Name: svn:keywords
+ Revision
Added:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/CalendarModelItem.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/CalendarModelItem.java
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/CalendarModelItem.java 2010-12-09
10:50:23 UTC (rev 20473)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.model;
+
+import org.richfaces.model.CalendarDataModelItem;
+
+/**
+ * Item of calendar data model.
+ *
+ * @author Ilya Shaikovsky, Exadel
+ * @version $Revision$
+ */
+public class CalendarModelItem implements CalendarDataModelItem {
+
+ private boolean enabled;
+ private String styleClass;
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public void setStyleClass(String styleClass) {
+ this.styleClass = styleClass;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public String getStyleClass() {
+ return styleClass;
+ }
+}
Property changes on:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/model/CalendarModelItem.java
___________________________________________________________________
Name: svn:keywords
+ Revision
Added:
modules/tests/metamer/trunk/application/src/main/webapp/components/richCalendar/dataModel.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richCalendar/dataModel.xhtml
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richCalendar/dataModel.xhtml 2010-12-09
10:50:23 UTC (rev 20473)
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:h="http://java.sun.com/jsf/html">
+
+ <!--
+JBoss, Home of Professional Open Source
+Copyright 2010, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+This software 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 software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ -->
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="head">
+ <f:metadata>
+ <f:viewParam name="templates"
value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ <style type="text/css">
+ .yellowDay {
+ background: yellow !important;
+ }
+
+ .aquaDay {
+ background: aqua !important;
+ }
+
+ </style>
+
+ <script type="text/javascript">
+ testedComponentId = "#{rich:clientId('calendar')}";
+ </script>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ </ui:define>
+
+ <ui:define name="component">
+ <div style="padding: 250px">
+ <rich:calendar id="calendar"
boundaryDatesMode="scroll" dataModel="#{calendarModel}"
mode="ajax" >
+ <a4j:ajax event="change" render="output,
requestTime" limitRender="#{true}"/>
+ </rich:calendar>
+ </div>
+
+ <br/><br/>
+
+ output: <h:outputText id="output"
value="#{richCalendarBean.attributes['value'].value}"/>
+
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter"/>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richCalendar/list.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richCalendar/list.xhtml 2010-12-09
09:50:04 UTC (rev 20472)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richCalendar/list.xhtml 2010-12-09
10:50:23 UTC (rev 20473)
@@ -35,6 +35,10 @@
Simple page containing <b>rich:calendar</b> and inputs for
all its attributes.
</metamer:testPageLink>
+ <metamer:testPageLink id="dataModel"
outcome="dataModel" value="Data Model">
+ Page containing <b>rich:calendar</b> with data model and
inputs for all its attributes.
+ </metamer:testPageLink>
+
</ui:define>
</ui:composition>
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richCalendar/simple.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richCalendar/simple.xhtml 2010-12-09
09:50:04 UTC (rev 20472)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richCalendar/simple.xhtml 2010-12-09
10:50:23 UTC (rev 20473)
@@ -83,7 +83,6 @@
<ui:define name="component">
<div style="padding: 250px">
- <!-- add attributes direction and jointPoint ASAP -->
<rich:calendar id="calendar"
boundaryDatesMode="#{richCalendarBean.attributes['boundaryDatesMode'].value}"
buttonClass="#{richCalendarBean.attributes['buttonClass'].value}"