Author: ilya_shaikovsky
Date: 2010-12-02 05:15:11 -0500 (Thu, 02 Dec 2010)
New Revision: 20289
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/dataModel.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/dataModel-sample.xhtml
Modified:
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml
Log:
https://jira.jboss.org/browse/RF-9834
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModel.java 2010-12-02
10:15:11 UTC (rev 20289)
@@ -0,0 +1,54 @@
+package org.richfaces.demo.calendar.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;
+
+@ManagedBean
+@ApplicationScoped
+public class CalendarModel implements CalendarDataModel {
+ private static final String WEEKEND_DAY_CLASS = "wdc";
+ private static final String BUSY_DAY_CLASS = "bdc";
+ 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;
+ }
+}
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java
===================================================================
---
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/calendar/model/CalendarModelItem.java 2010-12-02
10:15:11 UTC (rev 20289)
@@ -0,0 +1,25 @@
+package org.richfaces.demo.calendar.model;
+
+import org.richfaces.model.CalendarDataModelItem;
+
+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;
+ }
+}
Modified:
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-12-02
10:00:57 UTC (rev 20288)
+++
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-12-02
10:15:11 UTC (rev 20289)
@@ -1,15 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
- <!--
- NOTES(TODO: move to some readme in future): id for sample should
- equals to xhtml page name with the sample the same for demo id - it
- should be equals to name of the folder where samples placed
- -->
+<!-- NOTES(TODO: move to some readme in future): id for sample should equals
+ to xhtml page name with the sample the same for demo id - it should be equals
+ to name of the folder where samples placed -->
<root>
<group>
<name>Ajax Action</name>
<demos>
<demo>
- <id>ajax</id>
+ <id>ajax</id>
<name>a4j:ajax</name>
<samples>
<sample>
@@ -174,21 +172,10 @@
</demo>
</demos>
</group>
- <!-- group>
- <name>Validation</name>
- <demos>
- <demo>
- <id>clientValidation</id>
- <name>Ajax/Client Validation</name>
- <samples>
- <sample>
- <id>ajaxValidation</id>
- <name>Simple Ajax Validation</name>
- </sample>
- </samples>
- </demo>
- </demos>
- </group-->
+ <!-- group> <name>Validation</name> <demos> <demo>
<id>clientValidation</id>
+ <name>Ajax/Client Validation</name> <samples> <sample>
<id>ajaxValidation</id>
+ <name>Simple Ajax Validation</name> </sample> </samples>
</demo> </demos>
+ </group -->
<group>
<name>Data Iteration</name>
<demos>
@@ -215,14 +202,10 @@
<name>Data Table Styling</name>
<description>
<!-- TODO: rowClass should appears at this sample after completion -->
- <!--
- TODO: rowClasses should be used instead of jQuerry selectors
- after will works
- -->
- <!--
- TODO: onrowmouseover, onrowmouseout - should be used instead of
- jQuery selector
- -->
+ <!-- TODO: rowClasses should be used instead of jQuerry selectors
+ after will works -->
+ <!-- TODO: onrowmouseover, onrowmouseout - should be used instead
+ of jQuery selector -->
</description>
</sample>
<sample>
@@ -246,7 +229,7 @@
<sample>
<id>exTableSelection</id>
<name>ExtendedData Table Selection usage</name>
- </sample>
+ </sample>
</samples>
</demo>
<demo>
@@ -334,7 +317,7 @@
<sample>
<id>simple</id>
<name>Simple Toggle Panel</name>
- </sample>
+ </sample>
</samples>
</demo>
<demo>
@@ -346,18 +329,15 @@
<description>Simple Tab Panels</description>
<name>Simple Tab Panels</name>
</sample>
- <!-- sample>
- <id>headerCustomization</id>
- <description>Headers Customization</description>
- <name>Headers Customization</name>
- </sample-->
- <sample>
+ <!-- sample> <id>headerCustomization</id>
<description>Headers Customization</description>
+ <name>Headers Customization</name> </sample -->
+ <sample>
<id>valueManagement</id>
<description>Selected Tab Management</description>
<name>Selected Tab Management</name>
- </sample>
+ </sample>
</samples>
- </demo>
+ </demo>
<demo>
<id>collapsiblePanel</id>
<name>rich:collapsiblePanel</name>
@@ -371,13 +351,13 @@
<demo>
<id>accordion</id>
<name>rich:accordion</name>
- <samples>
+ <samples>
<sample>
<id>simple</id>
<name>Simple Accordion</name>
</sample>
- </samples>
- </demo>
+ </samples>
+ </demo>
<demo>
<id>popup</id>
<name>rich:popupPanel</name>
@@ -415,13 +395,13 @@
<name>Simple tooltips</name>
</sample>
</samples>
- </demo>
+ </demo>
</demos>
</group>
<group>
<name>Menus</name>
<demos>
- <demo new="true">
+ <demo new="true">
<id>panelMenu</id>
<name>rich:panelMenu</name>
<samples>
@@ -431,7 +411,7 @@
</sample>
</samples>
</demo>
- <demo new="true">
+ <demo new="true">
<id>toolBar</id>
<name>rich:toolBar</name>
<samples>
@@ -449,7 +429,7 @@
</group>
<group>
<name>Inputs and Selects</name>
- <demos>
+ <demos>
<demo>
<id>autocomplete</id>
<name>rich:autocomplete</name>
@@ -457,14 +437,14 @@
<sample>
<id>cachedAjax</id>
<name>Autocomplete in Cached Ajax mode</name>
- </sample>
+ </sample>
<sample>
<id>clientFilter</id>
<name>Custom client filter</name>
- </sample>
+ </sample>
</samples>
</demo>
- <demo>
+ <demo new="true">
<id>calendar</id>
<name>rich:calendar</name>
<samples>
@@ -475,7 +455,11 @@
<sample new="true">
<id>clientStylingDisablement</id>
<name>Client Side Styling/Disablement</name>
- </sample>
+ </sample>
+ <sample new="true">
+ <id>dataModel</id>
+ <name>Data Model Support</name>
+ </sample>
</samples>
</demo>
<demo>
@@ -507,7 +491,7 @@
<name>Inplace Inputs samples</name>
</sample>
</samples>
- </demo>
+ </demo>
<demo>
<id>inplaceSelect</id>
<name>rich:inplaceSelect</name>
@@ -517,7 +501,7 @@
<name>Inplace Selects samples</name>
</sample>
</samples>
- </demo>
+ </demo>
<demo>
<id>select</id>
<name>rich:select</name>
@@ -527,8 +511,8 @@
<name>Selects samples</name>
</sample>
</samples>
- </demo>
- </demos>
+ </demo>
+ </demos>
</group>
<group>
<name>Misc Components/Features</name>
Added:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/dataModel.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/dataModel.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/dataModel.xhtml 2010-12-02
10:15:11 UTC (rev 20289)
@@ -0,0 +1,66 @@
+<!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:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition>
+ <p>Calendar may use a special Data Model to provide data for
+ element rendering. You can re-define the default Calendar Model using
+ the dataModel attribute pointed to the object that implements
+ CalendarDataModel interface.</p>
+ <p>In next simple example next rules applied using model:</p>
+ <ul>
+ <li>Weekend days are disabled (sunday and saturday) and uses bold
+ and italic text style.</li>
+ <li>Thuesday and Thursday are disabled also. (just RichFaces team
+ meeting days) So grayed out as busy days.</li>
+ <li>All the values in the past disabed and styled as boundary
+ dates.</li>
+ </ul>
+ <ui:include src="#{demoNavigator.sampleIncludeURI}" />
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="#{demoNavigator.sampleIncludeURI}"
/>
+ <ui:param name="sourceType" value="xhtml" />
+ <ui:param name="openLabel" value="View Source" />
+ <ui:param name="hideLabel" value="Hide Source" />
+ </ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src"
+ value="/WEB-INF/src/org/richfaces/demo/calendar/model/CalendarModel.java"
/>
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View CalendarModel Source"
/>
+ <ui:param name="hideLabel" value="Hide CalendarModel Source"
/>
+ </ui:include>
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src"
+ value="/WEB-INF/src/org/richfaces/demo/calendar/model/CalendarModelItem.java"
/>
+ <ui:param name="sourceType" value="java" />
+ <ui:param name="openLabel" value="View CalendarModelItem Source"
/>
+ <ui:param name="hideLabel" value="Hide CalendarModelItem Source"
/>
+ </ui:include>
+ <p>Calendar may use a special Data Model to provide data for
+ element rendering. You can re-define the default Calendar Model using
+ the dataModel attribute pointed to the object that implements
+ <b>CalendarDataModel</b> interface.</p>
+ <p>CalendarDataModel has the following methods:</p>
+ <ul>
+ <li><b>CalendarDataModelItem[] getData(Date[])</b> is called every
time
+ when components need the next block of CalendarDataItems. That may
+ happens when the calendar is rendered, or when you navigate to the
+ next/previous month or in any other case when the calendar is
+ rendered. This method is called in an Ajax mode when the calendar
+ renders a new page.</li>
+ </ul>
+ <p>CalendarDataModelItem provides the following methods:</p>
+ <ul>
+ <li><b>Boolean isEnabled()</b> returns "true" if date is
"selectable" on
+ the calendar, the default implementation returns "true"</li>
+ <li><b>String getStyleClass()</b> returns "String" that is
appended to a
+ style class for the date span. For example it may be "relevant
+ holiday" that means a class looks like "rich-cal-day relevant
+ holiday". The default implementation returns an empty string.</li>
+ </ul>
+</ui:composition>
+
+</html>
\ No newline at end of file
Modified:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml 2010-12-02
10:00:57 UTC (rev 20288)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/clientStylingDisablement-sample.xhtml 2010-12-02
10:15:11 UTC (rev 20289)
@@ -34,5 +34,4 @@
</script>
<rich:calendar dayDisableFunction="disablementFunction"
dayClassFunction="disabledClassesProv" boundaryDatesMode="scroll"
/>
-
</ui:composition>
\ No newline at end of file
Added:
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/dataModel-sample.xhtml
===================================================================
---
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/dataModel-sample.xhtml
(rev 0)
+++
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/calendar/samples/dataModel-sample.xhtml 2010-12-02
10:15:11 UTC (rev 20289)
@@ -0,0 +1,22 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:rich="http://richfaces.org/rich">
+ <style>
+.bdc {
+ background-color: gray;
+}
+
+.wdc {
+ font-weight: bold;
+ font-style: italic;
+}
+</style>
+ <h:form>
+ <rich:calendar mode="ajax" boundaryDatesMode="scroll"
+ dataModel="#{calendarModel}" />
+ </h:form>
+</ui:composition>
\ No newline at end of file