Author: ilya_shaikovsky
Date: 2008-08-28 10:12:19 -0400 (Thu, 28 Aug 2008)
New Revision: 10220
Added:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendedDataTable/
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendedDataTable/ExtendedTableBean.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/snippets/
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/snippets/ValidationBean.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/snippets/
trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/snippets/CalendarDataModelImpl.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/snippets/CalendarDataModelItemImpl.java
trunk/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable/
trunk/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable/examples/
trunk/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable/examples/simple.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable/usage.xhtml
Log:
extendedDataTable sample
Added:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendedDataTable/ExtendedTableBean.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendedDataTable/ExtendedTableBean.java
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendedDataTable/ExtendedTableBean.java 2008-08-28
14:12:19 UTC (rev 10220)
@@ -0,0 +1,32 @@
+/**
+ *
+ */
+package org.richfaces.demo.extendedDataTable;
+
+/**
+ * @author Ilya Shaikovsky
+ *
+ */
+public class ExtendedTableBean {
+ private String sortMode="single";
+ private String selectionMode="multi";
+
+ public String getSortMode() {
+ return sortMode;
+ }
+
+ public void setSortMode(String sortMode) {
+ this.sortMode = sortMode;
+ }
+
+ public String getSelectionMode() {
+ return selectionMode;
+ }
+
+ public void setSelectionMode(String selectionMode) {
+ this.selectionMode = selectionMode;
+ }
+
+ public ExtendedTableBean() {
+ }
+}
Added:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/snippets/ValidationBean.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/snippets/ValidationBean.java
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/beanValidator/snippets/ValidationBean.java 2008-08-28
14:12:19 UTC (rev 10220)
@@ -0,0 +1,69 @@
+/**
+ *
+ */
+package org.richfaces.demo.validation;
+
+import org.hibernate.validator.Email;
+import org.hibernate.validator.Length;
+import org.hibernate.validator.Max;
+import org.hibernate.validator.Min;
+import org.hibernate.validator.NotEmpty;
+import org.hibernate.validator.NotNull;
+
+/**
+ * @author Ilya Shaikovsky
+ *
+ */
+public class ValidationBean {
+
+ private String progressString="Fill the form please";
+
+ @NotEmpty
+ @Length(min=3,max=12)
+ private String name;
+ @Email
+ @NotEmpty
+ private String email;
+ @NotNull
+ @Min(18)
+ @Max(100)
+ private int age;
+
+ public ValidationBean() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+ public void success() {
+ setProgressString(getProgressString() + "(Strored successfully)");
+ }
+
+ public String getProgressString() {
+ return progressString;
+ }
+
+ public void setProgressString(String progressString) {
+ this.progressString = progressString;
+ }
+}
Added:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/snippets/CalendarDataModelImpl.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/snippets/CalendarDataModelImpl.java
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/snippets/CalendarDataModelImpl.java 2008-08-28
14:12:19 UTC (rev 10220)
@@ -0,0 +1,187 @@
+/**
+ * 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.calendar.modelImpl;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.event.ValueChangeEvent;
+
+import org.richfaces.model.CalendarDataModel;
+import org.richfaces.model.CalendarDataModelItem;
+
+/**
+ * @author Ilya Shaikovsky
+ *
+ */
+public class CalendarDataModelImpl implements CalendarDataModel {
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.CalendarDataModel#getData(java.util.Date[])
+ */
+
+ private CalendarDataModelItem[] items;
+
+ private String currentDescription;
+ private String currentShortDescription;
+ private Date currentDate;
+ private boolean currentDisabled;
+
+
+ /* (non-Javadoc)
+ * @see org.richfaces.model.CalendarDataModel#getData(java.util.Date[])
+ */
+ public CalendarDataModelItem[] getData(Date[] dateArray) {
+ if (dateArray == null) {
+ return null;
+ }
+ if (items==null) {
+ items = new CalendarDataModelItem[dateArray.length];
+ for (int i = 0; i < dateArray.length; i++) {
+ items[i] = createDataModelItem(dateArray[i]);
+ }
+ }
+ return items;
+ }
+
+ /**
+ * @param date
+ * @return CalendarDataModelItem for date
+ */
+ protected CalendarDataModelItem createDataModelItem(Date date) {
+ CalendarDataModelItemImpl item = new CalendarDataModelItemImpl();
+ Map data = new HashMap();
+ data.put("shortDescription", "Nothing planned");
+ data.put("description", "");
+ Calendar c = Calendar.getInstance();
+ c.setTime(date);
+ item.setDay(c.get(Calendar.DAY_OF_MONTH));
+ item.setEnabled(true);
+ item.setStyleClass("rel-hol");
+ item.setData(data);
+ return item;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.model.CalendarDataModel#getToolTip(java.util.Date)
+ */
+ public Object getToolTip(Date date) {
+
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @return items
+ */
+ public CalendarDataModelItem[] getItems() {
+ return items;
+ }
+
+ /**
+ * @param setter for items
+ */
+ public void setItems(CalendarDataModelItem[] items) {
+ this.items = items;
+ }
+
+ /**
+ * @param valueChangeEvent handling
+ */
+ public void valueChanged(ValueChangeEvent event) {
+ System.out.println(event.getNewValue()+"selected");
+ setCurrentDate((Date)event.getNewValue());
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(getCurrentDate());
+ setCurrentDescription((String)((HashMap)items[calendar.get(Calendar.DAY_OF_MONTH)-1].getData()).get("description"));
+ setCurrentShortDescription((String)((HashMap)items[calendar.get(Calendar.DAY_OF_MONTH)-1].getData()).get("shortDescription"));
+ }
+
+ /**
+ * Storing changes action
+ */
+ public void storeDayDetails() {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(getCurrentDate());
+ ((HashMap)items[calendar.get(Calendar.DAY_OF_MONTH)-1].getData()).put("shortDescription",
getCurrentShortDescription());
+ ((HashMap)items[calendar.get(Calendar.DAY_OF_MONTH)-1].getData()).put("description",
getCurrentDescription());
+ }
+
+ /**
+ * @return currentDescription
+ */
+ public String getCurrentDescription() {
+ return currentDescription;
+ }
+
+ /**
+ * @param currentDescription
+ */
+ public void setCurrentDescription(String currentDescription) {
+ this.currentDescription = currentDescription;
+ }
+
+ /**
+ * @return currentDisabled
+ */
+ public boolean isCurrentDisabled() {
+ return currentDisabled;
+ }
+
+ /**
+ * @param currentDisabled
+ */
+ public void setCurrentDisabled(boolean currentDisabled) {
+ this.currentDisabled = currentDisabled;
+ }
+
+ /**
+ * @return currentShortDescription
+ */
+ public String getCurrentShortDescription() {
+ return currentShortDescription;
+ }
+
+ /**
+ * @param currentShortDescription
+ */
+ public void setCurrentShortDescription(String currentShortDescription) {
+ this.currentShortDescription = currentShortDescription;
+ }
+
+ /**
+ * @return currentDate
+ */
+ public Date getCurrentDate() {
+ return currentDate;
+ }
+
+ /**
+ * @param currentDate
+ */
+ public void setCurrentDate(Date currentDate) {
+ this.currentDate = currentDate;
+ }
+
+}
Added:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/snippets/CalendarDataModelItemImpl.java
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/snippets/CalendarDataModelItemImpl.java
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/calendar/snippets/CalendarDataModelItemImpl.java 2008-08-28
14:12:19 UTC (rev 10220)
@@ -0,0 +1,111 @@
+/**
+ * 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.calendar.modelImpl;
+
+import org.richfaces.model.CalendarDataModelItem;
+
+/**
+ * @author Nick Belaevski - mailto:nbelaevski@exadel.com
+ * created 04.07.2007
+ *
+ */
+public class CalendarDataModelItemImpl implements CalendarDataModelItem {
+
+ private Object data;
+ private String styleClass;
+ private Object toolTip;
+ private int day;
+ private boolean enabled = true;
+
+
+ public int getDay() {
+ return day;
+ }
+
+ public void setDay(int day) {
+ this.day = day;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.CalendarDataModelItem#getData()
+ */
+ public Object getData() {
+ return data;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.CalendarDataModelItem#getStyleClass()
+ */
+ public String getStyleClass() {
+ return styleClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.CalendarDataModelItem#getToolTip()
+ */
+ public Object getToolTip() {
+ return toolTip;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.CalendarDataModelItem#hasToolTip()
+ */
+ public boolean hasToolTip() {
+ return getToolTip() != null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.CalendarDataModelItem#isEnabled()
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * @param data the data to set
+ */
+ public void setData(Object data) {
+ this.data = data;
+ }
+
+ /**
+ * @param styleClass the styleClass to set
+ */
+ public void setStyleClass(String styleClass) {
+ this.styleClass = styleClass;
+ }
+
+ /**
+ * @param toolTip the toolTip to set
+ */
+ public void setToolTip(Object toolTip) {
+ this.toolTip = toolTip;
+ }
+
+ /**
+ * @param enabled the enabled to set
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+}
Added:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable/examples/simple.xhtml
===================================================================
---
trunk/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable/examples/simple.xhtml
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable/examples/simple.xhtml 2008-08-28
14:12:19 UTC (rev 10220)
@@ -0,0 +1,61 @@
+<!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>
+ <h:form>
+ <h:panelGrid columns="2">
+ <rich:extendedDataTable value="#{capitalsBean.capitals}"
var="cap" id="table"
+ width="400px" height="400px"
sortMode="#{extendedTableBean.sortMode}"
+ selectionMode="#{extendedTableBean.selectionMode}">
+ <rich:column sortable="false">
+ <f:facet name="header">
+ <h:outputText value="Flag"/>
+ </f:facet>
+ <h:graphicImage value="#{cap.stateFlag}"/>
+ </rich:column>
+ <rich:column sortable="true" sortBy="#{cap.state}">
+ <f:facet name="header">
+ <h:outputText value="State Name"/>
+ </f:facet>
+ <h:outputText value="#{cap.state}"/>
+ </rich:column>
+ <rich:column sortable="true" sortBy="#{cap.name}">
+ <f:facet name="header">
+ <h:outputText value="State Capital"/>
+ </f:facet>
+ <h:outputText value="#{cap.name}"/>
+ </rich:column>
+ <rich:column sortable="false">
+ <f:facet name="header">
+ <h:outputText value="Time Zone"/>
+ </f:facet>
+ <h:outputText value="#{cap.timeZone}"/>
+ </rich:column>
+ </rich:extendedDataTable>
+ <rich:panel>
+ <h:panelGrid columns="2">
+ <h:outputText value="Sort Mode:"/>
+ <h:selectOneMenu value="#{extendedTableBean.sortMode}">
+ <f:selectItem itemLabel="Single" itemValue="single"/>
+ <f:selectItem itemLabel="Multy" itemValue="multi"/>
+ <a4j:support event="onchange" ajaxSingle="true"
reRender="table"/>
+ </h:selectOneMenu>
+ <h:outputText value="Selection Mode:"/>
+ <h:selectOneMenu value="#{extendedTableBean.selectionMode}">
+ <a4j:support ajaxSingle="true" event="onchange"
reRender="table"/>
+ <f:selectItem itemLabel="Single" itemValue="single"/>
+ <f:selectItem itemLabel="Multy" itemValue="multi"/>
+ <f:selectItem itemLabel="None" itemValue="none"/>
+ </h:selectOneMenu>
+ </h:panelGrid>
+ </rich:panel>
+ </h:panelGrid>
+ </h:form>
+ </ui:composition>
+
+</html>
\ No newline at end of file
Added:
trunk/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable/usage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable/usage.xhtml
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable/usage.xhtml 2008-08-28
14:12:19 UTC (rev 10220)
@@ -0,0 +1,25 @@
+<!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>Desc
+ </p>
+
+ <fieldset class="demo_fieldset">
+ <legend class="demo_legend">Extended DataTable
example</legend>
+ <div class="sample-container">
+ <ui:include
src="/richfaces/extendedDataTable/examples/simple.xhtml"/>
+ <ui:include src="/templates/include/sourceview.xhtml">
+ <ui:param name="sourcepath"
value="/richfaces/extendedDataTable/examples/simple.xhtml"/>
+ </ui:include>
+ </div>
+ </fieldset>
+ </ui:define>
+
+ </ui:composition>
+</html>
Added: trunk/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable.xhtml
(rev 0)
+++
trunk/samples/richfaces-demo/src/main/webapp/richfaces/extendedDataTable.xhtml 2008-08-28
14:12:19 UTC (rev 10220)
@@ -0,0 +1,13 @@
+<!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:rich="http://richfaces.org/rich">
+<ui:composition template="/templates/main.xhtml">
+ <ui:define name="title">RichFaces - Open Source Rich JSF Components -
Extended DataTable</ui:define>
+ <ui:define name="body">
+ <ui:include src="/templates/include/tab-panel.xhtml" />
+ </ui:define>
+</ui:composition>
+</html>