JBoss Rich Faces SVN: r1198 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-15 07:57:55 -0400 (Fri, 15 Jun 2007)
New Revision: 1198
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
Log:
renderer extend UIDataAdaptor instead of UIRepeat
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-06-15 11:25:23 UTC (rev 1197)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-06-15 11:57:55 UTC (rev 1198)
@@ -20,7 +20,7 @@
import org.ajax4jsf.ajax.repeat.DataVisitor;
import org.ajax4jsf.ajax.repeat.ExtendedDataModel;
import org.ajax4jsf.ajax.repeat.Range;
-import org.ajax4jsf.ajax.repeat.UIRepeat;
+import org.ajax4jsf.ajax.repeat.UIDataAdaptor;
import org.ajax4jsf.framework.ajax.AjaxComponent;
import org.ajax4jsf.framework.ajax.AjaxContext;
import org.ajax4jsf.framework.ajax.AjaxEvent;
@@ -37,14 +37,12 @@
import org.richfaces.model.impl.ListDataModel;
-
-
/**
* @author Anton Belevich
*
*/
-public abstract class UIScrollableGrid extends UIRepeat implements AjaxComponent, Sortable, Selectable{
+public abstract class UIScrollableGrid extends UIDataAdaptor implements AjaxComponent, Sortable, Selectable{
public static final String COMPONENT_TYPE = "org.richfaces.component.ScrollableGrid";
17 years, 6 months
JBoss Rich Faces SVN: r1197 - in trunk: sandbox/calendar/src/main/templates/org/richfaces and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-06-15 07:25:23 -0400 (Fri, 15 Jun 2007)
New Revision: 1197
Modified:
trunk/sandbox-samples/calendar-sample/src/main/webapp/pages/index.jsp
trunk/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
trunk/sandbox/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
Log:
Sample & script updated
Modified: trunk/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
--- trunk/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-06-15 10:11:36 UTC (rev 1196)
+++ trunk/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-06-15 11:25:23 UTC (rev 1197)
@@ -119,7 +119,11 @@
int bodyChildrenLength = bodyChildren.getLength();
writer.startElement("script", component);
- writer.write("var calendarEval = function (string, context) { return string; };");
+ writer.write("calendarEval = function(template, object)" +
+"{" +
+" var value=\"\";"+
+" try { with (object) value=eval(template) } catch (e) { LOG.warn('Exception: '+e.message + '\\n[' + template + ']'); }"+
+" return value;};");
writer.write("var evaluator = new Object(); evaluator.parts = [ ");
@@ -151,7 +155,7 @@
writer.write("]; evaluator.evaluate = function (context) { var result = '';");
writer.write(" for (var i = 0; i < this.parts.length; i++) result += this.parts[i].getOuterHTML(context); return result;};\n");
- writer.write("new Insertion.Top($('" + component.getClientId(context) + "'), evaluator.evaluate(null));");
+ writer.write("new Insertion.Top($('" + component.getClientId(context) + "'), evaluator.evaluate(window));");
writer.endElement("script");
}
}
Modified: trunk/sandbox/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- trunk/sandbox/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-06-15 10:11:36 UTC (rev 1196)
+++ trunk/sandbox/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-06-15 11:25:23 UTC (rev 1197)
@@ -11,7 +11,7 @@
component="org.richfaces.component.UICalendar"
>
<f:clientid var="clientId"/>
- <h:scripts>new org.ajax4jsf.framework.resource.PrototypeScript(),/org/richfaces/renderkit/html/scripts/json/json-dom.js</h:scripts>
+ <h:scripts>new org.ajax4jsf.framework.resource.PrototypeScript(),new org.ajax4jsf.framework.ajax.AjaxScript(),/org/richfaces/renderkit/html/scripts/json/json-dom.js</h:scripts>
<div id="#{clientId}"
x:passThruWithExclusions="value,name,type,id"
>
Modified: trunk/sandbox-samples/calendar-sample/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox-samples/calendar-sample/src/main/webapp/pages/index.jsp 2007-06-15 10:11:36 UTC (rev 1196)
+++ trunk/sandbox-samples/calendar-sample/src/main/webapp/pages/index.jsp 2007-06-15 11:25:23 UTC (rev 1197)
@@ -7,6 +7,12 @@
</head>
<body>
<f:view>
+ <f:verbatim>
+ <script>
+ window.test = "test var text";
+ </script>
+ </f:verbatim>
+
<f:verbatim><h3>HTML tidying test</h3></f:verbatim>
<calendar:calendar>
<h:outputText escape="false" value="<br xmlns:test='urn:test' test:aaa='sss'> &<a href='#' class='{test}'>end<div xmlns:prefix='urn:urn'><p value='aaa'><p value='bbb'></p></div>" />
@@ -16,6 +22,8 @@
<f:verbatim><h3>Templating test</h3></f:verbatim>
<calendar:calendar>
<f:verbatim><input type="text" value="$ {test} $" /></f:verbatim>
+
+ <f:verbatim><input type="radio" checked="{test}" /><input type="radio" checked="{test1}" /></f:verbatim>
</calendar:calendar>
</f:view>
</body>
17 years, 6 months
JBoss Rich Faces SVN: r1196 - trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-06-15 06:11:36 -0400 (Fri, 15 Jun 2007)
New Revision: 1196
Modified:
trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java
Log:
Tests compilation fixed
Modified: trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java
===================================================================
--- trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java 2007-06-15 08:39:06 UTC (rev 1195)
+++ trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java 2007-06-15 10:11:36 UTC (rev 1196)
@@ -56,6 +56,10 @@
return MenuComponent.MODE_AJAX;
}
+ public void setSubmitMode(String submitMode) {
+ throw new UnsupportedOperationException();
+ }
+
}
/**
@@ -94,7 +98,7 @@
menuItem.setSubmitMode(null);
assertEquals(menuItem.getParent(), menu);
String resultMode = renderer.resolveSubmitMode(menuItem);
- assertEquals(resultMode, MenuComponent.MODE_SERVER);
+ assertEquals(MenuComponent.MODE_SERVER, resultMode);
menuItem.setSubmitMode(MenuComponent.MODE_NONE);
resultMode = renderer.resolveSubmitMode(menuItem);
17 years, 6 months
JBoss Rich Faces SVN: r1195 - in trunk/richfaces/menu-components/src/main: java/org/richfaces/component and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: a.izobov
Date: 2007-06-15 04:39:06 -0400 (Fri, 15 Jun 2007)
New Revision: 1195
Modified:
trunk/richfaces/menu-components/src/main/config/component/menucomponents.xml
trunk/richfaces/menu-components/src/main/java/org/richfaces/component/MenuComponent.java
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
Log:
http://jira.jboss.com/jira/browse/RF-263 fixed
Modified: trunk/richfaces/menu-components/src/main/config/component/menucomponents.xml
===================================================================
--- trunk/richfaces/menu-components/src/main/config/component/menucomponents.xml 2007-06-15 00:06:13 UTC (rev 1194)
+++ trunk/richfaces/menu-components/src/main/config/component/menucomponents.xml 2007-06-15 08:39:06 UTC (rev 1195)
@@ -211,7 +211,6 @@
<classname>java.lang.String</classname>
<description>Set the submission mode (ajax, server(Default),
none)</description>
- <defaultvalue>"server"</defaultvalue>
</property>
<!-- Command attributes -->
Modified: trunk/richfaces/menu-components/src/main/java/org/richfaces/component/MenuComponent.java
===================================================================
--- trunk/richfaces/menu-components/src/main/java/org/richfaces/component/MenuComponent.java 2007-06-15 00:06:13 UTC (rev 1194)
+++ trunk/richfaces/menu-components/src/main/java/org/richfaces/component/MenuComponent.java 2007-06-15 08:39:06 UTC (rev 1195)
@@ -40,5 +40,6 @@
* Getter for submit mode property.
*/
public String getSubmitMode();
+ public void setSubmitMode(String submitMode);
}
Modified: trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java
===================================================================
--- trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2007-06-15 00:06:13 UTC (rev 1194)
+++ trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuItemRendererBase.java 2007-06-15 08:39:06 UTC (rev 1195)
@@ -111,7 +111,7 @@
menuItem, context).toString());
} else if (mode.equalsIgnoreCase(MenuComponent.MODE_SERVER)) {
CommandScriptBuilder builder = new CommandScriptBuilder(menuItem);
- //builder.setCheckActionAndListener(true);
+ builder.setCheckActionAndListener(false);
Object target = menuItem.getAttributes().get("target");
if (null != target) {
builder.setTarget((String) target);
17 years, 6 months
JBoss Rich Faces SVN: r1194 - in trunk/sandbox-samples: calendar-sample and 12 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-06-14 20:06:13 -0400 (Thu, 14 Jun 2007)
New Revision: 1194
Added:
trunk/sandbox-samples/calendar-sample/
trunk/sandbox-samples/calendar-sample/pom.xml
trunk/sandbox-samples/calendar-sample/src/
trunk/sandbox-samples/calendar-sample/src/main/
trunk/sandbox-samples/calendar-sample/src/main/java/
trunk/sandbox-samples/calendar-sample/src/main/java/org/
trunk/sandbox-samples/calendar-sample/src/main/java/org/richfaces/
trunk/sandbox-samples/calendar-sample/src/main/java/org/richfaces/Bean.java
trunk/sandbox-samples/calendar-sample/src/main/resources/
trunk/sandbox-samples/calendar-sample/src/main/webapp/
trunk/sandbox-samples/calendar-sample/src/main/webapp/WEB-INF/
trunk/sandbox-samples/calendar-sample/src/main/webapp/WEB-INF/faces-config.xml
trunk/sandbox-samples/calendar-sample/src/main/webapp/WEB-INF/web.xml
trunk/sandbox-samples/calendar-sample/src/main/webapp/index.jsp
trunk/sandbox-samples/calendar-sample/src/main/webapp/pages/
trunk/sandbox-samples/calendar-sample/src/main/webapp/pages/index.jsp
trunk/sandbox-samples/calendar-sample/src/main/webapp/pages/index.xhtml
trunk/sandbox-samples/calendar-sample/src/test/
trunk/sandbox-samples/calendar-sample/src/test/java/
trunk/sandbox-samples/calendar-sample/src/test/java/org/
trunk/sandbox-samples/calendar-sample/src/test/java/org/richfaces/
trunk/sandbox-samples/calendar-sample/src/test/java/org/richfaces/BeanTest.java
Modified:
trunk/sandbox-samples/pom.xml
Log:
calendar-sample initial import
Property changes on: trunk/sandbox-samples/calendar-sample
___________________________________________________________________
Name: svn:ignore
+ .settings
target
.classpath
.project
Added: trunk/sandbox-samples/calendar-sample/pom.xml
===================================================================
--- trunk/sandbox-samples/calendar-sample/pom.xml (rev 0)
+++ trunk/sandbox-samples/calendar-sample/pom.xml 2007-06-15 00:06:13 UTC (rev 1194)
@@ -0,0 +1,32 @@
+<?xml version="1.0"?><project>
+ <parent>
+ <artifactId>richfaces-samples</artifactId>
+ <groupId>org.richfaces</groupId>
+ <version>3.0.2-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces</groupId>
+ <artifactId>calendar-sample</artifactId>
+ <packaging>war</packaging>
+ <name>calendar-sample Maven Webapp</name>
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces</groupId>
+ <artifactId>common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces</groupId>
+ <artifactId>calendar</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces</groupId>
+ <artifactId>skins</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <finalName>calendar-sample</finalName>
+ </build>
+</project>
\ No newline at end of file
Added: trunk/sandbox-samples/calendar-sample/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/sandbox-samples/calendar-sample/src/main/java/org/richfaces/Bean.java (rev 0)
+++ trunk/sandbox-samples/calendar-sample/src/main/java/org/richfaces/Bean.java 2007-06-15 00:06:13 UTC (rev 1194)
@@ -0,0 +1,29 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - 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;
+/**
+ * @author $Autor$
+ *
+ */
+public class Bean {
+
+}
\ No newline at end of file
Added: trunk/sandbox-samples/calendar-sample/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/sandbox-samples/calendar-sample/src/main/webapp/WEB-INF/faces-config.xml (rev 0)
+++ trunk/sandbox-samples/calendar-sample/src/main/webapp/WEB-INF/faces-config.xml 2007-06-15 00:06:13 UTC (rev 1194)
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
+ "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+<faces-config>
+ <managed-bean>
+ <managed-bean-name>skinBean</managed-bean-name>
+ <managed-bean-class>org.richfaces.SkinBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+</faces-config>
Added: trunk/sandbox-samples/calendar-sample/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/sandbox-samples/calendar-sample/src/main/webapp/WEB-INF/web.xml (rev 0)
+++ trunk/sandbox-samples/calendar-sample/src/main/webapp/WEB-INF/web.xml 2007-06-15 00:06:13 UTC (rev 1194)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <display-name>Archetype Created Web Application</display-name>
+ <context-param>
+ <param-name>javax.faces.CONFIG_FILES</param-name>
+ <param-value>/WEB-INF/faces-config.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <!--
+ -->
+ <filter>
+ <display-name>Ajax4jsf Filter</display-name>
+ <filter-name>ajax4jsf</filter-name>
+ <filter-class>org.ajax4jsf.Filter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>ajax4jsf</filter-name>
+ <servlet-name>Faces Servlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>/faces/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+</web-app>
Added: trunk/sandbox-samples/calendar-sample/src/main/webapp/index.jsp
===================================================================
--- trunk/sandbox-samples/calendar-sample/src/main/webapp/index.jsp (rev 0)
+++ trunk/sandbox-samples/calendar-sample/src/main/webapp/index.jsp 2007-06-15 00:06:13 UTC (rev 1194)
@@ -0,0 +1,11 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+
+<html>
+
+<head></head>
+
+ <body>
+ <jsp:forward page="/pages/index.jsf" />
+ </body>
+
+</html>
\ No newline at end of file
Added: trunk/sandbox-samples/calendar-sample/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox-samples/calendar-sample/src/main/webapp/pages/index.jsp (rev 0)
+++ trunk/sandbox-samples/calendar-sample/src/main/webapp/pages/index.jsp 2007-06-15 00:06:13 UTC (rev 1194)
@@ -0,0 +1,22 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://richfaces.ajax4jsf.org/calendar" prefix="calendar" %>
+<html>
+ <head>
+ <title></title>
+ </head>
+ <body>
+ <f:view>
+ <f:verbatim><h3>HTML tidying test</h3></f:verbatim>
+ <calendar:calendar>
+ <h:outputText escape="false" value="<br xmlns:test='urn:test' test:aaa='sss'> &<a href='#' class='{test}'>end<div xmlns:prefix='urn:urn'><p value='aaa'><p value='bbb'></p></div>" />
+ </calendar:calendar>
+
+
+ <f:verbatim><h3>Templating test</h3></f:verbatim>
+ <calendar:calendar>
+ <f:verbatim><input type="text" value="$ {test} $" /></f:verbatim>
+ </calendar:calendar>
+ </f:view>
+ </body>
+</html>
\ No newline at end of file
Added: trunk/sandbox-samples/calendar-sample/src/main/webapp/pages/index.xhtml
===================================================================
--- trunk/sandbox-samples/calendar-sample/src/main/webapp/pages/index.xhtml (rev 0)
+++ trunk/sandbox-samples/calendar-sample/src/main/webapp/pages/index.xhtml 2007-06-15 00:06:13 UTC (rev 1194)
@@ -0,0 +1,12 @@
+<!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:h="http://java.sun.com/jsf/html"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
+ xmlns:c="http://java.sun.com/jsp/jstl/core"
+ >
+ <f:view>
+
+ </f:view>
+</html>
\ No newline at end of file
Added: trunk/sandbox-samples/calendar-sample/src/test/java/org/richfaces/BeanTest.java
===================================================================
--- trunk/sandbox-samples/calendar-sample/src/test/java/org/richfaces/BeanTest.java (rev 0)
+++ trunk/sandbox-samples/calendar-sample/src/test/java/org/richfaces/BeanTest.java 2007-06-15 00:06:13 UTC (rev 1194)
@@ -0,0 +1,46 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - 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;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+*/
+public class BeanTest
+ extends TestCase
+{
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public BeanTest( String testName )
+ {
+ super( testName );
+ }
+
+ public void testStub() throws Exception {
+
+ }
+}
Modified: trunk/sandbox-samples/pom.xml
===================================================================
--- trunk/sandbox-samples/pom.xml 2007-06-15 00:03:21 UTC (rev 1193)
+++ trunk/sandbox-samples/pom.xml 2007-06-15 00:06:13 UTC (rev 1194)
@@ -84,13 +84,13 @@
<artifactId>jstl</artifactId>
<version>1.0</version>
<scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.richfaces</groupId>
- <artifactId>richfaces</artifactId>
- <version>3.0.2-SNAPSHOT</version>
- <scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>org.richfaces</groupId>
+ <artifactId>richfaces</artifactId>
+ <version>3.0.2-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
<scm>
@@ -190,7 +190,7 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2_03</version>
+ <version>1.2_03</version>
<scope>runtime</scope>
</dependency>
<dependency>
@@ -238,64 +238,65 @@
<scope>runtime</scope>
</dependency>
</dependencies>
- </profile>
- <profile>
- <id>jsf-facelets</id>
- <dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- <version>2.1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-api</artifactId>
- <version>1.2_03</version>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-impl</artifactId>
- <version>1.2_03</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>com.sun.facelets</groupId>
- <artifactId>jsf-facelets</artifactId>
- <version>1.1.11</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- <version>1.0</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>el-impl</groupId>
- <artifactId>el-impl</artifactId>
- <version>1.0</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jstl</artifactId>
- <version>1.0</version>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
- </profile>
+ </profile>
+ <profile>
+ <id>jsf-facelets</id>
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>1.2_03</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>1.2_03</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.facelets</groupId>
+ <artifactId>jsf-facelets</artifactId>
+ <version>1.1.11</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>1.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>el-impl</groupId>
+ <artifactId>el-impl</artifactId>
+ <version>1.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+ </profile>
</profiles>
<modules>
<module>scrollable-grid-demo</module>
<module>panel2-sample</module>
<module>simpleTogglePanel2-sample</module>
<module>panelmenu-sample</module>
+ <module>calendar-sample</module>
</modules>
</project>
\ No newline at end of file
17 years, 7 months
JBoss Rich Faces SVN: r1193 - in trunk: richfaces/common/src/main/java/org/richfaces/renderkit and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-06-14 20:03:21 -0400 (Thu, 14 Jun 2007)
New Revision: 1193
Added:
trunk/richfaces/common/src/main/java/org/richfaces/json/JSContentHandler.java
trunk/richfaces/common/src/main/java/org/richfaces/renderkit/TemplateUtil.java
trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js
trunk/sandbox/calendar/src/main/java/org/richfaces/renderkit/
trunk/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
trunk/sandbox/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java
Removed:
trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/TemplateUtil.java
Modified:
trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java
trunk/sandbox/calendar/pom.xml
trunk/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java
trunk/sandbox/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
Log:
- Client templating being moved to common
- Improved client templating in calendar project started
Added: trunk/richfaces/common/src/main/java/org/richfaces/json/JSContentHandler.java
===================================================================
--- trunk/richfaces/common/src/main/java/org/richfaces/json/JSContentHandler.java (rev 0)
+++ trunk/richfaces/common/src/main/java/org/richfaces/json/JSContentHandler.java 2007-06-15 00:03:21 UTC (rev 1193)
@@ -0,0 +1,583 @@
+package org.richfaces.json;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Arrays;
+
+import org.ajax4jsf.framework.util.javascript.JSEncoder;
+import org.ajax4jsf.framework.util.message.Messages;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.LexicalHandler;
+
+
+/**
+ * @author shura
+ * SAX content handler for serialise events as JavaScript function.
+ */
+public class JSContentHandler implements ContentHandler,LexicalHandler {
+
+ protected Writer outputWriter;
+
+ private static final JSEncoder encoder = new JSEncoder();
+
+ private static final char S_EOL[] = System.getProperty("line.separator")
+ .toCharArray();
+
+ private static final char S_DOCUMENT_START[] = "(".toCharArray();
+
+ private static final char S_DOCUMENT_ENF[] = ");".toCharArray();
+
+ private static final char S_DOCUMENT_3[] = "\"?>".toCharArray();
+
+ private static final char S_OBJECT_START[] = "{".toCharArray();
+ private static final char[] S_OBJECT_END = "}".toCharArray();
+
+ private static final char S_ELEMENT_START[] = "new E(".toCharArray();
+
+ private static final char[] S_ELEMENT_CLOSE = ")".toCharArray();
+
+ private static final char S_ATTRIBUTES_END[] = "}".toCharArray();
+
+ private static final char S_ATTRIBUTES_START[] = ",{".toCharArray();
+
+ private static final char S_ELEMENT_END_START_TAG[] = ",[".toCharArray();
+
+ private static final char S_ELEMENT_END[] = "])".toCharArray();
+
+ private static final char S_TEXT_START[] = "new T('".toCharArray();
+
+ private static final char S_TEXT_END[] = "')".toCharArray();
+
+ private static final char S_CDATA_START[] = "new D('".toCharArray();
+
+ private static final char S_CDATA_END[] = "')".toCharArray();
+
+ private static final char S_COMMENT_START[] = "new C('".toCharArray();
+
+ private static final char S_COMMENT_END[] = "')".toCharArray();
+
+ private static final char S_PROCINSTR_START[] = "<?".toCharArray();
+
+ private static final char S_PROCINSTR_END[] = "?>".toCharArray();
+
+ private static final char C_LT = '<';
+
+ private static final char C_GT = '>';
+
+ private static final char C_SPACE = ' ';
+
+ private static final char C_QUOTE = '\'';
+
+ private static final char C_NSSEP = ':';
+
+ private static final char C_COMMA = ',';
+
+ private static final boolean DEBUG = false;
+
+ /* ====================================================================== */
+ private boolean hanging_element = false;
+
+ /** True if we are processing the prolog. */
+ private boolean beforeDocumentStart = true;
+
+ /** True if we are processing the DTD. */
+ private boolean processing_dtd = false;
+
+ /** True if we are processing the DTD. */
+ private boolean processing_cdata = false;
+ /** The <code>DocType</code> instance representing the document. */
+ // protected DocType doctype = null;
+
+ protected int level;
+
+ protected char[] indentBuffer;
+
+
+ private Locator locator;
+
+ public static final String DEFAULT_ENCODING = "ISO-8859-1";
+
+ public JSContentHandler() {
+ }
+ /**
+ * @param outputWriter
+ */
+ public JSContentHandler(Writer outputWriter) {
+ this.outputWriter = outputWriter;
+ }
+ /**
+ * @throws java.io.IOException
+ */
+ public void close() throws IOException {
+ outputWriter.close();
+ }
+
+ // ContentHandler Methods
+ /* (non-Javadoc)
+ * @see org.xml.sax.ContentHandler#characters(char[], int, int)
+ */
+ public void characters(char[] ch, int start, int length)
+ throws SAXException {
+ if (this.beforeDocumentStart || level < 0)
+ return;
+ try {
+ if (!this.closeElement(false) && this.processing_cdata == false) {
+ this.outputWriter.write(C_COMMA);
+ }
+ if (DEBUG) {
+ this.outputWriter.write('[');
+ this.outputWriter.write(Integer.toString(level));
+ this.outputWriter.write(']');
+ }
+ if (this.processing_cdata == false) {
+ this.outputWriter.write(S_TEXT_START);
+ }
+ this.encode(ch, start, length);
+ if (this.processing_cdata == false) {
+ this.outputWriter.write(S_TEXT_END);
+ }
+ } catch (IOException e) {
+ throw new SAXException("Write error",e);
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.xml.sax.ContentHandler#endDocument()
+ */
+ public void endDocument() throws SAXException {
+ this.beforeDocumentStart = true;
+
+ if (this.level != 0) {
+ throw new SAXException(Messages.getMessage(Messages.OPEN_CLOSE_TAGS_DO_NOT_MATCH_ERROR));
+ }
+ // Write parameters after parsing and final function )
+ try {
+ this.outputWriter.write(S_EOL);
+ this.outputWriter.flush();
+ } catch (IOException e) {
+ throw new SAXException("Write error",e);
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public void endElement(String uri, String localName, String qName)
+ throws SAXException {
+ this.level--;
+ if (closeElement(true))
+ return;
+ try {
+ this.outputWriter.write(S_ELEMENT_END); // [</]
+ if (DEBUG) {
+ this.outputWriter.write('[');
+ this.outputWriter.write(qName);
+ this.outputWriter.write('-');
+ this.outputWriter.write(uri);
+ this.outputWriter.write(']');
+ }
+ } catch (IOException e) {
+ throw new SAXException("Write error",e);
+ }
+ // this.outputWriter.write(qual);
+ // this.outputWriter.write(C_GT); // [>]
+ }
+
+ /**
+ * Write the end part of a start element (if necessary).
+ *
+ * @param end_element
+ * Whether this method was called because an element is being
+ * closed or not.
+ * @return <b>true </b> if this call successfully closed the element (and no
+ * further <code></element></code> is required.
+ */
+ protected boolean closeElement(boolean end_element) throws SAXException {
+ if (!end_element && level == 0)
+ return true;
+
+ if (!hanging_element)
+ return (false);
+ try {
+ if (end_element)
+ this.outputWriter.write(S_ELEMENT_CLOSE); // [ />]
+ else
+ this.outputWriter.write(S_ELEMENT_END_START_TAG); // [>]
+ } catch (IOException e) {
+ throw new SAXException("Write error",e);
+ }
+ this.hanging_element = false;
+ return (true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
+ */
+ public void endPrefixMapping(String prefix) throws SAXException {
+
+ }
+ /* (non-Javadoc)
+ * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
+ */
+ public void ignorableWhitespace(char[] ch, int start, int length)
+ throws SAXException {
+ // TODO Auto-generated method stub
+
+ }
+ /* (non-Javadoc)
+ * @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String)
+ */
+ public void processingInstruction(String target, String data)
+ throws SAXException {
+ // TODO Auto-generated method stub
+
+ }
+ /* ====================================================================== */
+
+ /**
+ * Receive an object for locating the origin of SAX document events.
+ */
+ public final void setDocumentLocator(Locator locator) {
+ this.locator = locator;
+ }
+
+ /**
+ * Return the public identifier for the current document event.
+ *
+ * @return A <code>String</code> containing the public identifier,
+ * or <b>null</b> if none is available.
+ */
+ public String getPublicId() {
+ return(this.locator == null? null: this.locator.getPublicId());
+ }
+
+ /**
+ * Return the system identifier for the current document event.
+ *
+ * @return A <code>String</code> containing the system identifier,
+ * or <b>null</b> if none is available.
+ */
+ public String getSystemId() {
+ return(this.locator == null? null: this.locator.getSystemId());
+ }
+
+ /**
+ * Return the line number where the current document event ends.
+ *
+ * @return The line number, or -1 if none is available.
+ */
+ public int getLineNumber() {
+ return(this.locator == null? -1: this.locator.getLineNumber());
+ }
+
+ /**
+ * Return the column number where the current document event ends.
+ *
+ * @return The column number, or -1 if none is available.
+ */
+ public int getColumnNumber() {
+ return(this.locator == null? -1: this.locator.getColumnNumber());
+ }
+
+ /**
+ * Return a <code>String</code> describing the current location.
+ */
+ protected String getLocation() {
+ if (this.locator == null) return("");
+ StringBuffer buf = new StringBuffer(" (");
+ if (this.getSystemId() != null) {
+ buf.append(this.getSystemId());
+ buf.append(' ');
+ }
+ buf.append("line " + this.getLineNumber());
+ buf.append(" col " + this.getColumnNumber());
+ buf.append(')');
+ return(buf.toString());
+ }
+
+ /* ====================================================================== */
+ /* (non-Javadoc)
+ * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
+ */
+ public void skippedEntity(String name) throws SAXException {
+ // TODO Auto-generated method stub
+
+ }
+ /* (non-Javadoc)
+ * @see org.xml.sax.ContentHandler#startDocument()
+ */
+ public void startDocument() throws SAXException {
+ this.beforeDocumentStart = false;
+ this.processing_cdata = false;
+ this.level = 0;
+ /* We have a document type. */
+// if (this.doctype != null) {
+//
+// String root_name = this.doctype.getName();
+// /* Check the DTD and the root element */
+// if (!root_name.equals(qual)) {
+// throw new SAXException("Root element name \"" + root_name
+// + "\" declared by document type declaration differs "
+// + "from actual root element name \"" + qual + "\"");
+// }
+ /* Output the <!DOCTYPE ...> declaration. */
+ // this.outputWriter.write(this.doctype.toString());
+// }
+ }
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
+ */
+ public void startElement(String uri, String localName,
+ String qName, Attributes attributes) throws SAXException {
+ try {
+ if (!this.closeElement(false) && this.level > 0) {
+ this.outputWriter.write(C_COMMA);
+ }
+ this.outputWriter.write(S_ELEMENT_START); // [<]
+ if (DEBUG) {
+ this.outputWriter.write('[');
+ this.outputWriter.write(uri);
+ this.outputWriter.write(']');
+ }
+ this.outputWriter.write(C_QUOTE);
+ this.outputWriter.write(qName);
+ this.outputWriter.write(C_QUOTE);
+
+// if (attributes.getLength() > 0) {
+ this.outputWriter.write(S_ATTRIBUTES_START);
+ // TODO - implementing namespaces !
+ // for (int x = 0; x < namespaces.length; x++) {
+ // this.outputWriter.write(S_ELEMENT_4); // [ xmlns]
+ // if (namespaces[x][Namespaces.NAMESPACE_PREFIX].length() > 0) {
+ // this.outputWriter.write(C_NSSEP); // [:]
+ // this.outputWriter.write(namespaces[x][Namespaces.NAMESPACE_PREFIX]);
+ // }
+ // this.outputWriter.write(S_ELEMENT_1); // [="]
+ // this.encode(namespaces[x][Namespaces.NAMESPACE_URI]);
+ // this.outputWriter.write(C_QUOTE); // ["]
+ // }
+ for (int x = 0; x < attributes.getLength(); x++) {
+ if (0 != x) {
+ this.outputWriter.write(C_COMMA);
+ this.outputWriter.write(C_SPACE); // [ ]
+ }
+ if (DEBUG) {
+ this.outputWriter.write('[');
+ this.outputWriter.write(attributes.getURI(x));
+ this.outputWriter.write(']');
+ }
+ String attrName = attributes.getQName(x);
+ // For JavaScript any attributes names illegal ...
+ // replate with correct names.
+ if (attrName.equalsIgnoreCase("class")) {
+ attrName = "className";
+ }
+ this.outputWriter.write(C_QUOTE); // [']
+ this.outputWriter.write(attrName);
+ this.outputWriter.write(C_QUOTE); // [']
+ this.outputWriter.write(C_NSSEP); // [:]
+ this.encodeAttributeValue(attributes, x);
+ }
+
+ this.outputWriter.write(S_ATTRIBUTES_END);
+// }
+ this.level++;
+ this.hanging_element = true;
+ } catch (IOException e) {
+
+ throw new SAXException("write error",e);
+ }
+ }
+
+ protected void encodeAttributeValue(Attributes attributes, int idx) throws SAXException, IOException {
+ //TODO by nick - fix namespace handling
+ this.outputWriter.write(C_QUOTE); // [']
+ this.encode(attributes.getValue(idx));
+ this.outputWriter.write(C_QUOTE); // [']
+ }
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
+ */
+ public void startPrefixMapping(String prefix, String uri)
+ throws SAXException {
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
+ */
+ public void comment(char[] ch, int start, int length) throws SAXException {
+ if (this.beforeDocumentStart || level < 0)
+ return;
+ try {
+ if (!this.closeElement(false)) {
+ this.outputWriter.write(C_COMMA);
+ }
+ if (DEBUG) {
+ this.outputWriter.write('[');
+ this.outputWriter.write(Integer.toString(level));
+ this.outputWriter.write(']');
+ }
+// this.outputWriter.write(C_QUOTE);
+ this.outputWriter.write(S_COMMENT_START);
+ this.encode(ch, start, length);
+ this.outputWriter.write(S_COMMENT_END);
+// this.outputWriter.write(C_QUOTE);
+ } catch (IOException e) {
+ throw new SAXException("Write error",e);
+ }
+
+
+ }
+ /* (non-Javadoc)
+ * @see org.xml.sax.ext.LexicalHandler#endCDATA()
+ */
+ public void endCDATA() throws SAXException {
+ if (this.beforeDocumentStart || level < 0)
+ return;
+ try {
+ if (this.closeElement(false)) {
+ return;
+ }
+ if (DEBUG) {
+ this.outputWriter.write('[');
+ this.outputWriter.write(Integer.toString(level));
+ this.outputWriter.write(']');
+ }
+ this.outputWriter.write(S_CDATA_END);
+ this.processing_cdata = false;
+ } catch (IOException e) {
+ throw new SAXException("Write error",e);
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.xml.sax.ext.LexicalHandler#endDTD()
+ */
+ public void endDTD() throws SAXException {
+ // TODO Auto-generated method stub
+
+ }
+ /* (non-Javadoc)
+ * @see org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String)
+ */
+ public void endEntity(String name) throws SAXException {
+ // TODO Auto-generated method stub
+
+ }
+ /* (non-Javadoc)
+ * @see org.xml.sax.ext.LexicalHandler#startCDATA()
+ */
+ public void startCDATA() throws SAXException {
+ if (this.beforeDocumentStart || level < 0)
+ return;
+ try {
+ if (!this.closeElement(false)) {
+ this.outputWriter.write(C_COMMA);
+ }
+ if (DEBUG) {
+ this.outputWriter.write('[');
+ this.outputWriter.write(Integer.toString(level));
+ this.outputWriter.write(']');
+ }
+ this.outputWriter.write(S_CDATA_START);
+ this.processing_cdata = true;
+ } catch (IOException e) {
+ throw new SAXException("Write error",e);
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
+ */
+ public void startDTD(String name, String publicId, String systemId)
+ throws SAXException {
+ // TODO Auto-generated method stub
+
+ }
+ /* (non-Javadoc)
+ * @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
+ */
+ public void startEntity(String name) throws SAXException {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.cocoon.components.serializers.EncodingSerializer#writeIndent(int)
+ */
+ protected void writeIndent(int indent) throws SAXException {
+ try {
+ this.outputWriter.write("\n".toCharArray(), 0, 1);
+ if (indent > 0) {
+ this.outputWriter.write(assureIndentBuffer(indent), 0, indent);
+ }
+ } catch (IOException e) {
+ throw new SAXException("Write error",e);
+ }
+
+ }
+
+ private char[] assureIndentBuffer(int size) {
+ if (indentBuffer == null || indentBuffer.length < size) {
+ indentBuffer = new char[size];
+ Arrays.fill(indentBuffer, ' ');
+ }
+ return indentBuffer;
+ }
+
+ /**
+ * Encode and write a <code>String</code>
+ */
+ protected void encode(String data)
+ throws SAXException {
+ char array[] = data.toCharArray();
+ this.encode(array, 0, array.length);
+ }
+
+ /**
+ * Encode and write an array of characters.
+ */
+ protected void encode(char data[])
+ throws SAXException {
+ this.encode(data, 0, data.length);
+ }
+
+ /**
+ * Encode and write a specific part of an array of characters.
+ */
+ protected void encode(char data[], int start, int length)
+ throws SAXException {
+ int end = start + length;
+
+ if (data == null) throw new NullPointerException("Null data");
+ if ((start < 0) || (start > data.length) || (length < 0) ||
+ (end > data.length) || (end < 0))
+ throw new IndexOutOfBoundsException("Invalid data");
+ if (length == 0) return;
+
+ try {
+ for (int x = start; x < end; x++) {
+ char c = data[x];
+
+ if ( JSContentHandler.encoder.compile(c)) {
+ continue;
+ }
+
+ if (start != x) this.outputWriter.write(data, start, x - start );
+ this.outputWriter.write(JSContentHandler.encoder.encode(c));
+ start = x + 1;
+ continue;
+ }
+ if (start != end) this.outputWriter.write(data, start, end - start );
+ } catch (IOException e) {
+ throw new SAXException("Write error",e);
+ }
+ }
+
+}
Copied: trunk/richfaces/common/src/main/java/org/richfaces/renderkit/TemplateUtil.java (from rev 1117, trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/TemplateUtil.java)
===================================================================
--- trunk/richfaces/common/src/main/java/org/richfaces/renderkit/TemplateUtil.java (rev 0)
+++ trunk/richfaces/common/src/main/java/org/richfaces/renderkit/TemplateUtil.java 2007-06-15 00:03:21 UTC (rev 1193)
@@ -0,0 +1,71 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * 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.renderkit;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.richfaces.org.apache.commons.lang.StringEscapeUtils;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 11.12.2006
+ *
+ */
+public class TemplateUtil {
+
+ public static interface MacroTemplateHandler {
+ public String handle(String body);
+ };
+
+ private final static Pattern PARAMETER_REPLACER_PATTERN = Pattern.compile("(\\\\)?\\{([^\\}]+)\\}");
+
+ public static String replaceParams(String string, MacroTemplateHandler handler) {
+ Matcher m = PARAMETER_REPLACER_PATTERN.matcher(string);
+ StringBuffer sb = new StringBuffer("\"");
+
+ int lastPosition = 0;
+
+ while (m.find()) {
+ String firstGroup = m.group(1);
+ if (firstGroup == null || firstGroup.length() == 0) {
+ sb.append(StringEscapeUtils.escapeJavaScript(string.substring(lastPosition, m.start(2) - 1)));
+ sb.append("\" + " + handler.handle(m.group(2)) + " + \"");
+ } else {
+ StringBuffer sbUnEsc = new StringBuffer();
+ sbUnEsc.append(string.substring(lastPosition, m.end(1) - 1));
+ sbUnEsc.append("{");
+ sbUnEsc.append(m.group(2));
+ sbUnEsc.append("}");
+
+ sb.append(StringEscapeUtils.escapeJavaScript(sbUnEsc.toString()));
+ }
+
+ lastPosition = m.end(2) + 1;
+ }
+ if (lastPosition < string.length()) {
+ sb.append(StringEscapeUtils.escapeJavaScript(string.substring(lastPosition)));
+ }
+ sb.append("\"");
+ return sb.toString();
+ }
+}
Added: trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js
===================================================================
--- trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js (rev 0)
+++ trunk/richfaces/common/src/main/resources/org/richfaces/renderkit/html/scripts/json/json-dom.js 2007-06-15 00:03:21 UTC (rev 1193)
@@ -0,0 +1,195 @@
+// AJAX-JSF AJAX-like library, for communicate with view Tree on server side.
+// In case of XMLHttpRequest don't worked, use :
+// JSHttpRequest v1.12. (C) Dmitry Koterov, 2005-01-27.
+// http://forum.dklab.ru/users/DmitryKoterov/
+//
+// Do not remove this comment if you want to use script!
+// ?? ???????? ?????? ???????????, ???? ?? ?????? ???????????? ??????!
+//
+// Modified by Alexander J. Smirnov to use as JSF AJAX-like components.
+
+ JSDocument = function(js) {
+// AJAX_Log( " Response document "+Dump(js,1));
+// AJAX_Log( " Response document buildCache: "+typeof(js.buildCache));
+ this.idsCache = {};
+ js.buildCache(this.idsCache);
+ this.documentElement = js;//this._parseJS(js);
+ }
+
+// DOM document like class for parsing javaScript response.
+ JSDocument.prototype = {
+// idsCache: {},
+
+
+// documentElement : null,
+
+
+ getElementById: function( elementId ){
+ return this.idsCache[elementId];
+ },
+
+ getElementsByTagName: function( tagname ){
+ return [];
+ },
+ createElement: function(js){
+ return new E(js.tag);
+ },
+
+
+ createTextNode: function(text){
+ return new T(text);
+ },
+
+ createComment: function(text){
+ return new C(text);
+ },
+
+ createCDATASection: function(text){
+ return new D(text);
+ }
+
+
+ }
+
+// DOM - like elements for JSRequest. JS serialiser encode
+// XML sax events to creation of corresponding objects.
+ JSNode = function(){
+// this.tag = null;
+// this.attrs = {};
+// this.childs = [];
+// this.value = "";
+ };
+
+ JSNode.prototype = {
+ tag : null,
+ attrs : {},
+ childs : [],
+ parentNode : null,
+ value : "",
+ _symbols : {
+ '&':"&",
+ '<':"<",
+ '>':">",
+ '"':""",
+ '\'':"'",
+ '\u00A0':" "
+ },
+ // Public functions
+ getAttribute : function(aname) {
+ return this.attrs[aname];
+ },
+ setAttribute : function(aname,avalue){
+ this.attrs[aname]=avalue;
+ },
+ getInnerHTML : function(context){
+ var html = "";
+ for( var i = 0; i < this.childs.length; i++ ){
+ html += this.childs[i].getOuterHTML(context);
+ }
+ return html;
+ },
+// getOuterHTML : function(){return ""},
+
+ appendChild : function(child){
+ this.childs[this.childs.length]=child;
+ child.parentNode = this;
+ },
+
+ buildCache : function(cache){
+ if(this.attrs.id){
+ cache[this.attrs.id]=this;
+ }
+ for( var i in this.childs ){
+ this.childs[i].buildCache(cache);
+ this.childs[i].parentNode = this;
+ }
+ },
+
+ // TODO - make real clone ...
+ cloneNode : function(withChildren){
+ },
+
+ // Escape XML symbols - < > & ' ...
+ xmlescape : function(text){
+ for( var i in this._symbols ){
+// text = text.replace(i,this._symbols[i]);
+ text = text.split(i).join(this._symbols[i])
+ }
+ return text;
+ },
+
+ // Escape JavaScript function
+ JSEscape : function(text){
+// for( var i in this._symbols ){
+// text = text.replace(i,this._symbols[i]);
+// text = text.split(i).join(this._symbols[i])
+// }
+ return text;
+ }
+ }
+ // Element node
+ E = function(tagname,attributes,childnodes){
+
+ this.tag = tagname;
+ this.attrs = attributes;
+ if(childnodes){
+ this.childs = childnodes;
+ } else {
+ this.childs = [];
+ }
+ };
+
+ E.prototype = new JSNode();
+ E.prototype.getOuterHTML = function(context){
+ // AJAX_Log("Get Outer HTML for object:"+Dump(this);
+ var html = "<"+this.tag;
+ var inner = this.getInnerHTML();
+ for( var i in this.attrs ){
+ var attrValue = this.attrs[i];
+ if (typeof attrValue == "function") {
+ attrValue = attrValue(context);
+ }
+
+ if (attrValue) {
+ html += " "+(i=='className'?'class':i)+'="'+(i.substring(0,2)=="on"?this.JSEscape(attrValue):this.xmlescape(attrValue))+'"';
+ // html+= " "+i+'="'+this.xmlescape(this.attrs[i])+'"';
+ }
+ }
+ if(inner == ""){
+ html+= " />";
+ } else {
+ html+= " >"+inner+"</"+this.tag+">";
+ }
+ return html;
+ };
+
+ // Text node
+ T = function(text) {
+ this.value = text;
+ }
+
+ T.prototype = new JSNode();
+ T.prototype.getOuterHTML = function(context){
+ return this.xmlescape(this.value);
+ }
+
+ // Comment node
+ C = function(text) {
+ this.value = text;
+ }
+
+ C.prototype = new JSNode();
+ C.prototype.getOuterHTML = function(context){
+ return "<!--"+this.value+"-->";
+ }
+
+ // CDATA Section node.
+ D = function(text) {
+ this.value = text;
+ }
+
+ D.prototype = new JSNode();
+ D.prototype.getOuterHTML = function(context){
+ return "<![CDATA["+this.value+"]]>";
+ }
+
Modified: trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java
===================================================================
--- trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java 2007-06-14 19:19:27 UTC (rev 1192)
+++ trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/DragIndicatorRendererBase.java 2007-06-15 00:03:21 UTC (rev 1193)
@@ -37,6 +37,7 @@
import org.richfaces.component.UIDragIndicator;
import org.richfaces.component.nsutils.NSUtils;
import org.richfaces.org.apache.commons.lang.StringEscapeUtils;
+import org.richfaces.renderkit.TemplateUtil.MacroTemplateHandler;
/**
* Base renderer class for drag indicator ( marker ).
@@ -44,6 +45,16 @@
*
*/
public class DragIndicatorRendererBase extends HeaderResourcesRendererBase {
+ private final static MacroTemplateHandler macroTemplateHandler = new MacroTemplateHandler() {
+
+ public String handle(String body) {
+ String paramAccess = "jsParams['" + body + "']";
+
+ return ("((!!" + paramAccess + ") ? " + paramAccess + " : \"\")");
+ }
+
+ };
+
public static final String ACCEPT_CLASS = "acceptClass";
public static final String REJECT_CLASS = "rejectClass";
public static final String RENDERER_TYPE = "com.exadel.jsf.renderer.DropIndicatorRenderer";
@@ -176,7 +187,7 @@
responseWriter.write("elt.indicatorTemplates['" + facetName + "'] = function(element, jsParams) {\n");
responseWriter.write("var content = ");
- String result = TemplateUtil.replaceParams(dumpWriter.getBuffer().toString(), "jsParams");
+ String result = TemplateUtil.replaceParams(dumpWriter.getBuffer().toString(), macroTemplateHandler);
responseWriter.write(result + ";\n new Insertion.Top(element, content);\n");
responseWriter.write("};");
}
Deleted: trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/TemplateUtil.java
===================================================================
--- trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/TemplateUtil.java 2007-06-14 19:19:27 UTC (rev 1192)
+++ trunk/richfaces/drag-drop/src/main/java/org/richfaces/renderkit/TemplateUtil.java 2007-06-15 00:03:21 UTC (rev 1193)
@@ -1,74 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * 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.renderkit;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.richfaces.org.apache.commons.lang.StringEscapeUtils;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 11.12.2006
- *
- */
-public class TemplateUtil {
-
- private final static Pattern PARAMETER_REPLACER_PATTERN = Pattern.compile("(\\\\)?\\{([^\\}]+)\\}");
-
- public static String replaceParams(String string, String paramsVarName) {
- Matcher m = PARAMETER_REPLACER_PATTERN.matcher(string);
- StringBuffer sb = new StringBuffer("\"");
-
- int lastPosition = 0;
-
- while (m.find()) {
- String firstGroup = m.group(1);
- if (firstGroup == null || firstGroup.length() == 0) {
- sb.append(StringEscapeUtils.escapeJavaScript(string.substring(lastPosition, m.start(2) - 1)));
-
- String paramAccess = paramsVarName + "['" + m.group(2) + "']";
-
- sb.append("\" + ((!!" + paramAccess + ") ? " + paramAccess + " : \"\") + \"");
- } else {
- StringBuffer sbUnEsc = new StringBuffer();
- sbUnEsc.append(string.substring(lastPosition, m.end(1) - 1));
- sbUnEsc.append("{");
- sbUnEsc.append(m.group(2));
- sbUnEsc.append("}");
-
- sb.append(StringEscapeUtils.escapeJavaScript(sbUnEsc.toString()));
- }
-
- lastPosition = m.end(2) + 1;
- }
- if (lastPosition < string.length()) {
- sb.append(StringEscapeUtils.escapeJavaScript(string.substring(lastPosition)));
- }
- sb.append("\"");
- return sb.toString();
- }
-
- public static void main(String[] args) {
- System.out.println(TemplateUtil.replaceParams("test string \" \n with \\{pa\\rams} {name} \"and {value}1", "params"));
- }
-}
Modified: trunk/sandbox/calendar/pom.xml
===================================================================
--- trunk/sandbox/calendar/pom.xml 2007-06-14 19:19:27 UTC (rev 1192)
+++ trunk/sandbox/calendar/pom.xml 2007-06-15 00:03:21 UTC (rev 1193)
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
- <artifactId>sandbox-parent</artifactId>
+ <artifactId>richfaces-parent</artifactId>
<groupId>org.richfaces</groupId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>3.0.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.richfaces</groupId>
@@ -17,14 +17,14 @@
<version>1.1.2-SNAPSHOT</version>
<executions>
<execution>
- <id>generate-sources</id>
+ <id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
<execution>
- <id>generate-test-sources</id>
+ <id>generate-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>generate-tests</goal>
@@ -50,3 +50,4 @@
</dependency>
</dependencies>
</project>
+
Modified: trunk/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java
===================================================================
--- trunk/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-06-14 19:19:27 UTC (rev 1192)
+++ trunk/sandbox/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-06-15 00:03:21 UTC (rev 1193)
@@ -1,5 +1,22 @@
/**
+ * License Agreement.
*
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * 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.component;
@@ -12,7 +29,7 @@
*/
public abstract class UICalendar extends UIComponentBase {
- private static final String COMPONENT_TYPE = "org.richfaces.Calendar";
+ public static final String COMPONENT_TYPE = "org.richfaces.Calendar";
private static final String COMPONENT_FAMILY = "org.richfaces.Calendar";
Added: trunk/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
--- trunk/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java (rev 0)
+++ trunk/sandbox/calendar/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2007-06-15 00:03:21 UTC (rev 1193)
@@ -0,0 +1,157 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * 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.renderkit;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Properties;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.stream.StreamSource;
+
+import org.ajax4jsf.framework.ajax.xmlfilter.tidy.TidyParser;
+import org.ajax4jsf.framework.ajax.xmlfilter.tidy.TidyXMLFilter;
+import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
+import org.richfaces.component.UICalendar;
+import org.richfaces.json.JSContentHandler;
+import org.richfaces.org.apache.commons.lang.StringEscapeUtils;
+import org.richfaces.renderkit.TemplateUtil.MacroTemplateHandler;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Nick Belaevski - mailto:nbelaevski@exadel.com
+ * created 08.06.2007
+ *
+ */
+public class CalendarRendererBase extends HeaderResourcesRendererBase {
+
+ private static final MacroTemplateHandler macroTemplateHandler = new MacroTemplateHandler() {
+
+ public String handle(String body) {
+ return "calendarEval(\"" +
+ StringEscapeUtils.escapeJavaScript(body) + "\", context)";
+ }
+
+ };
+
+ private TransformerFactory transformerFactory;
+
+ public CalendarRendererBase() {
+ super();
+
+ transformerFactory = TransformerFactory.newInstance();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.renderer.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ return UICalendar.class;
+ }
+
+ public boolean getRendersChildren() {
+ return true;
+ }
+
+ public void encodeChildren(FacesContext context, UIComponent component)
+ throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ StringWriter dumpingWriter = new StringWriter();
+ ResponseWriter clonedWriter = writer.cloneWithWriter(dumpingWriter);
+ context.setResponseWriter(clonedWriter);
+ try {
+ renderChildren(context, component);
+ } finally {
+ clonedWriter.flush();
+ context.setResponseWriter(writer);
+ }
+
+ Properties tidyProperties = new Properties();
+ InputStream propertiesStream = null;
+ try {
+ propertiesStream = TidyXMLFilter.class.getResourceAsStream("tidy.properties");
+ tidyProperties.load(propertiesStream);
+ } finally {
+ if (propertiesStream != null) {
+ propertiesStream.close();
+ }
+ }
+
+ TidyParser tidyParser = new TidyParser(tidyProperties);
+ Document parsedHtml = tidyParser.parseHtmlByTidy(new StringReader(dumpingWriter.toString()), null);
+ NodeList nodeList = parsedHtml.getDocumentElement().getChildNodes();
+ Node bodyNode = nodeList.item(nodeList.getLength() - 1);
+ NodeList bodyChildren = bodyNode.getChildNodes();
+ int bodyChildrenLength = bodyChildren.getLength();
+
+ writer.startElement("script", component);
+ writer.write("var calendarEval = function (string, context) { return string; };");
+
+ writer.write("var evaluator = new Object(); evaluator.parts = [ ");
+
+ try {
+ Transformer transformer = transformerFactory.newTransformer();
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+
+ JSContentHandler contentHandler = new JSContentHandler(writer) {
+ protected void encodeAttributeValue(Attributes attributes,
+ int idx) throws SAXException, IOException {
+
+ String value = attributes.getValue(idx);
+ outputWriter.write("function (context) { return " + TemplateUtil.replaceParams(value, macroTemplateHandler) + ";}");
+ }
+ };
+ Result result = new SAXResult(contentHandler);
+
+ for (int i = 0; i < bodyChildrenLength; i++) {
+ if (i != 0) {
+ writer.write(", ");
+ }
+ transformer.transform(new DOMSource(bodyChildren.item(i)), result);
+ }
+ } catch (TransformerException e) {
+ throw new IOException(e.getMessage(), e);
+ }
+
+ writer.write("]; evaluator.evaluate = function (context) { var result = '';");
+ writer.write(" for (var i = 0; i < this.parts.length; i++) result += this.parts[i].getOuterHTML(context); return result;};\n");
+
+ writer.write("new Insertion.Top($('" + component.getClientId(context) + "'), evaluator.evaluate(null));");
+ writer.endElement("script");
+ }
+}
Modified: trunk/sandbox/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- trunk/sandbox/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-06-14 19:19:27 UTC (rev 1192)
+++ trunk/sandbox/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-06-15 00:03:21 UTC (rev 1193)
@@ -5,13 +5,17 @@
xmlns:ui=" http://ajax4jsf.org/cdk/ui"
xmlns:u=" http://ajax4jsf.org/cdk/u"
xmlns:x=" http://ajax4jsf.org/cdk/x"
+ xmlns:vcp=" http://ajax4jsf.org/cdk/vcp"
class="org.richfaces.renderkit.html.CalendarRenderer"
- baseclass="org.ajax4jsf.framework.renderer.AjaxComponentRendererBase"
+ baseclass="org.richfaces.renderkit.CalendarRendererBase"
component="org.richfaces.component.UICalendar"
>
<f:clientid var="clientId"/>
+ <h:scripts>new org.ajax4jsf.framework.resource.PrototypeScript(),/org/richfaces/renderkit/html/scripts/json/json-dom.js</h:scripts>
<div id="#{clientId}"
x:passThruWithExclusions="value,name,type,id"
>
+
+ <vcp:body />
</div>
</f:root>
\ No newline at end of file
Added: trunk/sandbox/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java
===================================================================
--- trunk/sandbox/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java (rev 0)
+++ trunk/sandbox/calendar/src/test/java/org/richfaces/component/CalendarComponentTest.java 2007-06-15 00:03:21 UTC (rev 1193)
@@ -0,0 +1,40 @@
+/**
+ *
+ */
+package org.richfaces.component;
+
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlOutputText;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author Nick Belaevski - mailto:nbelaevski@exadel.com
+ * created 08.06.2007
+ *
+ */
+public class CalendarComponentTest extends AbstractAjax4JsfTestCase {
+
+ public CalendarComponentTest(String name) {
+ super(name);
+ }
+
+ public void testTidy() throws Exception {
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ List children = viewRoot.getChildren();
+ UIComponent calendar = application.createComponent(UICalendar.COMPONENT_TYPE);
+ children.add(calendar);
+ HtmlOutputText output = (HtmlOutputText) application.createComponent(HtmlOutputText.COMPONENT_TYPE);
+ output.setValue("<br> &<a href='#'>");
+ output.setEscape(false);
+ calendar.getChildren().add(output);
+
+ HtmlPage renderView = renderView();
+ System.out.println(renderView.asXml());
+ }
+}
17 years, 7 months
JBoss Rich Faces SVN: r1192 - in trunk/sandbox/scrollable-grid/src/main/java/org/richfaces: model/impl and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-06-14 15:19:27 -0400 (Thu, 14 Jun 2007)
New Revision: 1192
Added:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ArrayDataModel.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ListDataModel.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/SimpleGridDataModel.java
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
Log:
added implementations for array and list data models
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-06-14 17:45:11 UTC (rev 1191)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-06-14 19:19:27 UTC (rev 1192)
@@ -6,14 +6,15 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
+import java.util.List;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
-import javax.faces.model.DataModel;
import org.ajax4jsf.ajax.repeat.DataComponentState;
import org.ajax4jsf.ajax.repeat.DataVisitor;
@@ -24,12 +25,16 @@
import org.ajax4jsf.framework.ajax.AjaxContext;
import org.ajax4jsf.framework.ajax.AjaxEvent;
import org.apache.commons.collections.iterators.IteratorChain;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.richfaces.event.scroll.ScrollEvent;
import org.richfaces.event.sort.SortEvent;
-import org.richfaces.model.ScrollableGridRange;
import org.richfaces.model.DataModelCache;
import org.richfaces.model.GridDataModel;
+import org.richfaces.model.ScrollableGridRange;
import org.richfaces.model.SortOrder;
+import org.richfaces.model.impl.ArrayDataModel;
+import org.richfaces.model.impl.ListDataModel;
@@ -41,8 +46,11 @@
public abstract class UIScrollableGrid extends UIRepeat implements AjaxComponent, Sortable, Selectable{
+
public static final String COMPONENT_TYPE = "org.richfaces.component.ScrollableGrid";
+ private final static Log log = LogFactory.getLog(UIScrollableGrid.class);
+
private transient Collection partialUpdateChildren;
private Collection responseData = new ArrayList();
@@ -108,11 +116,57 @@
Object value = getValue();
+ GridDataModel model = null;
+
if (value instanceof GridDataModel) {
- return new DataModelCache((GridDataModel) value);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Found instanceof " + value.getClass() + " will use it unwrapped");
+ }
+
+ model = (GridDataModel) value;
+
+ } else if (value instanceof List) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Found instanceof " + value.getClass() + " - will wrap it into " + ListDataModel.class);
+ }
+
+ model = new ListDataModel((List) value);
+
+ }else if (value instanceof Object[]) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Found instanceof " + value.getClass() + " - will wrap it into " + ArrayDataModel.class);
+ }
+
+ model = new ArrayDataModel((Object[]) value);
+
+ } else if (value == null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Found null value - will wrap it into empty " + ListDataModel.class);
+ }
+
+ model = new ListDataModel(Collections.EMPTY_LIST);
+ } else {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Found instanceof " + value.getClass() + " - will wrap it into singleton " + ListDataModel.class);
+ }
+
+ model = new ListDataModel(Collections.singletonList(value));
}
- return null;
+ if (isCacheable()) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Initializing cache of type " + DataModelCache.class);
+ }
+
+ model = new DataModelCache(model);
+ }
+
+ return model;
}
@@ -223,10 +277,6 @@
super.walk(context, visitor, argument);
}
- public DataModel getStoredDataModel() {
- return super.getDataModel();
- }
-
public Collection getPartialUpdateChildren() {
if (partialUpdateChildren == null) {
@@ -241,4 +291,8 @@
super.encodeEnd(context);
partialUpdateChildren = null;
}
+
+ public boolean isCacheable() {
+ return true;
+ }
}
Added: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ArrayDataModel.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ArrayDataModel.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ArrayDataModel.java 2007-06-14 19:19:27 UTC (rev 1192)
@@ -0,0 +1,90 @@
+/**
+ *
+ */
+package org.richfaces.model.impl;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.richfaces.model.SortOrder;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class ArrayDataModel extends SimpleGridDataModel {
+
+ private Object [] data;
+
+ public ArrayDataModel() {
+ this(null);
+ }
+
+ public ArrayDataModel(Object [] data) {
+ super();
+ setWrappedData(data);
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.richfaces.model.GridDataModel#loadData(int, int, org.richfaces.model.SortOrder)
+ */
+ public List loadData(int startRow, int endRow, SortOrder sortOrder) {
+
+ if (data != null && getRowCount() > 0) {
+ Object [] sortedList = data;
+
+ if (sortOrder != null) {
+
+ sortedList = new Object[data.length];
+
+ System.arraycopy(data, 0, sortedList, 0, data.length);
+
+ Comparator comparator = createComparator(sortOrder);
+
+ if (comparator == null) {
+
+ Arrays.sort(sortedList);
+
+ } else {
+
+ Arrays.sort(sortedList, comparator);
+
+ }
+
+ }
+
+ Object [] subArray = new Object[endRow - startRow];
+
+ System.arraycopy(sortedList, startRow, subArray, 0, subArray.length);
+
+ return Arrays.asList(subArray);
+ }
+
+ return Collections.EMPTY_LIST;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowCount()
+ */
+ public int getRowCount() {
+ return data == null ? 0 : data.length;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getWrappedData()
+ */
+ public Object getWrappedData() {
+ return data;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
+ */
+ public void setWrappedData(Object data) {
+ this.data = (Object[]) data;
+ }
+}
Added: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ListDataModel.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ListDataModel.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ListDataModel.java 2007-06-14 19:19:27 UTC (rev 1192)
@@ -0,0 +1,84 @@
+/**
+ *
+ */
+package org.richfaces.model.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.richfaces.model.SortOrder;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class ListDataModel extends SimpleGridDataModel {
+
+ private List data;
+
+ public ListDataModel() {
+ this(null);
+ }
+
+ public ListDataModel(List data) {
+ super();
+ setWrappedData(data);
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.richfaces.model.GridDataModel#loadData(int, int, org.richfaces.model.SortOrder)
+ */
+ public List loadData(int startRow, int endRow, SortOrder sortOrder) {
+
+ if (data != null && getRowCount() > 0) {
+ List sortedList = data;
+
+ if (sortOrder != null) {
+ sortedList = new ArrayList(data);
+
+ Comparator comparator = createComparator(sortOrder);
+
+ if (comparator == null) {
+
+ Collections.sort(sortedList);
+
+ } else {
+
+ Collections.sort(sortedList, comparator);
+
+ }
+
+ }
+
+ return sortedList.subList(startRow, endRow);
+ }
+
+ return Collections.EMPTY_LIST;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowCount()
+ */
+ public int getRowCount() {
+ return data == null ? 0 : data.size();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getWrappedData()
+ */
+ public Object getWrappedData() {
+ return data;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
+ */
+ public void setWrappedData(Object data) {
+ this.data = (List) data;
+ }
+
+}
Added: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/SimpleGridDataModel.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/SimpleGridDataModel.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/SimpleGridDataModel.java 2007-06-14 19:19:27 UTC (rev 1192)
@@ -0,0 +1,14 @@
+package org.richfaces.model.impl;
+
+import java.util.Comparator;
+
+import org.richfaces.model.GridDataModel;
+import org.richfaces.model.SortOrder;
+
+public abstract class SimpleGridDataModel extends GridDataModel {
+
+ protected Comparator createComparator(SortOrder sortOrder) {
+ return new PropertyResolverComparator(sortOrder);
+ }
+
+}
17 years, 7 months
JBoss Rich Faces SVN: r1191 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-14 13:45:11 -0400 (Thu, 14 Jun 2007)
New Revision: 1191
Removed:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IOExceptionWrapper.java
Log:
Deleted: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IOExceptionWrapper.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IOExceptionWrapper.java 2007-06-14 17:20:40 UTC (rev 1190)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IOExceptionWrapper.java 2007-06-14 17:45:11 UTC (rev 1191)
@@ -1,28 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2007
- * All rights reserved.
- *
- * History
- * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/IOExceptionWrapper.java,v $
- * $Revision: 1.1 $
- */
-
-package org.richfaces.model;
-
-import java.io.IOException;
-
-public final class IOExceptionWrapper extends RuntimeException {
- private static final long serialVersionUID = -1173652671552790659L;
-
- private IOException wrappedException;
-
- public IOExceptionWrapper(IOException wrapped) {
- super();
- this.wrappedException = wrapped;
- }
-
- public IOException getWrappedException() {
- return wrappedException;
- }
-}
\ No newline at end of file
17 years, 7 months
JBoss Rich Faces SVN: r1190 - in trunk: sandbox/scrollable-grid/src/main/java/org/richfaces/model and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-06-14 13:20:40 -0400 (Thu, 14 Jun 2007)
New Revision: 1190
Added:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridRange.java
Removed:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/ChannelDataModel.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/SelectionBean.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/BufferedSequenceRange.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataRange.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/Entity.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridDataModelFeatures.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridRange.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IterationBounds.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridDataModel.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SequenceRange.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ArrayDataModelExt.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ArrayDataRange.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ListDataModelExt.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ListDataRange.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/SequenceDataModelExt.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/snapshot/
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/ChannelDataModel2.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Channel.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Issue.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataModelCache.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java
Log:
removed most of intralinks legacy code
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -7,7 +7,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
-import java.util.List;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -27,13 +26,10 @@
import org.apache.commons.collections.iterators.IteratorChain;
import org.richfaces.event.scroll.ScrollEvent;
import org.richfaces.event.sort.SortEvent;
-import org.richfaces.model.BufferedSequenceRange;
+import org.richfaces.model.ScrollableGridRange;
import org.richfaces.model.DataModelCache;
import org.richfaces.model.GridDataModel;
-import org.richfaces.model.ScrollableGridDataModel;
import org.richfaces.model.SortOrder;
-import org.richfaces.model.impl.ArrayDataModelExt;
-import org.richfaces.model.impl.ListDataModelExt;
@@ -104,34 +100,19 @@
rows = -1;
}
- BufferedSequenceRange range = new BufferedSequenceRange(curentRow,rows);
- range.setSortOrder(getSortOrder());
-
- return range;
+ return new ScrollableGridRange(curentRow,rows, getSortOrder());
}
};
}
protected ExtendedDataModel createDataModel() {
- ScrollableGridDataModel model = null;
Object value = getValue();
if (value instanceof GridDataModel) {
return new DataModelCache((GridDataModel) value);
}
- if (value instanceof ScrollableGridDataModel) {
- ScrollableGridDataModel dataModel = (ScrollableGridDataModel) value;
- model = dataModel;
- } else if (value instanceof List) {
- model = new ListDataModelExt((List)value);
- } else if (value instanceof Object []) {
- model = new ArrayDataModelExt((Object[]) value);
- } else {
- model = new ArrayDataModelExt(new Object[]{value});
- }
-
- return model;
+ return null;
}
Deleted: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/BufferedSequenceRange.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/BufferedSequenceRange.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/BufferedSequenceRange.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -1,67 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/BufferedSequenceRange.java,v $
- * $Revision: 1.7 $
- */
-
-package org.richfaces.model;
-
-
-
-/**
- * @author Maksim Kaszynski
- * @modified by Anton Belevich
- */
-public class BufferedSequenceRange extends GridRange{
-
- private int first = 0;
- private int last = 0;
- private boolean readOnly;
-
- public IterationBounds getIterationBounds() {
- return new IterationBounds(this.first, this.last);
- }
-
- public boolean isReadOnly() {
- return readOnly;
- }
-
- public void setReadOnly(boolean readOnly) {
- this.readOnly = readOnly;
- }
-
- public BufferedSequenceRange(int first, int last) {
- super();
- this.first = first;
- this.last = last;
- }
-
- /**
- * @return the bufferSize
- */
- public int getLast() {
- return last;
- }
- /**
- * @param bufferSize the bufferSize to set
- */
- public void setLast(int lastRow) {
- this.last = lastRow;
- }
- /**
- * @return the first
- */
- public int getFirst() {
- return first;
- }
- /**
- * @param first the first to set
- */
- public void setFirst(int first) {
- this.first = first;
- }
-}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataModelCache.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataModelCache.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataModelCache.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -18,6 +18,8 @@
import org.apache.commons.logging.LogFactory;
/**
+ * Implementation stores last loaded data, so no additional requests to db will be performed
+ * Acts as a proxy between the component and original data model
* @author Maksim Kaszynski
*
*/
@@ -64,6 +66,7 @@
private GridDataModel gridDataModel;
+ private int rowCount = Integer.MIN_VALUE;
public DataModelCache(GridDataModel gridDataModel) {
super();
@@ -87,7 +90,8 @@
if (log.isDebugEnabled()) {
log.debug("Trying to get object by id" + id);
}
-
+ //First try to find data in inner cache
+ //If not fo9und - get it from original model
Object cached = secondaryMapping.get(id);
if (cached == null) {
@@ -109,7 +113,10 @@
}
public int getRowCount() {
- return gridDataModel.getRowCount();
+ if (rowCount == Integer.MIN_VALUE) {
+ rowCount = gridDataModel.getRowCount();
+ }
+ return rowCount;
}
public Object getRowData() {
Deleted: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataRange.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataRange.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/DataRange.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -1,76 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/DataRange.java,v $
- * $Revision: 1.5 $
- */
-
-package org.richfaces.model;
-
-
-/**
- * Data window wrapper.
- * Instance should be able to access any object within current data window.
- * Subclasses can be built around any data source, (e.g. ResultSet, ScrollableResult or simple List).
- *
- *
- * @author Maksim Kaszynski
- *
- */
-public abstract class DataRange {
- private SortOrder sortOrder;
- private int startRow;
- private int endRow;
-
- /**
- * Construct a DataRange object.
- * @param startRow
- * @param endRow
- * @param sortOrder
- */
- public DataRange(int startRow, int endRow, SortOrder sortOrder) {
- super();
- this.sortOrder = sortOrder;
- this.startRow = startRow;
- this.endRow = endRow;
- }
- /**
- * @return the endRow
- */
- public int getEndRow() {
- return endRow;
- }
- /**
- * @return the sortOrder
- */
- public SortOrder getSortOrder() {
- return sortOrder;
- }
- /**
- * @return the startRow
- */
- public int getStartRow() {
- return startRow;
- }
-
- /**
- * test if specified absolute index lies within this data range
- * @param index
- * @return
- */
- public boolean hit(int index) {
- return index >= startRow && index < endRow;
- }
-
- /**
- * Implementations should define this method to get object at given absolute position.
- *
- * @param index - absolute index of record within entire recordset, NOT relative to the start of data range.
- * @return object at given position within whole recordset.
- */
- public abstract Object getRowData(int index);
-
-}
Deleted: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/Entity.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/Entity.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/Entity.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -1,13 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public interface Entity {
- public Object getId();
-}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridDataModel.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -18,11 +18,22 @@
import org.apache.commons.logging.LogFactory;
/**
+ * Base class for data models
+ * Subclasses must implement {@link #loadData(int, int, SortOrder)}
+ * For certain features (like selection and sorting) to work correctly together,
+ * {@link #getId(Object)} and {@link #getObjectById(Object)}
+ * methods need to be overriden
+ *
* @author Maksim Kaszynski
*
*/
public abstract class GridDataModel extends ExtendedDataModel {
-
+
+ /**
+ * Simple implementation - index-based row key
+ * @author Maksim Kaszynski
+ *
+ */
private static class SimpleRowKey implements Serializable{
private static final long serialVersionUID = 1L;
@@ -51,14 +62,20 @@
private SortOrder lastSortOrder;
- public Object getRowKey() {
- return rowKey;
- }
+ /**
+ * Load range of data items from the source.
+ * Starting from startRow, and up to but excluding endRow
+ * @param startRow
+ * @param endRow
+ * @param sortOrder
+ * @return list of ordered data
+ */
+ public abstract List loadData(int startRow, int endRow, SortOrder sortOrder);
- public void setRowKey(Object key) {
- rowKey = key;
- }
-
+
+ /**
+ * Load data range, and iterate over it
+ */
public void walk(FacesContext context, DataVisitor visitor, Range range,
Object argument) throws IOException {
@@ -66,7 +83,7 @@
log.trace("Starting walk");
}
- BufferedSequenceRange sequenceRange = (BufferedSequenceRange) range;
+ ScrollableGridRange sequenceRange = (ScrollableGridRange) range;
int startIndex = sequenceRange.getFirst();
int last = sequenceRange.getLast();
@@ -97,18 +114,10 @@
}
- /**
- * Load range of data items from the source
- * @param startRow
- * @param endRow
- * @param sortOrder
- * @return
- */
- public abstract List loadData(int startRow, int endRow, SortOrder sortOrder);
/**
- * This method is the reverse of getObjectId
- * Default implementation returns null anyway
+ * This method is the reverse of {@link #getId(Object)}
+ * If you override this method, you need to override {@link #getId(Object)} as well
* @param id
* @return
*/
@@ -130,6 +139,8 @@
* To get rid of Entity interface, method is introduced
* Implementations may override it to provide domain-specific searches
* Id should be serializable
+ * Default implementation returns <code>null</code> anyway
+ * If you override this method, you need to override {@link #getObjectById(Object)} as well
* @param o
* @return
*/
@@ -138,22 +149,6 @@
}
- private Object loadAndMap(Object id) {
-
- if (log.isTraceEnabled()) {
- log.trace("loadAndMap " + id);
- }
-
- Object o = getObjectById(id);
- if (o != null) {
- if (mapping == null) {
- mapping = new HashMap();
- }
- mapping.put(id, o);
- }
- return o;
- }
-
public Object getRowData() {
if (mapping != null && mapping.containsKey(rowKey)) {
@@ -164,17 +159,50 @@
}
+ /**
+ * Row indexes navigation is no longer supported
+ */
public int getRowIndex() {
throw new UnsupportedOperationException("getRowIndex");
}
-
+
+ /**
+ * Quite simple implementation - data will be cached, so the call will be cheap
+ */
public boolean isRowAvailable() {
return getRowData() != null;
}
+ /**
+ * Row indexes navigation is no longer supported
+ */
public void setRowIndex(int arg0) {
throw new UnsupportedOperationException("setRowIndex");
}
+ public Object getRowKey() {
+ return rowKey;
+ }
+ public void setRowKey(Object key) {
+ rowKey = key;
+ }
+
+ private Object loadAndMap(Object id) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("loadAndMap " + id);
+ }
+
+ Object o = getObjectById(id);
+ if (o != null) {
+ if (mapping == null) {
+ mapping = new HashMap();
+ }
+ mapping.put(id, o);
+ }
+ return o;
+ }
+
+
}
Deleted: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridDataModelFeatures.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridDataModelFeatures.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridDataModelFeatures.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -1,17 +0,0 @@
-package org.richfaces.model;
-
-import org.richfaces.model.snapshot.ObjectLocator;
-
-
-
-public interface GridDataModelFeatures {
- public ObjectLocator getObjectLocator();
- public void setObjectLocator(ObjectLocator locator);
- public void reset();
-// public Collection getSelectedObjects();
-
-// public void setSelection(Selection selection);
-//
-// public Selection getSelection();
-
-}
Deleted: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridRange.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridRange.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridRange.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -1,26 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import org.ajax4jsf.ajax.repeat.Range;
-
-/**
- * @author maksim
- * @modidied by Anton Belevich
- *
- */
-public abstract class GridRange implements Range {
-
- private SortOrder sortOrder;
-
- public abstract IterationBounds getIterationBounds();
-
- public SortOrder getSortOrder() {
- return sortOrder;
- }
-
- public void setSortOrder(SortOrder sortOrder) {
- this.sortOrder = sortOrder;
- }
-}
Deleted: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IterationBounds.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IterationBounds.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/IterationBounds.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -1,62 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/IterationBounds.java,v $
- * $Revision: 1.3 $
- */
-
-package org.richfaces.model;
-
-import java.io.Serializable;
-
-public class IterationBounds implements Serializable {
-
- public interface RowVisitor {
- public void visit(int rowIndex);
- }
-
- private static final long serialVersionUID = 1L;
-
- private int startRow;
- private int endRow;
-
- public IterationBounds() {
- }
- public IterationBounds(int startRow, int endRow) {
- super();
- this.startRow = startRow;
- this.endRow = endRow;
- }
-
- public boolean within(int i) {
- return i >= startRow && i < endRow;
- }
-
- public void iterate(RowVisitor rowVisitor) {
- for (int i = startRow; i < endRow; i++) {
- rowVisitor.visit(i);
- }
- }
-
- public int size() {
- return endRow - startRow;
- }
-
- public int getEndRow() {
- return endRow;
- }
-
- public int getStartRow() {
- return startRow;
- }
- /**
- * @see java.lang.Object#toString()
- */
-
- public String toString() {
- return "[" + startRow + "," + endRow + "]";
- }
-}
\ No newline at end of file
Deleted: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridDataModel.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridDataModel.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridDataModel.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -1,196 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/GridDataModel.java,v $
- * $Revision: 1.14 $
- */
-
-package org.richfaces.model;
-
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.ajax.repeat.DataVisitor;
-import org.ajax4jsf.ajax.repeat.ExtendedDataModel;
-import org.ajax4jsf.ajax.repeat.Range;
-import org.ajax4jsf.ajax.repeat.SerializableDataModel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.richfaces.component.UIDataGrid;
-import org.richfaces.model.snapshot.DataModelSnapshot;
-import org.richfaces.model.snapshot.ObjectLocator;
-
-
-
-/**
- * To effectively use {@link UIDataGrid} component, a data model is to be
- * defined.
- *
- * Data model to deal with underlying data source. Support for partial load of
- * data window and sorting. Subclasses must implement
- * {@link #createDataRange(int, int, SortOrder)} method. This class is mostly
- * targetted to database fetches, where
- * {@link #createDataRange(int, int, SortOrder)} method accesses underlying data
- * source and wraps select result into DataRange object.
- *
- * <p>
- * State saving/restore works as follows:
- * </p>
- * <ul>
- * <li> If {@link #getObjectLocator()} call returns {@link ObjectLocator}
- * instance, it is used to create a snapshot of model data with object
- * identifiers instead of full-blown objects. Then the snapshot is saved within
- * state, and on restore state ObjectLocator is employed to load objects by
- * their ids. </li>
- * <li> If there's no {@link ObjectLocator} instance, snapshot is not
- * serialized. </li>
- * </ul>
- *
- * @author Maksim Kaszynski
- */
-public abstract class ScrollableGridDataModel extends ExtendedDataModel implements
- GridDataModelFeatures {
-
- private static final Log log = LogFactory.getLog(ScrollableGridDataModel.class);
-
- private final class BearerSettings {
- SortOrder sortOrder;
- int startRow = -1;
- int endRow = -1;
- public BearerSettings(int startRow, int endRow, SortOrder sortOrder) {
- super();
- this.sortOrder = sortOrder;
- this.startRow = startRow;
- this.endRow = endRow;
- }
-
-
- }
-
- private ObjectLocator objectLocator;
-
- private SortOrder sortOrder;
-
-// private Selection selection;
-
- private DataRange bearer;
-
- private BearerSettings bearerSettings = null;
-
- /**
- * Create new {@link DataRange} - i.e. load a new data window from data
- * base. Subclasses need to define this method - for example to get
- * {ResultSet} from database, or ScrollableResult from hibernate.
- *
- * @param startRow
- * @param endRow
- * @param sortOrder
- * @return
- */
- protected abstract DataRange createDataRange(int startRow, int endRow,
- SortOrder sortOrder);
-
- /**
- * reset data range - we need to load a new one
- *
- */
- public void reset() {
- bearer = null;
- sortOrder = null;
-// selection = null;
- bearerSettings = null;
- }
-
- public void setObjectLocator(ObjectLocator objectLocator) {
- this.objectLocator = objectLocator;
- }
-
- public ObjectLocator getObjectLocator() {
- return objectLocator;
- }
-
- public Object getRowData() {
- int index = getRowIndex();
- log.debug("GridDataModel.getRowData() " + index );
- if (index == -1) {
- return null;
- }
-
- if (bearer == null && bearerSettings != null) {
- bearer = createDataRange(bearerSettings.startRow,
- bearerSettings.endRow, bearerSettings.sortOrder);
- bearerSettings = null;
- }
-
- if (bearer == null || !bearer.hit(index)) {
- bearer = createDataRange(index, index + 1, sortOrder);
- }
-
- return bearer.getRowData(index);
- }
-
- public void walk(final FacesContext context, final DataVisitor visitor,
- final Range range, final Object argument) throws IOException {
-
- int rowCount = getRowCount();
-
- if (rowCount == 0) {
- return;
- }
-
- GridRange sequenceRange = (GridRange) range;
-
- sortOrder = sequenceRange.getSortOrder();
-
- IterationBounds bounds = sequenceRange.getIterationBounds();
-
- bearer = null;
- bearerSettings = new BearerSettings(bounds.getStartRow(), bounds.getEndRow(), sortOrder);
-
- try {
- bounds.iterate(new IterationBounds.RowVisitor() {
- public void visit(int rowIndex) {
- Integer rowKey = new Integer(rowIndex);
- try {
- visitor.process(context, rowKey, argument);
- } catch (IOException e) {
- throw new IOExceptionWrapper(e);
- }
- }
- });
-
- } catch (IOExceptionWrapper e) {
- throw e.getWrappedException();
- }
- }
-
- public Object getRowKey() {
- int rowIndex = getRowIndex();
- if (rowIndex == -1) {
- return null;
- }
- return new Integer(rowIndex);
- }
-
- public void setRowKey(Object key) {
- if (key == null) {
- setRowIndex(-1);
- } else {
- setRowIndex(((Integer) key).intValue());
- }
- }
-
- public SerializableDataModel getSerializableModel(Range range) {
- BufferedSequenceRange sequenceRange = (BufferedSequenceRange) range;
- ObjectLocator locator = getObjectLocator();
- if (locator != null) {
- return new DataModelSnapshot(this, sequenceRange);
- }
- return super.getSerializableModel(range);
- }
-
-}
\ No newline at end of file
Copied: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridRange.java (from rev 1186, trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/GridRange.java)
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridRange.java (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/ScrollableGridRange.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -0,0 +1,66 @@
+/*
+ * Copyright
+ * Copyright (c) Exadel,Inc. 2006
+ * All rights reserved.
+ *
+ * History
+ * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/ScrollableGridRange.java,v $
+ * $Revision: 1.7 $
+ */
+
+package org.richfaces.model;
+
+import org.ajax4jsf.ajax.repeat.Range;
+
+
+
+/**
+ * @author Maksim Kaszynski
+ * @modified by Anton Belevich
+ */
+public class ScrollableGridRange implements Range{
+
+ private int first = 0;
+ private int last = 0;
+ private SortOrder sortOrder;
+
+ public ScrollableGridRange(int first, int last, SortOrder sortOrder) {
+ super();
+ this.first = first;
+ this.last = last;
+ this.sortOrder = sortOrder;
+ }
+
+ /**
+ * @return the bufferSize
+ */
+ public int getLast() {
+ return last;
+ }
+ /**
+ * @param bufferSize the bufferSize to set
+ */
+ public void setLast(int lastRow) {
+ this.last = lastRow;
+ }
+ /**
+ * @return the first
+ */
+ public int getFirst() {
+ return first;
+ }
+ /**
+ * @param first the first to set
+ */
+ public void setFirst(int first) {
+ this.first = first;
+ }
+
+ public SortOrder getSortOrder() {
+ return sortOrder;
+ }
+
+ public void setSortOrder(SortOrder sortOrder) {
+ this.sortOrder = sortOrder;
+ }
+}
Deleted: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SequenceRange.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SequenceRange.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/SequenceRange.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -1,65 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-/**
- * @author maksim
- *
- */
-public class SequenceRange extends GridRange {
-
- private int start;
- private int end;
-
- public SequenceRange(int start, int end) {
- super();
- this.start = start;
- this.end = end;
- }
-
- public int getStart() {
- return start;
- }
-
- public void setStart(int start) {
- this.start = start;
- }
-
- public int getEnd() {
- return end;
- }
-
- public void setEnd(int end) {
- this.end = end;
- }
-
- /* (non-Javadoc)
- * @see com.exadel.jsf.model.GridRange#getIterationBounds(int)
- */
- public IterationBounds getIterationBounds() {
-// int a = start, b = end;
-//
-// if (start > rowCount) {
-// a = rowCount;
-// }
-//
-// if (end > rowCount) {
-// b = rowCount;
-// }
-// if (b < 0) {
-// b = rowCount;
-// }
-//
-// if (a > b) {
-// int c = a;
-//
-// a = b;
-// b = c;
-// }
-//
-//
- return new IterationBounds(0,0);
- }
-
-}
Deleted: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ArrayDataModelExt.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ArrayDataModelExt.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ArrayDataModelExt.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -1,82 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/impl/ArrayDataModelExt.java,v $
- * $Revision: 1.2 $
- */
-
-package org.richfaces.model.impl;
-
-import java.util.Arrays;
-
-import org.richfaces.model.DataRange;
-import org.richfaces.model.SortOrder;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class ArrayDataModelExt extends SequenceDataModelExt {
-
- private Object [] wrappedData;
- private int rowIndex;
- public ArrayDataModelExt(Object [] array) {
- wrappedData = array;
- }
-
- protected DataRange createDataRange(int startRow, int endRow,
- SortOrder sortOrder) {
-
- if (sortOrder != null && sortOrder.getSortColumn() != -1) {
- Arrays.sort(wrappedData, getComparator(sortOrder)) ;
- }
-
- return new ArrayDataRange(0, getRowCount(), sortOrder, wrappedData);
- }
-
- /**
- * @see javax.faces.model.DataModel#getRowCount()
- */
- public int getRowCount() {
- return wrappedData.length;
- }
-
- /**
- * @see javax.faces.model.DataModel#getRowIndex()
- */
- public int getRowIndex() {
- return rowIndex;
- }
-
- /**
- * @see javax.faces.model.DataModel#getWrappedData()
- */
- public Object getWrappedData() {
- return wrappedData;
- }
-
- /**
- * @see javax.faces.model.DataModel#isRowAvailable()
- */
- public boolean isRowAvailable() {
- return rowIndex < wrappedData.length;
- }
-
- /**
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- public void setRowIndex(int rowIndex) {
- this.rowIndex = rowIndex;
- }
-
- /**
- * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
- */
- public void setWrappedData(Object data) {
- wrappedData = (Object[]) data;
- }
-
-}
Deleted: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ArrayDataRange.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ArrayDataRange.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ArrayDataRange.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -1,45 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/impl/ArrayDataRange.java,v $
- * $Revision: 1.2 $
- */
-
-package org.richfaces.model.impl;
-
-import org.richfaces.model.DataRange;
-import org.richfaces.model.SortOrder;
-
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class ArrayDataRange extends DataRange {
-
- private Object [] wrapped;
-
- /**
- * @param startRow
- * @param endRow
- * @param sortOrder
- * @param wrappedData
- */
- public ArrayDataRange(int startRow, int endRow, SortOrder sortOrder,
- Object [] wrappedData) {
- super(startRow, endRow, sortOrder);
- wrapped = wrappedData;
- }
-
- /**
- * @see com.exadel.jsf.model.DataRange#getRowData(int)
- */
- public Object getRowData(int index) {
- // TODO Auto-generated method stub
- return ((Object[]) wrapped)[index];
- }
-
-}
Deleted: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ListDataModelExt.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ListDataModelExt.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ListDataModelExt.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -1,69 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/impl/ListDataModelExt.java,v $
- * $Revision: 1.5 $
- */
-
-package org.richfaces.model.impl;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import org.richfaces.model.DataRange;
-import org.richfaces.model.SortOrder;
-
-
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class ListDataModelExt extends SequenceDataModelExt {
- private List wrappedData;
- private int rowIndex;
-
- public ListDataModelExt(List wrappedData) {
- this.wrappedData = wrappedData;
- }
-
- protected DataRange createDataRange(int startRow, int endRow, SortOrder sortOrder) {
- List wrapped = (List) getWrappedData();
- boolean shouldSort = sortOrder != null && sortOrder.getSortColumn() != -1;
- if (shouldSort) {
- Comparator comparator = getComparator(sortOrder);
- if (comparator != null) {
- Collections.sort(wrapped, comparator);
- }
- }
- return new ListDataRange(0, getRowCount(), sortOrder, wrapped);
- }
-
- public int getRowCount() {
- return wrappedData.size();
- }
-
- public int getRowIndex() {
- return rowIndex;
- }
-
- public Object getWrappedData() {
- return wrappedData;
- }
-
- public boolean isRowAvailable() {
- return rowIndex < wrappedData.size();
- }
-
- public void setRowIndex(int rowIndex) {
- this.rowIndex = rowIndex;
- }
-
- public void setWrappedData(Object data) {
- wrappedData = (List) data;
- }
-}
Deleted: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ListDataRange.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ListDataRange.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/ListDataRange.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -1,56 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/impl/ListDataRange.java,v $
- * $Revision: 1.2 $
- */
-
-package org.richfaces.model.impl;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.richfaces.model.DataRange;
-import org.richfaces.model.SortOrder;
-
-
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class ListDataRange extends DataRange {
-
- private int lastIndex = -1;;
- private transient Iterator wrappedIterator;
- private List list;
- /**
- * @param startRow
- * @param endRow
- * @param sortOrder
- * @param wrappedData
- */
- public ListDataRange(int startRow, int endRow, SortOrder sortOrder, List wrappedData) {
- super(startRow, endRow, sortOrder);
- list = wrappedData;
- }
-
- /**
- * @see com.exadel.jsf.model.DataRange#getRowData(int)
- */
- public Object getRowData(int index) {
-
- if (index >= 0 && index - lastIndex == 1 && wrappedIterator != null) {
-
- } else {
- wrappedIterator = list.listIterator(index);
- }
-
- lastIndex = index;
- return wrappedIterator.next();
- }
-
-}
Deleted: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/SequenceDataModelExt.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/SequenceDataModelExt.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/model/impl/SequenceDataModelExt.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -1,64 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/impl/SequenceDataModelExt.java,v $
- * $Revision: 1.4 $
- */
-
-package org.richfaces.model.impl;
-
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.richfaces.model.ScrollableGridDataModel;
-import org.richfaces.model.SortOrder;
-
-
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public abstract class SequenceDataModelExt extends ScrollableGridDataModel {
-
- private transient Map comparators;
-
-
- /**
- *
- */
- public SequenceDataModelExt() {
- super();
- }
-
- protected Comparator getComparator(SortOrder sortOrder) {
- Comparator comp = (Comparator) getComparators().get(sortOrder);
- if (comp == null) {
- comp = createComparator(sortOrder);
- }
-
- if (comp != null) {
- getComparators().put(sortOrder, comp);
- }
-
- return comp;
- }
-
- protected Comparator createComparator(SortOrder sortOrder) {
- return new PropertyResolverComparator(sortOrder);
- }
-
- protected Map getComparators() {
- if (comparators == null) {
- comparators = new HashMap();
-
- }
- return comparators;
- }
-
-
-}
\ No newline at end of file
Deleted: trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/ChannelDataModel.java
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/ChannelDataModel.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/ChannelDataModel.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -1,171 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source: /cvs-master/intralinks-jsf-comps/web-projects/data-view-grid-demo/src/com/exadel/jsf/demo/datagrid/bean/ChannelDataModel.java,v $
- * $Revision: 1.4 $
- */
-
-package org.richfaces.demo.datagrid.bean;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.richfaces.demo.datagrid.model.Channel;
-import org.richfaces.demo.datagrid.model.Issue;
-import org.richfaces.model.DataRange;
-import org.richfaces.model.ScrollableGridDataModel;
-import org.richfaces.model.SortOrder;
-import org.richfaces.model.snapshot.ObjectLocator;
-
-/**
- * Example data model. Uses {@link Channel} instance as data storage
- *
- * @author Maksim Kaszynski
- *
- */
-public class ChannelDataModel extends ScrollableGridDataModel {
-
- /**
- * Data range implementation. Wraps query result
- * @author Maksim Kaszynski
- *
- */
- public static class ChannelDataRange extends DataRange {
-
- private List <Issue> window;
-
- public ChannelDataRange(int startRow, int endRow, SortOrder sortOrder, List <Issue> window) {
- super(startRow, endRow, sortOrder);
- this.window = window;
- }
-
- /**
- * get loaded object
- * @see com.exadel.jsf.model.DataRange#getRowData(int)
- */
- @Override
- public Object getRowData(int index) {
- return window.get(index - getStartRow());
- }
- }
-
- /**
- * Minimize LIST queries. Locate objects by their IDs
- * @author Maksim Kaszynski
- *
- */
- public class IssueLocator implements ObjectLocator {
-
- public Collection findObjects(Collection ids) {
- System.out.println("IssueLocator.findObjects()" + ids);
-
- //sort of find by ids
- List <Issue> issues = new ArrayList<Issue>(ids.size());
- for (Object key : ids) {
- Integer id = (Integer) key;
- Issue issue = getChannel().findById(id);
- issues.add(issue);
- }
-
- return issues;
- }
-
- public Serializable getObjectId(Object object) {
- Issue issue = (Issue) object;
- Integer id = issue.getIndex();
- return id;
- }
-
- }
-
- private ObjectLocator objectLocator = new IssueLocator();
- private Channel channel;
- private int rowIndex;
-
- /**
- * Load part of channel.
- */
- @Override
- protected DataRange createDataRange(int startRow, int endRow,
- SortOrder sortOrder) {
- //access storage to get data
- List <Issue> window = getChannel().executeQuery(startRow, endRow, sortOrder);
- System.out.println("ChannelDataModel.createDataRange()");
- return new ChannelDataRange(startRow, endRow, sortOrder, window);
- }
-
- /**
- * @see javax.faces.model.DataModel#getRowCount()
- */
- @Override
- public int getRowCount() {
- return getChannel().size();
- }
-
-
- @Override
- public Object getWrappedData() {
- return getChannel();
- }
-
- /**
- * @see javax.faces.model.DataModel#isRowAvailable()
- */
- @Override
- public boolean isRowAvailable() {
- return rowIndex < getRowCount();
- }
-
- @Override
- public void setWrappedData(Object data) {
- setChannel((Channel) data);
- }
-
- /**
- * @return the channel
- */
- public Channel getChannel() {
- return channel;
- }
-
- /**
- * @param channel the channel to set
- */
- public void setChannel(Channel channel) {
- this.channel = channel;
- }
-
- /**
- * @return the rowIndex
- */
- public int getRowIndex() {
- return rowIndex;
- }
-
- /**
- * @param rowIndex the rowIndex to set
- */
- public void setRowIndex(int rowIndex) {
- this.rowIndex = rowIndex;
- }
-
- /**
- * @return the objectLocator
- */
- public ObjectLocator getObjectLocator() {
- return objectLocator;
- }
-
- /**
- * @param objectLocator the objectLocator to set
- */
- public void setObjectLocator(ObjectLocator objectLocator) {
- this.objectLocator = objectLocator;
- }
-
-}
Modified: trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/ChannelDataModel2.java
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/ChannelDataModel2.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/ChannelDataModel2.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -21,9 +21,9 @@
private final Log log = LogFactory.getLog(ChannelDataModel2.class);
- public static final int BIG_QUERY_DELAY = 1000;
+ public static final int BIG_QUERY_DELAY = 0*1000;
- public static final int SMALL_QUERY_DELAY = 500;
+ public static final int SMALL_QUERY_DELAY = 0*500;
private Channel channel;
@@ -37,16 +37,19 @@
log.trace(id);
}
- log.info("sleeping " + SMALL_QUERY_DELAY + "ms");
-
- try {
- Thread.sleep(SMALL_QUERY_DELAY);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ if (SMALL_QUERY_DELAY > 0) {
+ log.info("sleeping " + SMALL_QUERY_DELAY + "ms");
+
+ try {
+ Thread.sleep(SMALL_QUERY_DELAY);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ log.info("Awoke from slumber");
}
- log.info("Awoke from slumber");
return channel.findIssueByKey((Key) id);
}
@@ -61,15 +64,18 @@
log.trace("startRow=" + startRow + ", endRow=" + endRow + ",sortOrder=" + sortOrder);
}
- log.info("sleeping " + BIG_QUERY_DELAY);
-
- try {
- Thread.sleep(BIG_QUERY_DELAY);
- } catch (InterruptedException e) {
- e.printStackTrace();
+ if (BIG_QUERY_DELAY > 0) {
+ log.info("sleeping " + BIG_QUERY_DELAY);
+
+ try {
+ Thread.sleep(BIG_QUERY_DELAY);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ log.info("Awoke from slumber");
}
- log.info("Awoke from slumber");
return channel.executeQuery(startRow, endRow, sortOrder);
}
Deleted: trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/SelectionBean.java
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/SelectionBean.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/bean/SelectionBean.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -1,85 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source: /cvs-master/intralinks-jsf-comps/web-projects/data-view-grid-demo/src/com/exadel/jsf/demo/datagrid/bean/SelectionBean.java,v $
- * $Revision: 1.19 $
- */
-
-package org.richfaces.demo.datagrid.bean;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.faces.event.ActionEvent;
-import javax.faces.model.SelectItem;
-
-import org.richfaces.demo.datagrid.model.Channel;
-import org.richfaces.demo.datagrid.model.Issue;
-import org.richfaces.model.ScrollableGridDataModel;
-
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class SelectionBean {
-
- private ScrollableGridDataModel dataModel;
-
- private Channel channel;
-
- private String key;
-
- private int id;
-
-
- public ScrollableGridDataModel getDataModel() {
- return dataModel;
- }
-
- public void setDataModel(ScrollableGridDataModel dataModel) {
- this.dataModel = dataModel;
- }
-
- public SelectionBean() {
-
- }
-
- public void setKeyz(ActionEvent e) {
- System.out.println("SelectionBean.setKeyz() " + key + "id " + id);
- Channel channel = (Channel) getDataModel().getWrappedData ();
- Issue issue = channel.getIndex().get(id);
- if (issue != null) {
- channel.getIndex().remove(issue.getIndex());
- channel.getIssues().remove(issue);
- }
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getKey() {
- return key;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- public Channel getChannel() {
- return channel;
- }
-
- public void setChannel(Channel channel) {
- this.channel = channel;
- }
-}
-
Modified: trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Channel.java
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Channel.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Channel.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -234,6 +234,9 @@
}
public void addIssue(Issue issue) {
+ /*if (issues.size() > 5) {
+ return;
+ }*/
issues.add(issue);
index.put(issue.getIndex(), issue);
}
Modified: trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Issue.java
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Issue.java 2007-06-14 17:08:16 UTC (rev 1189)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/datagrid/model/Issue.java 2007-06-14 17:20:40 UTC (rev 1190)
@@ -12,13 +12,11 @@
import java.io.Serializable;
-import org.richfaces.model.Entity;
-
/**
* @author Maksim Kaszynski
*
*/
-public class Issue implements Serializable{
+public class Issue {
private static int issueIndex = 0;
private int index = ++issueIndex;
17 years, 7 months
JBoss Rich Faces SVN: r1189 - trunk/sandbox/scrollable-grid/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-06-14 13:08:16 -0400 (Thu, 14 Jun 2007)
New Revision: 1189
Modified:
trunk/sandbox/scrollable-grid/src/main/config/component/scrollable-grid.xml
Log:
add rows default value
Modified: trunk/sandbox/scrollable-grid/src/main/config/component/scrollable-grid.xml
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/config/component/scrollable-grid.xml 2007-06-14 17:04:49 UTC (rev 1188)
+++ trunk/sandbox/scrollable-grid/src/main/config/component/scrollable-grid.xml 2007-06-14 17:08:16 UTC (rev 1189)
@@ -43,7 +43,13 @@
<description>grid width</description>
<defaultvalue>"700px"</defaultvalue>
</property>
+ <property>
+ <name>rows</name>
+ <classname>int</classname>
+ <defaultvalue>40</defaultvalue>
+ </property>
+
<property attachedstate="true" hidden="true">
<name>sortOrder</name>
<classname>org.richfaces.model.SortOrder</classname>
17 years, 7 months