[richfaces-svn-commits] JBoss Rich Faces SVN: r2423 - in trunk/samples: richfaces-demo/src/main/java/org/richfaces/demo and 5 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Wed Aug 22 20:30:10 EDT 2007
Author: SergeySmirnov
Date: 2007-08-22 20:30:10 -0400 (Wed, 22 Aug 2007)
New Revision: 2423
Added:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/calendar/
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/calendar/CalendarBean.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/model.xhtml
Modified:
trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java
trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/examples/calSample.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/usage.xhtml
Log:
demo update. calendar
Modified: trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java
===================================================================
--- trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java 2007-08-22 23:56:15 UTC (rev 2422)
+++ trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java 2007-08-23 00:30:10 UTC (rev 2423)
@@ -1,202 +1,10 @@
-/**
- * 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
- */
+ rich:calendar allows to select the date using monthly calendar elements on pages.
+ It is possoble to use the component in popup and inline code. Calendar at popup mode
+ initially renders as input for date and button on the right side to call popup.
+ Also initially Calendar should be loaded to client for the initial date.
-package org.richfaces;
+ If no initial date it should be loaded for current date but input must be empty.
+ On the button click - it must be shown. If the date was changed in the text from
+ initial field manually ajax request may (or may not) be sent to show the calendar
+ for the corresponding date.
-import java.text.DateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-import javax.faces.event.ValueChangeEvent;
-
-/**
- * 20/07/2007
- *
- * @author Alexej Kushunin
- * @mailto: akushunin at exadel.com
- *
- */
-public class CalendarBean {
-
- private static final String[] WEEK_DAY_LABELS = new String[] { "Sun *",
- "Mon +", "Tue +", "Wed +", "Thu +", "Fri +", "Sat *" };
- private Locale locale;
-
- private boolean popup;
- private boolean readonly;
- private boolean showInput;
- private boolean enableManualInput;
- private String pattern;
- private Date currentDate;
- private Date selectedDate;
- private String jointPoint;
- private String direction;
- private String boundary;
-
- private boolean useCustomDayLabels;
-
- public Locale getLocale() {
- return locale;
- }
-
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- public boolean isPopup() {
- return popup;
- }
-
- public void setPopup(boolean popup) {
- this.popup = popup;
- }
-
- public String getPattern() {
- return pattern;
- }
-
- public void setPattern(String pattern) {
- this.pattern = pattern;
- }
-
- public CalendarBean() {
-
- locale = Locale.US;
- popup = true;
- pattern = "MMM d, yyyy";
- jointPoint = "bottom-left";
- direction = "bottom-right";
- readonly = true;
- enableManualInput=false;
- showInput=true;
- boundary = "inactive";
- }
-
-
- public boolean isShowInput() {
- return showInput;
- }
-
- public void setShowInput(boolean showInput) {
- this.showInput = showInput;
- }
-
- public boolean isEnableManualInput() {
- return enableManualInput;
- }
-
- public void setEnableManualInput(boolean enableManualInput) {
- this.enableManualInput = enableManualInput;
- }
-
- public boolean isReadonly() {
- return readonly;
- }
-
- public void setReadonly(boolean readonly) {
- this.readonly = readonly;
- }
-
- public void selectLocale(ValueChangeEvent event) {
-
- String tLocale = (String) event.getNewValue();
- if (tLocale != null) {
- String lang = tLocale.substring(0, 2);
- String country = tLocale.substring(3);
- locale = new Locale(lang, country, "");
- }
- }
-
- public boolean isUseCustomDayLabels() {
- return useCustomDayLabels;
- }
-
- public void setUseCustomDayLabels(boolean useCustomDayLabels) {
- this.useCustomDayLabels = useCustomDayLabels;
- }
-
- public Object getWeekDayLabelsShort() {
- if (isUseCustomDayLabels()) {
- return WEEK_DAY_LABELS;
- } else {
- return null;
- }
- }
-
- public String getCurrentDateAsText() {
- Date currentDate = getCurrentDate();
- if (currentDate != null) {
- return DateFormat.getDateInstance(DateFormat.FULL).format(
- currentDate);
- }
-
- return null;
- }
-
- public Date getCurrentDate() {
- return currentDate;
- }
-
- public void setCurrentDate(Date currentDate) {
- this.currentDate = currentDate;
- }
-
- public Date getSelectedDate() {
- return selectedDate;
- }
-
- public void setSelectedDate(Date selectedDate) {
- this.selectedDate = selectedDate;
- }
-
- public String getJointPoint() {
- return jointPoint;
- }
-
- public void setJointPoint(String jointPoint) {
- this.jointPoint = jointPoint;
- }
-
- public void selectJointPoint(ValueChangeEvent event) {
- jointPoint = (String) event.getNewValue();
- }
-
- public String getDirection() {
- return direction;
- }
-
- public void setDirection(String direction) {
- this.direction = direction;
- }
-
- public void selectDirection(ValueChangeEvent event) {
- direction = (String) event.getNewValue();
- }
-
- public String getBoundary() {
- return boundary;
- }
-
- public void setBoundary(String boundary) {
- this.boundary = boundary;
- }
-
-}
\ No newline at end of file
Added: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/calendar/CalendarBean.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/calendar/CalendarBean.java (rev 0)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/calendar/CalendarBean.java 2007-08-23 00:30:10 UTC (rev 2423)
@@ -0,0 +1,75 @@
+package org.richfaces.demo.calendar;
+
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+import javax.faces.event.ValueChangeEvent;
+
+public class CalendarBean {
+
+ private Locale locale;
+ private boolean popup;
+ private String pattern;
+ private Date selectedDate;
+
+ private boolean useCustomDayLabels;
+
+ public Locale getLocale() {
+ return locale;
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+ public boolean isPopup() {
+ return popup;
+ }
+
+ public void setPopup(boolean popup) {
+ this.popup = popup;
+ }
+
+ public String getPattern() {
+ return pattern;
+ }
+
+ public void setPattern(String pattern) {
+ this.pattern = pattern;
+ }
+
+ public CalendarBean() {
+
+ locale = Locale.US;
+ popup = true;
+ pattern = "MMM d, yyyy";
+ }
+
+ public void selectLocale(ValueChangeEvent event) {
+
+ String tLocale = (String) event.getNewValue();
+ if (tLocale != null) {
+ String lang = tLocale.substring(0, 2);
+ String country = tLocale.substring(3);
+ locale = new Locale(lang, country, "");
+ }
+ }
+
+ public boolean isUseCustomDayLabels() {
+ return useCustomDayLabels;
+ }
+
+ public void setUseCustomDayLabels(boolean useCustomDayLabels) {
+ this.useCustomDayLabels = useCustomDayLabels;
+ }
+
+ public Date getSelectedDate() {
+ return selectedDate;
+ }
+
+ public void setSelectedDate(Date selectedDate) {
+ this.selectedDate = selectedDate;
+ }
+
+}
\ No newline at end of file
Modified: trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml 2007-08-22 23:56:15 UTC (rev 2422)
+++ trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml 2007-08-23 00:30:10 UTC (rev 2423)
@@ -18,6 +18,11 @@
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
+ <managed-bean-name>calendarBean</managed-bean-name>
+ <managed-bean-class>org.richfaces.demo.calendar.CalendarBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
<managed-bean-name>profile</managed-bean-name>
<managed-bean-class>org.richfaces.demo.wizard.Profile</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/examples/calSample.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/examples/calSample.xhtml 2007-08-22 23:56:15 UTC (rev 2422)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/examples/calSample.xhtml 2007-08-23 00:30:10 UTC (rev 2423)
@@ -5,8 +5,49 @@
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
+ <style type="text/css">
+ .ecol1 { width:250px; vertical-align: top; }
+ .ecol2 { vertical-align: top; border-left:1px solid #CCC; }
+ </style>
+
<h:form>
- <rich:calendar inputType="text" datePattern="dd/MM/yyyy" />
- </h:form>
+ <h:panelGrid id="panel" columns="2" width="100%" columnClasses="ecol1, ecol2">
+ <a4j:outputPanel id="calendar" layout="block">
+ <rich:calendar value="#{calendarBean.selectedDate}"
+ locale="#{calendarBean.locale}"
+ popup="#{calendarBean.popup}"
+ datePattern="#{calendarBean.pattern}"
+ />
+ </a4j:outputPanel>
+
+
+ <h:panelGrid columns="2">
+ <h:outputText value="Popup Mode:" />
+ <h:selectBooleanCheckbox value="#{calendarBean.popup}">
+ <a4j:support event="onchange" reRender="calendar"/>
+ </h:selectBooleanCheckbox>
+
+ <h:outputText value="Select Locale" />
+ <h:selectOneRadio value="en/US" valueChangeListener="#{calendarBean.selectLocale}">
+ <a4j:support event="onchange" reRender="calendar"/>
+ <f:selectItem itemLabel="US" itemValue="en/US"/>
+ <f:selectItem itemLabel="DE" itemValue="de/DE"/>
+ <f:selectItem itemLabel="FR" itemValue="fr/FR"/>
+ <f:selectItem itemLabel="RU" itemValue="ru/RU"/>
+ </h:selectOneRadio>
+
+ <h:outputText value="Select Date Pattern:"/>
+ <h:selectOneMenu value="#{calendarBean.pattern}">
+ <a4j:support event="onchange" reRender="calendar"/>
+ <f:selectItem itemLabel="d/M/yy" itemValue="d/M/yy"/>
+ <f:selectItem itemLabel="dd/M/yy" itemValue="dd/M/yy"/>
+ <f:selectItem itemLabel="d/MMM/y" itemValue="d/MMM/y"/>
+ <f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy"/>
+ </h:selectOneMenu>
+
+ </h:panelGrid>
+
+ </h:panelGrid>
+ </h:form>
</ui:composition>
\ No newline at end of file
Added: trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/model.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/model.xhtml (rev 0)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/model.xhtml 2007-08-23 00:30:10 UTC (rev 2423)
@@ -0,0 +1,52 @@
+<!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:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich">
+ <ui:composition template="/templates/component-sample.xhtml">
+ <ui:define name="sample">
+
+ <p>Calendar may use a special Data Model to provide data for element rendering.
+ Data Model consist of two major interfaces:
+ <ul>
+ <li>CalendarDataModel</li>
+ <li>CalendarDataModelItem</li>
+ </ul>
+ </p>
+ <p>
+ CalendarDataModel has the following functions:
+ <ul>
+ <li><b>CalendarDataModelItem[] getData(Date[]) </b>
+ is called every time when components will need next block of
+ CalendarDataItems. That may happens when calendar rendered, or when user navigate
+ to next(previous) month or in any other case when calendar renders. This method
+ will be called in Ajax mode when Calendar renders new page.</li>
+ <li><b>Object getToolTip(Date)</b> uses when tool tips are displayed in "single" mode.</li>
+ </ul>
+ </p>
+ <p>
+ CalendarDataModelItem provides the following methods:
+
+ <ul>
+ <li><b>Date getDate()</b> returns date that this item for, default implementation return Date</li>
+ <li><b>Boolean isEnabled()</b> returns true if date is "selectable" on calendar, default
+ implementation return true</li>
+ <li><b>String getStyleClass()</b> returns String that will be appended to style class for
+ that date span. For example it may be "relevant holyday" that mean class will
+ be like "rich-cal-day relevant holyday". Default implementation return empty string.</li>
+ <li><b>Object getData()</b> returns any additional payload that must be JSON-serialazable
+ object. May be used in custom date representation on calendar (inside custom facet).</li>
+ <li><b>Boolean hasToolTip()</b> returns true if given date has an associated with
+ it tooltip data. Default implementation return false.</li>
+ <li><b>Object getToolTip()</b> returns tool tip data that will be used in "batch" tooltip
+ loading mode.</li>
+ </ul>
+ </p>
+
+
+ </ui:define>
+
+ </ui:composition>
+</html>
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/usage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/usage.xhtml 2007-08-22 23:56:15 UTC (rev 2422)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/usage.xhtml 2007-08-23 00:30:10 UTC (rev 2423)
@@ -9,7 +9,11 @@
<ui:define name="sample">
<p>
- </p>
+ rich:calendar allows to select the date using monthly calendar elements on pages.
+ It is possoble to use the component in popup and inline code. Calendar at popup mode
+ initially renders as input for date and button on the right side to call popup.
+ In case of inline mode, the monthly calendar is located on the page initially.
+ </p>
<div class="sample-container" >
@@ -19,7 +23,27 @@
</ui:include>
</div>
+ <p>
+ <b>locale</b> attribute define a Locale. The default value is set to the Locale of current page.
+ The name of the month and week days names are depends of the Locale.
+ </p>
+ <p>
+ <b>popup</b> attribute is a flag that direct the calendar mode. If true, the popup mode is used.
+ Otherwize, the inline mode is set.
+ </p>
+
+ <p>
+ <b>showInput</b> attribute defines should the input field be rendered in popup mode. If
+ set to false, only the button (calendar icon) appears on the page.
+ </p>
+
+ <p>
+ <b>enableManualInput</b> attribute allows to input the date in the text field manually.
+ The default value is false. It means a user can only select the date from the calendar element.
+ </p>
+
+
</ui:define>
</ui:composition>
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar.xhtml 2007-08-22 23:56:15 UTC (rev 2422)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar.xhtml 2007-08-23 00:30:10 UTC (rev 2423)
@@ -11,6 +11,9 @@
<rich:tab label="Usage">
<ui:include src="/richfaces/calendar/usage.xhtml"/>
</rich:tab>
+ <rich:tab label="Calendar Model">
+ <ui:include src="/richfaces/calendar/model.xhtml"/>
+ </rich:tab>
</rich:tabPanel>
</ui:define>
</ui:composition>
More information about the richfaces-svn-commits
mailing list