Author: amarkhel
Date: 2010-11-01 12:23:04 -0400 (Mon, 01 Nov 2010)
New Revision: 19853
Added:
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
Modified:
trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
Log:
extend calendar demo
Added: trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
===================================================================
--- trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
(rev 0)
+++
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java 2010-11-01
16:23:04 UTC (rev 19853)
@@ -0,0 +1,86 @@
+package org.richfaces.demo;
+
+import java.util.Date;
+import java.util.Locale;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+import javax.faces.event.ValueChangeEvent;
+
+@ManagedBean
+@RequestScoped
+public class CalendarBean {
+
+ private Locale locale;
+ private boolean popup;
+ private String pattern;
+ private Date selectedDate;
+ private boolean showApply = true;
+ private boolean useCustomDayLabels;
+
+ public CalendarBean() {
+
+ locale = Locale.US;
+ popup = true;
+ pattern = "d/M/yy HH:mm";
+ }
+
+ 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 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;
+ }
+
+ public boolean isShowApply() {
+ return showApply;
+ }
+
+ public void setShowApply(boolean showApply) {
+ this.showApply = showApply;
+ }
+
+}
\ No newline at end of file
Modified: trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-01 16:20:40
UTC (rev 19852)
+++ trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-01 16:23:04
UTC (rev 19853)
@@ -29,13 +29,52 @@
Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-->
- <h:head>
- <title>Richfaces Calendar Demo</title>
- </h:head>
- <h:body>
- <h:form id="form">
- <calendar:calendar popup="true"/>
- <h:commandButton value="submit"></h:commandButton>
- </h:form>
- </h:body>
+<h:head>
+ <title>Richfaces Calendar Demo</title>
+</h:head>
+<h:body>
+ <h:form id="form">
+ <h:panelGrid id="panel" columns="2">
+ <h:panelGroup layout="block">
+ <calendar:calendar value="#{calendarBean.selectedDate}"
id="calendar"
+ locale="#{calendarBean.locale}" popup="#{calendarBean.popup}"
+ datePattern="#{calendarBean.pattern}"
+ showApplyButton="#{calendarBean.showApply}" cellWidth="24px"
+ cellHeight="22px" style="width:200px">
+ <f:convertDateTime pattern="#{calendarBean.pattern}"
+ onchange="alert('1')" />
+ </calendar:calendar>
+ </h:panelGroup>
+ <h:panelGrid columns="2">
+ <h:outputText value="Popup Mode:" />
+ <h:selectBooleanCheckbox value="#{calendarBean.popup}">
+ <f:ajax event="click" execute="@form" render="calendar
@this" />
+ </h:selectBooleanCheckbox>
+ <h:outputText value="Apply Button:" />
+ <h:selectBooleanCheckbox value="#{calendarBean.showApply}">
+ <f:ajax event="click" execute="@form" render="calendar
@this" />
+ </h:selectBooleanCheckbox>
+ <h:outputText value="Select Locale" />
+ <h:selectOneRadio value="en/US"
+ valueChangeListener="#{calendarBean.selectLocale}">
+ <f:ajax execute="@form" event="click" render="calendar
@this" />
+ <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}">
+ <f:ajax execute="@form" event="change" render="calendar
@this" />
+ <f:selectItem itemLabel="d/M/yy HH:mm" itemValue="d/M/yy
HH:mm" />
+ <f:selectItem itemLabel="dd/M/yy hh:mm a"
+ itemValue="dd/M/yy hh:mm a" />
+ <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>
+</h:body>
</html>