JBoss Rich Faces SVN: r19871 - in branches/RF-7817/examples: push-demo and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-01 19:49:06 -0400 (Mon, 01 Nov 2010)
New Revision: 19871
Added:
branches/RF-7817/examples/push-demo/
branches/RF-7817/examples/push-demo/pom.xml
branches/RF-7817/examples/push-demo/src/
Modified:
branches/RF-7817/examples/pom.xml
branches/RF-7817/examples/push-demo/src/main/java/demo/TopicsInitializer.java
branches/RF-7817/examples/push-demo/src/main/webapp/chat.xhtml
Log:
https://jira.jboss.org/browse/RF-9158
Modified: branches/RF-7817/examples/pom.xml
===================================================================
--- branches/RF-7817/examples/pom.xml 2010-11-01 23:47:24 UTC (rev 19870)
+++ branches/RF-7817/examples/pom.xml 2010-11-01 23:49:06 UTC (rev 19871)
@@ -46,6 +46,7 @@
<module>input-demo</module>
<module>repeater-demo</module>
<module>iteration-demo</module>
+ <module>push-demo</module>
<module>richfaces-showcase</module>
<!--<module>dist</module>-->
</modules>
Added: branches/RF-7817/examples/push-demo/pom.xml
===================================================================
--- branches/RF-7817/examples/push-demo/pom.xml (rev 0)
+++ branches/RF-7817/examples/push-demo/pom.xml 2010-11-01 23:49:06 UTC (rev 19871)
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ JBoss, Home of Professional Open Source Copyright 2010, Red Hat,
+ Inc. and individual contributors by the @authors tag. See the
+ copyright.txt in the distribution for a full listing of
+ individual contributors. This is free software; you can
+ redistribute it and/or modify it under the terms of the GNU
+ Lesser General Public License as published by the Free Software
+ Foundation; either version 2.1 of the License, or (at your
+ option) any later version. This software 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 software; if not,
+ write to the Free Software Foundation, Inc., 51 Franklin St,
+ Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site:
+ http://www.fsf.org.
+ -->
+<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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.richfaces.examples</groupId>
+ <artifactId>richfaces-example-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.richfaces.examples</groupId>
+ <artifactId>push-demo</artifactId>
+ <packaging>war</packaging>
+ <version>4.0.0-SNAPSHOT</version>
+ <name>RichFaces Examples: Push</name>
+
+ <properties>
+ <hornetq.version>2.1.2.Final</hornetq.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.hornetq</groupId>
+ <artifactId>hornetq-core</artifactId>
+ <version>${hornetq.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hornetq</groupId>
+ <artifactId>hornetq-jms</artifactId>
+ <version>${hornetq.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hornetq</groupId>
+ <artifactId>hornetq-logging</artifactId>
+ <version>${hornetq.version}</version>
+ </dependency>
+ <!-- dependency>
+ <groupId>org.hornetq</groupId>
+ <artifactId>hornetq-transports</artifactId>
+ <version>2.1.0.r9031</version>
+ </dependency -->
+ <dependency>
+ <groupId>org.jboss.netty</groupId>
+ <artifactId>netty</artifactId>
+ <version>3.2.2.Final</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.jms</groupId>
+ <artifactId>jms</artifactId>
+ <version>1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.7</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.atmosphere</groupId>
+ <artifactId>atmosphere-runtime</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-impl</artifactId>
+ </dependency>
+
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui.core</groupId>
+ <artifactId>richfaces-ui-core-ui</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sf.ehcache</groupId>
+ <artifactId>ehcache</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>jee6</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <webappDirectory>${project.build.directory}/${project.build.finalName}-jee6</webappDirectory>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <!-- TODO these should be switchable in example specific parent -->
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>jetty</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-websocket</artifactId>
+ <version>8.0.0.M1</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <version>8.0.0.M1</version>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/examples/push-demo</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/examples/push-demo</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces</url>
+ </scm>
+</project>
Copied: branches/RF-7817/examples/push-demo/src (from rev 19862, branches/RF-7817/push-redesign-app/src)
Modified: branches/RF-7817/examples/push-demo/src/main/java/demo/TopicsInitializer.java
===================================================================
--- branches/RF-7817/push-redesign-app/src/main/java/demo/TopicsInitializer.java 2010-11-01 19:50:05 UTC (rev 19862)
+++ branches/RF-7817/examples/push-demo/src/main/java/demo/TopicsInitializer.java 2010-11-01 23:49:06 UTC (rev 19871)
@@ -83,7 +83,7 @@
if (chatBean == null || "badname".equals(chatBean.getUserName())) {
throw new EventAbortedException("User name has not passed validation");
}
- }
+ }
});
}
Modified: branches/RF-7817/examples/push-demo/src/main/webapp/chat.xhtml
===================================================================
--- branches/RF-7817/push-redesign-app/src/main/webapp/chat.xhtml 2010-11-01 19:50:05 UTC (rev 19862)
+++ branches/RF-7817/examples/push-demo/src/main/webapp/chat.xhtml 2010-11-01 23:49:06 UTC (rev 19871)
@@ -6,7 +6,7 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
- xmlns:p="http://richfaces.org/push-redesign">
+ xmlns:a4j="http://richfaces.org/a4j">
<f:view>
<f:metadata>
@@ -53,7 +53,7 @@
</h:selectBooleanCheckbox>
<h:panelGroup layout="block" rendered="#{channel.rendered}">
- <p:push address="#{channelName}@chat" onerror="alert(event.rf.data)" ondataavailable="jQuery('<div />').prependTo('.#{channelName}Output').text(event.rf.data)" />
+ <a4j:push address="#{channelName}@chat" onerror="alert(event.rf.data)" ondataavailable="jQuery('<div />').prependTo('.#{channelName}Output').text(event.rf.data)" />
<h:inputText styleClass="messageInput" value="#{chatBean.message}" size="40" />
15 years
JBoss Rich Faces SVN: r19870 - in branches/RF-7817/ui/core/ui/src/main: java/org/richfaces/renderkit and 7 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-01 19:47:24 -0400 (Mon, 01 Nov 2010)
New Revision: 19870
Added:
branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/AbstractPush.java
branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/renderkit/PushRendererBase.java
branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/resource/PushResource.java
branches/RF-7817/ui/core/ui/src/main/resources/META-INF/resources/net.java.dev.atmosphere/
branches/RF-7817/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/push.js
branches/RF-7817/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/push.template.xml
Removed:
branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/AbstractPush.java
branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/PushEventTracker.java
branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/PushListenersManager.java
branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/resource/PushResource.java
branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/AjaxPushHandler.java
branches/RF-7817/ui/core/ui/src/main/resources/META-INF/push-managed-beans.faces-config.xml
Log:
https://jira.jboss.org/browse/RF-9158
Deleted: branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/AbstractPush.java
===================================================================
--- branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/AbstractPush.java 2010-11-01 23:43:58 UTC (rev 19869)
+++ branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/AbstractPush.java 2010-11-01 23:47:24 UTC (rev 19870)
@@ -1,123 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.richfaces.component;
-
-import java.io.IOException;
-import java.util.EventListener;
-
-import javax.el.MethodExpression;
-import javax.faces.component.NamingContainer;
-import javax.faces.context.FacesContext;
-import javax.servlet.http.HttpSession;
-
-import org.richfaces.cdk.annotations.Attribute;
-import org.richfaces.cdk.annotations.EventName;
-import org.richfaces.cdk.annotations.JsfComponent;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.annotations.Signature;
-import org.richfaces.cdk.annotations.Tag;
-import org.richfaces.cdk.annotations.TagType;
-
-/**
- * Component for periodically call AJAX events on server ( poll actions )
- * @author shura
- *
- */
-@JsfComponent(
- tag = @Tag(generate = false, handler = "org.richfaces.view.facelets.html.AjaxPushHandler", type = TagType.Facelets),
- renderer = @JsfRenderer(type = "org.richfaces.PushRenderer")
-)
-public abstract class AbstractPush extends AbstractActionComponent {
-
- public static final String COMPONENT_TYPE = "org.richfaces.Push";
-
- public static final String COMPONENT_FAMILY = "org.richfaces.Push";
-
- public static final String DATA_AVAILABLE = "dataAvailable";
-
- public static final String ON_DATA_AVAILABLE = "ondataavailable";
-
- @Override
- public void encodeBegin(FacesContext context) throws IOException {
- MethodExpression producer = getEventProducer();
-
- // Subscribe events producer to push status listener.
- if (null != producer) {
- producer.invoke(context.getELContext(), new Object[] {getListener(context)});
- }
-
- super.encodeBegin(context);
- }
-
- private PushEventTracker getListener(FacesContext context) {
- PushListenersManager pushListenersManager = PushListenersManager.getInstance(context);
-
- return pushListenersManager.getListener(getListenerId(context));
- }
-
- public String getListenerId(FacesContext context) {
- Object session = context.getExternalContext().getSession(false);
- StringBuffer id = new StringBuffer();
-
- if (null != session && session instanceof HttpSession) {
- HttpSession httpSession = (HttpSession) session;
-
- id.append(httpSession.getId());
- }
-
- id.append(context.getViewRoot().getViewId());
- id.append(NamingContainer.SEPARATOR_CHAR);
- id.append(getClientId(context));
-
- return id.toString();
- }
-
- // ---------------------------------------
- @Attribute(signature = @Signature(parameters = EventListener.class))
- public abstract MethodExpression getEventProducer();
-
- public abstract void setEventProducer(MethodExpression producer);
-
- /**
- * @return time in mc for polling interval.
- */
- @Attribute(defaultValue = "1000")
- public abstract int getInterval();
-
- @Attribute(defaultValue = "true")
- public abstract boolean isEnabled();
-
- // TODO what wrong with that name?
- @Attribute(events = @EventName(value = DATA_AVAILABLE, defaultEvent = true))
- public abstract String getOndataavailable();
-
- @Attribute(events = @EventName("begin"))
- public abstract String getOnbegin();
-
- @Attribute(events = @EventName("beforedomupdate"))
- public abstract String getOnbeforedomupdate();
-
- @Attribute(events = @EventName("complete"))
- public abstract String getOncomplete();
-}
Copied: branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/AbstractPush.java (from rev 19862, branches/RF-7817/push-redesign/src/main/java/org/richfaces/component/AbstractPush.java)
===================================================================
--- branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/AbstractPush.java (rev 0)
+++ branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/AbstractPush.java 2010-11-01 23:47:24 UTC (rev 19870)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.component;
+
+import javax.faces.component.UIComponentBase;
+
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.TagType;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@JsfComponent(type = AbstractPush.COMPONENT_TYPE, family = AbstractPush.COMPONENT_FAMILY, tag = @Tag(name = "push", type = TagType.Facelets),
+ renderer = @JsfRenderer(type = "org.richfaces.PushRenderer"))
+public abstract class AbstractPush extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.Push";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.Push";
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ @Attribute(required = true)
+ public abstract String getAddress();
+
+ @Attribute(events = {@EventName("dataavailable")})
+ public abstract String getOndataavailable();
+
+ @Attribute(events = {@EventName("error")})
+ public abstract String getOnerror();
+}
Deleted: branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/PushEventTracker.java
===================================================================
--- branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/PushEventTracker.java 2010-11-01 23:43:58 UTC (rev 19869)
+++ branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/PushEventTracker.java 2010-11-01 23:47:24 UTC (rev 19870)
@@ -1,52 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.richfaces.component;
-
-import java.io.Serializable;
-
-import java.util.EventObject;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.ajax4jsf.event.PushEventListener;
-
-/**
- * @author Nick Belaevski
- * @since 4.0
- */
-public class PushEventTracker implements PushEventListener, Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = -4362297582678089326L;
- private final AtomicBoolean eventPerformed = new AtomicBoolean(false);
-
- public void onEvent(EventObject event) {
- eventPerformed.set(true);
- }
-
- public boolean pollStatus() {
- return eventPerformed.compareAndSet(true, false);
- }
-}
Deleted: branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/PushListenersManager.java
===================================================================
--- branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/PushListenersManager.java 2010-11-01 23:43:58 UTC (rev 19869)
+++ branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/component/PushListenersManager.java 2010-11-01 23:47:24 UTC (rev 19870)
@@ -1,66 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.richfaces.component;
-
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.richfaces.util.LRUMap;
-
-/**
- * @author Nick Belaevski
- * @since 4.0
- */
-public class PushListenersManager {
-
- private static final String CONTEXT_ATTRIBUTE_NAME = "richFacesPushListenersManager";
-
- private Map<String, PushEventTracker> listeners;
-
- public PushListenersManager() {
-
- // TODO configure map size
- this.listeners = new LRUMap<String, PushEventTracker>();
- }
-
- public static PushListenersManager getInstance(FacesContext context) {
- return (PushListenersManager) context.getExternalContext().getApplicationMap().get(CONTEXT_ATTRIBUTE_NAME);
- }
-
- public PushEventTracker getListener(String name) {
- synchronized (listeners) {
-
- // LRUMap involves write for each operation, so RWLock is not acceptable here
- PushEventTracker listener = listeners.get(name);
-
- if (listener == null) {
- listener = new PushEventTracker();
- listeners.put(name, listener);
- }
-
- return listener;
- }
- }
-}
Copied: branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/renderkit/PushRendererBase.java (from rev 19862, branches/RF-7817/push-redesign/src/main/java/org/richfaces/renderkit/PushRendererBase.java)
===================================================================
--- branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/renderkit/PushRendererBase.java (rev 0)
+++ branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/renderkit/PushRendererBase.java 2010-11-01 23:47:24 UTC (rev 19870)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.render.Renderer;
+
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.richfaces.component.AbstractPush;
+import org.richfaces.resource.PushResource;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class PushRendererBase extends Renderer {
+
+ private static final String PUSH_URL_ENCODED_ATTRIBUTE = PushRendererBase.class.getName();
+
+ protected String getPushUrl(FacesContext context) {
+ ResourceHandler resourceHandler = context.getApplication().getResourceHandler();
+ Resource pushResource = resourceHandler.createResource(PushResource.class.getName());
+
+ return pushResource.getRequestPath();
+ }
+
+ protected boolean shouldEncodePushUrl(FacesContext context) {
+ Map<Object, Object> attributes = context.getAttributes();
+
+ if (attributes.get(PUSH_URL_ENCODED_ATTRIBUTE) == null) {
+ attributes.put(PUSH_URL_ENCODED_ATTRIBUTE, Boolean.TRUE);
+ return true;
+ }
+
+ return false;
+ }
+
+ protected String getOptionsString(FacesContext context, UIComponent component) {
+ AbstractPush push = (AbstractPush) component;
+
+ Map<String, Object> options = new HashMap<String, Object>(2);
+
+ options.put("address", push.getAddress());
+ options.put("dataHandler", push.getOndataavailable());
+ options.put("errorHandler", push.getOnerror());
+
+ return ScriptUtils.toScript(options);
+ }
+}
Deleted: branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
===================================================================
--- branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2010-11-01 23:43:58 UTC (rev 19869)
+++ branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2010-11-01 23:47:24 UTC (rev 19870)
@@ -1,153 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.html;
-
-import static org.richfaces.renderkit.RenderKitUtils.shouldRenderAttribute;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.application.ResourceDependency;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.event.ActionEvent;
-
-import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.javascript.JSReference;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.component.AbstractPush;
-import org.richfaces.renderkit.HtmlConstants;
-import org.richfaces.renderkit.RendererBase;
-import org.richfaces.renderkit.util.HandlersChain;
-import org.richfaces.resource.PushResource;
-
-/**
- * @author shura
- */
-@ResourceDependency(library = "org.richfaces", name = "ajax.reslib")
-@JsfRenderer
-public class AjaxPushRenderer extends RendererBase {
-
- public static final String COMPONENT_FAMILY = "org.richfaces.Push";
-
- public static final String RENDERER_TYPE = "org.richfaces.PushRenderer";
-
- public static final String PUSH_INTERVAL_PARAMETER = "A4J.AJAX.Push.INTERVAL";
-
- public static final int DEFAULT_PUSH_INTERVAL = 1000;
-
- public static final int DEFAULT_PUSH_WAIT = Integer.MIN_VALUE;
-
- @Override
- protected void queueComponentEventForBehaviorEvent(FacesContext context, UIComponent component, String eventName) {
- super.queueComponentEventForBehaviorEvent(context, component, eventName);
-
- if (AbstractPush.DATA_AVAILABLE.equals(eventName)) {
- new ActionEvent(component).queue();
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
- * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
- AbstractPush push = (AbstractPush) component;
- writer.startElement(HtmlConstants.SPAN_ELEM, component);
- writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, "display:none;", null);
- getUtils().encodeId(context, component);
-
- //TODO - ?
- getUtils().encodeBeginFormIfNessesary(context, component);
- // pushing script.
- writer.startElement(HtmlConstants.SCRIPT_ELEM, component);
- writer.writeAttribute(HtmlConstants.TYPE_ATTR, "text/javascript", null);
- StringBuffer script = new StringBuffer("\n");
- if (push.isEnabled()) {
- JSFunction function = new JSFunction("RichFaces.startPush");
- // Set dummy form id, if nessesary.
- Map<String, Object> options = new HashMap<String, Object>();
-
- int interval = push.getInterval();
- if (shouldRenderAttribute(interval)) {
- String intervalInitParameter = context.getExternalContext().getInitParameter(PUSH_INTERVAL_PARAMETER);
- if (null != intervalInitParameter) {
- interval = Integer.parseInt(intervalInitParameter);
- } else {
- interval = DEFAULT_PUSH_INTERVAL;
- }
- }
-
- options.put("interval", interval);
- options.put("pushResourceUrl", new PushResource().getRequestPath());
- options.put("pushId", push.getListenerId(context));
- options.put("clientId", component.getClientId(context));
-
- HandlersChain handlersChain = new HandlersChain(context, push);
- handlersChain.addInlineHandlerFromAttribute(AbstractPush.ON_DATA_AVAILABLE);
- handlersChain.addBehaviors(AbstractPush.DATA_AVAILABLE);
- handlersChain.addAjaxSubmitFunction();
-
- String handler = handlersChain.toScript();
-
- if (handler != null) {
- JSFunctionDefinition dataAvailableHandler = new JSFunctionDefinition(JSReference.EVENT);
- dataAvailableHandler.addToBody(handler);
- options.put(AbstractPush.ON_DATA_AVAILABLE, dataAvailableHandler);
- }
- function.addParameter(options);
- script.append(function.toScript());
- } else {
- script.append("RichFaces.stopPush('").append(push.getListenerId(context)).append("')");
- }
- script.append(";\n");
- writer.writeText(script.toString(), null);
- writer.endElement(HtmlConstants.SCRIPT_ELEM);
- getUtils().encodeEndFormIfNessesary(context, component);
- writer.endElement(HtmlConstants.SPAN_ELEM);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
- */
- protected Class<? extends UIComponent> getComponentClass() {
- // only push component is allowed.
- return AbstractPush.class;
- }
-
- @Override
- protected void doDecode(FacesContext context, UIComponent component) {
- super.doDecode(context, component);
-
- AbstractPush push = (AbstractPush) component;
- if (push.isEnabled()) {
- Map<String, String> requestParameterMap = context.getExternalContext().getRequestParameterMap();
- if (requestParameterMap.get(push.getClientId(context)) != null) {
- new ActionEvent(push).queue();
- }
- }
- }
-
-}
Deleted: branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/resource/PushResource.java
===================================================================
--- branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/resource/PushResource.java 2010-11-01 23:43:58 UTC (rev 19869)
+++ branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/resource/PushResource.java 2010-11-01 23:47:24 UTC (rev 19870)
@@ -1,97 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.application.Resource;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-
-import org.richfaces.application.ServiceTracker;
-import org.richfaces.component.PushEventTracker;
-import org.richfaces.component.PushListenersManager;
-
-/**
- * @author Nick Belaevski
- * @since 4.0
- */
-
-//TODO make this a singleton
-@DynamicResource
-public class PushResource extends Resource {
-
- public PushResource() {
- setResourceName(getClass().getName());
- }
-
- public InputStream getInputStream() throws IOException {
- return null;
- }
-
- public Map<String, String> getResponseHeaders() {
- Map<String, String> headers = new HashMap<String, String>();
- FacesContext facesContext = FacesContext.getCurrentInstance();
- ExternalContext externalContext = facesContext.getExternalContext();
- String pushId = externalContext.getRequestParameterMap().get("id");
-
- if (pushId != null && pushId.length() != 0) {
- PushListenersManager manager = PushListenersManager.getInstance(facesContext);
- PushEventTracker eventTracker = manager.getListener(pushId);
-
- if (eventTracker != null) {
- if (eventTracker.pollStatus()) {
- headers.put("Ajax-Push-Status", "READY");
- }
- }
- }
-
- return headers;
- }
-
- public String getContentType() {
- return null;
- }
-
- @Override
- public String getRequestPath() {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- ResourceCodec resourceCodec = ServiceTracker.getService(ResourceCodec.class);
-
- String requestPath = resourceCodec.encodeResourceRequestPath(facesContext, null, getResourceName(), null, null);
- return resourceCodec.encodeJSFMapping(facesContext, requestPath);
- }
-
- @Override
- public URL getURL() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean userAgentNeedsUpdate(FacesContext context) {
- return true;
- }
-}
Copied: branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/resource/PushResource.java (from rev 19862, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/PushResource.java)
===================================================================
--- branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/resource/PushResource.java (rev 0)
+++ branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/resource/PushResource.java 2010-11-01 23:47:24 UTC (rev 19870)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.resource;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.UUID;
+
+import javax.faces.FacesException;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.richfaces.application.ServiceTracker;
+import org.richfaces.application.push.PushContext;
+import org.richfaces.application.push.PushContextFactory;
+import org.richfaces.application.push.Session;
+import org.richfaces.application.push.TopicKey;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public class PushResource implements UserResource {
+
+ private static final String PUSH_TOPIC_PARAM = "pushTopic";
+
+ private static final String FORGET_PUSH_SESSION_ID_PARAM = "forgetPushSessionId";
+
+ public Map<String, String> getResponseHeaders() {
+ return null;
+ }
+
+ public Date getLastModified() {
+ return null;
+ }
+
+ private InputStream mapToScript(Map<String, Object> map) {
+ try {
+ byte[] bs = ScriptUtils.toScript(map).getBytes("UTF-8");
+ return new ByteArrayInputStream(bs);
+ } catch (UnsupportedEncodingException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+ }
+
+ private Map<String, String> getFailuresMap(Map<TopicKey, String> failedSubscriptions) {
+ Map<String,String> result = new HashMap<String, String>();
+
+ for (Entry<TopicKey, String> entry: failedSubscriptions.entrySet()) {
+ result.put(entry.getKey().getTopicAddress(), entry.getValue());
+ }
+
+ return result;
+ }
+
+ public InputStream getInputStream() throws IOException {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ExternalContext externalContext = facesContext.getExternalContext();
+
+ PushContextFactory pushContextFactory = ServiceTracker.getService(PushContextFactory.class);
+ PushContext pushContext = pushContextFactory.getPushContext();
+
+ String forgetPushSessionId = externalContext.getRequestParameterMap().get(FORGET_PUSH_SESSION_ID_PARAM);
+ if (forgetPushSessionId != null) {
+ Session oldSession = pushContext.getSessionManager().getPushSession(forgetPushSessionId);
+ if (oldSession != null) {
+ oldSession.destroy();
+ }
+ }
+
+ Session session = pushContext.getSessionFactory().createSession(UUID.randomUUID().toString());
+
+ String[] topicNames = externalContext.getRequestParameterValuesMap().get(PUSH_TOPIC_PARAM);
+
+ if (topicNames == null) {
+ throw new IllegalArgumentException();
+ }
+
+ session.subscribe(topicNames);
+
+ Map<String, Object> subscriptionData = new HashMap<String, Object>(4);
+ subscriptionData.put("sessionId", session.getId());
+
+ Map<TopicKey, String> failedSubscriptions = session.getFailedSubscriptions();
+ subscriptionData.put("failures", getFailuresMap(failedSubscriptions));
+
+ return mapToScript(subscriptionData);
+ }
+
+ public String getContentType() {
+ return "application/javascript; charset=utf-8";
+ }
+
+ public int getContentLength() {
+ return -1;
+ }
+
+}
Deleted: branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/AjaxPushHandler.java
===================================================================
--- branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/AjaxPushHandler.java 2010-11-01 23:43:58 UTC (rev 19869)
+++ branches/RF-7817/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/AjaxPushHandler.java 2010-11-01 23:47:24 UTC (rev 19870)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright , Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.view.facelets.html;
-
-import javax.faces.event.ActionEvent;
-import javax.faces.view.facelets.*;
-import org.richfaces.component.AbstractPush;
-import org.richfaces.view.facelets.MethodMetadata;
-
-import java.util.EventListener;
-
-public class AjaxPushHandler extends ComponentHandler {
-
- private static final AjaxPushHandlerMetaRule META_RULE = new AjaxPushHandlerMetaRule();
-
-
- public AjaxPushHandler(ComponentConfig config) {
- super(config);
-
- }
-
- protected MetaRuleset createMetaRuleset(Class type) {
- MetaRuleset m = super.createMetaRuleset(type);
- m.addRule(META_RULE);
- return m;
- }
-
- static class AjaxPushHandlerMetaRule extends MetaRule{
-
- public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
- if (meta.isTargetInstanceOf(AbstractPush.class)) {
- if ("action".equals(name)) {
- return new MethodMetadata(attribute) {
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((AbstractPush) instance).setAction(getMethodBinding(ctx));
- }
- };
- }
- if ("actionExpression".equals(name)) {
- return new MethodMetadata(attribute) {
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((AbstractPush) instance).setActionExpression(getMethodExpression(ctx));
- }
- };
- }
- if ("actionListener".equals(name)) {
- return new MethodMetadata(attribute, ActionEvent.class) {
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((AbstractPush) instance).setActionListener(getMethodBinding(ctx));
- }
- };
- }
- if ("eventProducer".equals(name)) {
- return new MethodMetadata(attribute, EventListener.class) {
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((AbstractPush) instance).setEventProducer(getMethodExpression(ctx));
- }
- };
- }
- }
- return null;
- }
- }
-}
Deleted: branches/RF-7817/ui/core/ui/src/main/resources/META-INF/push-managed-beans.faces-config.xml
===================================================================
--- branches/RF-7817/ui/core/ui/src/main/resources/META-INF/push-managed-beans.faces-config.xml 2010-11-01 23:43:58 UTC (rev 19869)
+++ branches/RF-7817/ui/core/ui/src/main/resources/META-INF/push-managed-beans.faces-config.xml 2010-11-01 23:47:24 UTC (rev 19870)
@@ -1,12 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-
-<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
- version="2.0">
-
- <managed-bean eager="true">
- <managed-bean-name>richFacesPushListenersManager</managed-bean-name>
- <managed-bean-class>org.richfaces.component.PushListenersManager</managed-bean-class>
- <managed-bean-scope>application</managed-bean-scope>
- </managed-bean>
-
-</faces-config>
\ No newline at end of file
Copied: branches/RF-7817/ui/core/ui/src/main/resources/META-INF/resources/net.java.dev.atmosphere (from rev 19862, branches/RF-7817/push-redesign/src/main/resources/META-INF/resources/net.java.dev.atmosphere)
Copied: branches/RF-7817/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/push.js (from rev 19862, branches/RF-7817/push-redesign/src/main/resources/META-INF/resources/org.richfaces/push.js)
===================================================================
--- branches/RF-7817/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/push.js (rev 0)
+++ branches/RF-7817/ui/core/ui/src/main/resources/META-INF/resources/org.richfaces/push.js 2010-11-01 23:47:24 UTC (rev 19870)
@@ -0,0 +1,237 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+(function(jsf, richfaces, _$) {
+
+ var COMPONENT_NAME = "Push";
+
+ var RICH_NAMESPACE = richfaces.Event.RICH_NAMESPACE;
+
+ var EVENT_NAMESPACE_SEPARATOR = richfaces.Event.EVENT_NAMESPACE_SEPARATOR;
+
+ var DATA_EVENT_NAME = 'dataAvailable' + EVENT_NAMESPACE_SEPARATOR + RICH_NAMESPACE + EVENT_NAMESPACE_SEPARATOR + COMPONENT_NAME;
+
+ var ERROR_EVENT_NAME = 'error' + EVENT_NAMESPACE_SEPARATOR + RICH_NAMESPACE + EVENT_NAMESPACE_SEPARATOR + COMPONENT_NAME;
+
+ var getDataEventNamespace = function(address) {
+ return DATA_EVENT_NAME + EVENT_NAMESPACE_SEPARATOR + address;
+ };
+
+ var getErrorEventNamespace = function(address) {
+ return ERROR_EVENT_NAME + EVENT_NAMESPACE_SEPARATOR + address;
+ };
+
+ richfaces.Push = (function() {
+
+ var addedTopics = {};
+
+ var removedTopics = {};
+
+ var handlersCounter = {};
+
+ var pushUrl = null;
+
+ var pushSessionId = null;
+
+ var suspendMessageEndMarker = /(<!--[^>]+-->\s*)+/;
+
+ var messageCallback = function(response) {
+ var dataString = response.responseBody.replace(suspendMessageEndMarker, "");
+ if (dataString) {
+ var messages = _$.parseJSON(dataString);
+ if (messages) {
+ for (var i = 0; i < messages.length; i++) {
+ var message = messages[i];
+
+ richfaces.Event.fire(document, getDataEventNamespace(message.topic), message.data);
+ }
+ }
+ }
+ };
+
+ var connect = function() {
+ var pushSessionIdRequestHandler = function(data) {
+ var subscriptionData = _$.parseJSON(data);
+
+
+ for (var failedTopicKey in subscriptionData.failures) {
+ richfaces.Event.fire(
+ document,
+ getErrorEventNamespace(failedTopicKey),
+ subscriptionData.failures[failedTopicKey]
+ );
+ }
+
+ if (subscriptionData.sessionId) {
+ pushSessionId = subscriptionData.sessionId;
+
+ _$.atmosphere.subscribe(pushUrl + "?__richfacesPushAsync=1&pushSessionId=" + pushSessionId, messageCallback, {
+ /*transport: 'websocket'*/
+ });
+ }
+ };
+
+ var topics = new Array();
+ for (var topicName in handlersCounter) {
+ topics.push(topicName);
+ }
+
+ var data = {
+ "pushTopic": topics
+ };
+
+ if (pushSessionId) {
+ data['forgetPushSessionId'] = pushSessionId;
+ }
+
+ //TODO handle request errors
+ _$.ajax({
+ data: data,
+ dataType: 'text',
+ success: pushSessionIdRequestHandler,
+ traditional: true,
+ type: 'POST',
+ url: pushUrl
+ });
+ };
+
+ var disconnect = function() {
+ _$.atmosphere.closeSuspendedConnection();
+ };
+
+ return {
+ increaseSubscriptionCounters: function(address) {
+ if (isNaN(handlersCounter[address]++)) {
+ handlersCounter[address] = 1;
+ addedTopics[address] = true;
+ }
+ },
+
+ decreaseSubscriptionCounters: function(address) {
+ if (--handlersCounter[address] == 0) {
+ delete handlersCounter[address];
+ removedTopics[address] = true;
+ }
+ },
+
+ setPushUrl: function(argPushUrl) {
+ if (argPushUrl.charAt(0) == '/') {
+ pushUrl = location.protocol + '//' + location.host + argPushUrl;
+ } else {
+ pushUrl = argPushUrl;
+ }
+ },
+
+ updateConnection: function() {
+ if (_$.isEmptyObject(handlersCounter)) {
+ disconnect();
+ } else if (!_$.isEmptyObject(addedTopics) || !_$.isEmptyObject(removedTopics)) {
+ disconnect();
+ connect();
+ }
+
+ addedTopics = {};
+ removedTopics = {};
+ }
+ };
+
+ }());
+
+ _$(document).ready(richfaces.Push.updateConnection);
+
+ var ajaxEventHandler = function(event) {
+ if (event.type == 'event') {
+ if (event.status != 'success') {
+ return;
+ }
+ } else if (event.type != 'error') {
+ return;
+ }
+
+ richfaces.Push.updateConnection();
+ };
+
+ jsf.ajax.addOnEvent(ajaxEventHandler);
+ jsf.ajax.addOnError(ajaxEventHandler);
+
+ richfaces.ui = richfaces.ui || {};
+
+ richfaces.ui.Push = richfaces.BaseComponent.extendClass({
+
+ name: COMPONENT_NAME,
+
+ init: function (id, options) {
+ this.id = id;
+ this.attachToDom();
+
+ this.__address = options.address;
+ this.__handlers = {};
+
+ if (options.dataHandler) {
+ //TODO check compatibility with f:ajax
+ this.__bindDataHandler(options.dataHandler);
+ }
+
+ if (options.errorHandler) {
+ //TODO check compatibility with f:ajax
+ this.__bindErrorHandler(options.errorHandler);
+ }
+
+ richfaces.Push.increaseSubscriptionCounters(this.__address);
+ },
+
+ __bindDataHandler: function(handlerCode) {
+ var ns = getDataEventNamespace(this.__address)
+ this.__handlers.data = richfaces.Event.bind(document, ns, new Function("event", handlerCode));
+ },
+
+ __unbindDataHandler: function() {
+ if (this.__handlers.data) {
+ var ns = getDataEventNamespace(this.__address);
+ richfaces.Event.unbind(document, ns, this.__handlers.data);
+
+ this.__handlers.data = null;
+ }
+ },
+
+ __bindErrorHandler: function(handlerCode) {
+ var ns = getErrorEventNamespace(this.__address);
+ this.__handlers.error = richfaces.Event.bind(document, ns, new Function("event", handlerCode));
+ },
+
+ __unbindErrorHandler: function() {
+ if (this.__handlers.error) {
+ var ns = getErrorEventNamespace(this.__address);
+ richfaces.Event.unbind(document, ns, this.__handlers.error);
+
+ this.__handlers.error = null;
+ }
+ },
+
+ destroy: function() {
+ this.__unbindDataHandler();
+ this.__unbindErrorHandler();
+
+ richfaces.Push.decreaseSubscriptionCounters(this.__address);
+ }
+ });
+
+}(jsf, window.RichFaces, jQuery));
\ No newline at end of file
Copied: branches/RF-7817/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/push.template.xml (from rev 19862, branches/RF-7817/push-redesign/src/main/templates/push.template.xml)
===================================================================
--- branches/RF-7817/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/push.template.xml (rev 0)
+++ branches/RF-7817/ui/core/ui/src/main/templates/org/ajax4jsf/renderkit/html/push.template.xml 2010-11-01 23:47:24 UTC (rev 19870)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cdk:root xmlns="http://jboss.org/schema/richfaces/cdk/xhtml-el" xmlns:cdk="http://jboss.org/schema/richfaces/cdk/core"
+ xmlns:c="http://jboss.org/schema/richfaces/cdk/jstl/core" xmlns:cc="http://jboss.org/schema/richfaces/cdk/jsf/composite"
+ xmlns:javaee="http://java.sun.com/xml/ns/javaee">
+
+ <cc:interface>
+ <cdk:class>org.richfaces.renderkit.html.PushRenderer</cdk:class>
+ <cdk:superclass>org.richfaces.renderkit.PushRendererBase</cdk:superclass>
+ <cdk:component-family>org.richfaces.Push</cdk:component-family>
+ <cdk:renderer-type>org.richfaces.PushRenderer</cdk:renderer-type>
+ <cdk:renders-children>true</cdk:renders-children>
+
+ <cdk:resource-dependency library="javax.faces" name="jsf.js" />
+ <cdk:resource-dependency name="jquery.js" />
+ <cdk:resource-dependency name="richfaces.js" />
+ <cdk:resource-dependency name="richfaces-event.js" />
+ <cdk:resource-dependency name="richfaces-base-component.js" />
+ <cdk:resource-dependency library="net.java.dev.atmosphere" name="jquery-atmosphere.js" />
+ <cdk:resource-dependency library="org.richfaces" name="push.js" />
+ </cc:interface>
+
+ <cc:implementation>
+ <span id="#{clientId}">
+ <script type="text/javascript">
+ <c:if test="#{shouldEncodePushUrl(facesContext)}">
+ RichFaces.Push.setPushUrl("#{getPushUrl(facesContext)}");
+ </c:if>
+
+ new RichFaces.ui.Push("#{clientId}", #{getOptionsString(facesContext, component)});
+ </script>
+ </span>
+ </cc:implementation>
+
+</cdk:root>
15 years
JBoss Rich Faces SVN: r19869 - in branches/RF-7817/core: impl and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-01 19:43:58 -0400 (Mon, 01 Nov 2010)
New Revision: 19869
Added:
branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractRequest.java
branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractSession.java
branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractTopic.java
branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AtmosphereHandlerProvider.java
branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AtmospherePushHandler.java
branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/ConsumingCollection.java
branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/DefaultMessageDataSerializer.java
branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/SessionManagerImpl.java
branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/SessionQueue.java
branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/jms/
branches/RF-7817/core/impl/src/main/java/org/richfaces/webapp/PushFilter.java
Removed:
branches/RF-7817/core/api/src/main/java/org/ajax4jsf/event/PushEventListener.java
branches/RF-7817/core/impl/src/main/java/org/ajax4jsf/webapp/PushEventsCounter.java
branches/RF-7817/core/impl/src/main/java/org/richfaces/application/DummyPushContextFactory.java
Modified:
branches/RF-7817/core/impl/
branches/RF-7817/core/impl/pom.xml
branches/RF-7817/core/impl/richfaces-suppressions.xml
branches/RF-7817/core/impl/src/main/java/org/richfaces/application/DefaultModule.java
Log:
https://jira.jboss.org/browse/RF-9158
Deleted: branches/RF-7817/core/api/src/main/java/org/ajax4jsf/event/PushEventListener.java
===================================================================
--- branches/RF-7817/core/api/src/main/java/org/ajax4jsf/event/PushEventListener.java 2010-11-01 23:42:34 UTC (rev 19868)
+++ branches/RF-7817/core/api/src/main/java/org/ajax4jsf/event/PushEventListener.java 2010-11-01 23:43:58 UTC (rev 19869)
@@ -1,31 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.event;
-
-import java.util.EventListener;
-import java.util.EventObject;
-
-public interface PushEventListener extends EventListener {
- public void onEvent(EventObject event);
-}
Property changes on: branches/RF-7817/core/impl
___________________________________________________________________
Name: svn:ignore
- target
.settings
.project
.classpath
.clover
.externalToolBuilders
+ target
.settings
.project
.classpath
.clover
.externalToolBuilders
bin
Modified: branches/RF-7817/core/impl/pom.xml
===================================================================
--- branches/RF-7817/core/impl/pom.xml 2010-11-01 23:42:34 UTC (rev 19868)
+++ branches/RF-7817/core/impl/pom.xml 2010-11-01 23:43:58 UTC (rev 19869)
@@ -87,6 +87,18 @@
<optional>true</optional>
</dependency>
+ <!-- Push dependencies -->
+ <dependency>
+ <groupId>org.atmosphere</groupId>
+ <artifactId>atmosphere-runtime</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>javax.jms</groupId>
+ <artifactId>jms</artifactId>
+ <optional>true</optional>
+ </dependency>
+
<!-- Test Dependencies -->
<dependency>
<groupId>org.jboss.test-jsf</groupId>
Modified: branches/RF-7817/core/impl/richfaces-suppressions.xml
===================================================================
--- branches/RF-7817/core/impl/richfaces-suppressions.xml 2010-11-01 23:42:34 UTC (rev 19868)
+++ branches/RF-7817/core/impl/richfaces-suppressions.xml 2010-11-01 23:43:58 UTC (rev 19869)
@@ -16,4 +16,5 @@
<suppress checks="IllegalCatch" files="ResourceHandlerImpl.java" />
<suppress checks="IllegalThrows" files="AbstractThreadedTest.java" />
<suppress checks="ModifiedControlVariable" files="URLCodec.java" />
+ <suppress checks="IllegalCatch" files="AbstractRequest.java" />
</suppressions>
Deleted: branches/RF-7817/core/impl/src/main/java/org/ajax4jsf/webapp/PushEventsCounter.java
===================================================================
--- branches/RF-7817/core/impl/src/main/java/org/ajax4jsf/webapp/PushEventsCounter.java 2010-11-01 23:42:34 UTC (rev 19868)
+++ branches/RF-7817/core/impl/src/main/java/org/ajax4jsf/webapp/PushEventsCounter.java 2010-11-01 23:43:58 UTC (rev 19869)
@@ -1,53 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.webapp;
-
-import java.io.Serializable;
-import java.util.EventObject;
-
-import org.ajax4jsf.event.PushEventListener;
-
-public class PushEventsCounter implements PushEventListener, Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 4060284352186710009L;
- private volatile boolean performed = false;
-
- public void onEvent(EventObject event) {
- performed = true;
- }
-
- /**
- * @return the performed
- */
- public boolean isPerformed() {
- return performed;
- }
-
- /**
- */
- public void processed() {
- this.performed = false;
- }
-}
Modified: branches/RF-7817/core/impl/src/main/java/org/richfaces/application/DefaultModule.java
===================================================================
--- branches/RF-7817/core/impl/src/main/java/org/richfaces/application/DefaultModule.java 2010-11-01 23:42:34 UTC (rev 19868)
+++ branches/RF-7817/core/impl/src/main/java/org/richfaces/application/DefaultModule.java 2010-11-01 23:43:58 UTC (rev 19869)
@@ -3,6 +3,7 @@
import org.richfaces.application.configuration.ConfigurationService;
import org.richfaces.application.configuration.ConfigurationServiceImpl;
import org.richfaces.application.push.PushContextFactory;
+import org.richfaces.application.push.impl.jms.PushContextFactoryImpl;
import org.richfaces.cache.Cache;
import org.richfaces.l10n.BundleLoader;
import org.richfaces.renderkit.AjaxDataSerializer;
@@ -28,7 +29,7 @@
factory.setInstance(ResourceLibraryFactory.class, new ResourceLibraryFactoryImpl());
//TODO add default implementation class name
- factory.setInstance(PushContextFactory.class, ServiceLoader.loadService(PushContextFactory.class, DummyPushContextFactory.class));
+ factory.setInstance(PushContextFactory.class, ServiceLoader.loadService(PushContextFactory.class, PushContextFactoryImpl.class));
}
}
Deleted: branches/RF-7817/core/impl/src/main/java/org/richfaces/application/DummyPushContextFactory.java
===================================================================
--- branches/RF-7817/core/impl/src/main/java/org/richfaces/application/DummyPushContextFactory.java 2010-11-01 23:42:34 UTC (rev 19868)
+++ branches/RF-7817/core/impl/src/main/java/org/richfaces/application/DummyPushContextFactory.java 2010-11-01 23:43:58 UTC (rev 19869)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.application;
-
-import org.richfaces.application.push.PushContext;
-import org.richfaces.application.push.PushContextFactory;
-
-/**
- * @author Nick Belaevski
- *
- */
-//TODO - remove after push-redesign project merge
-public class DummyPushContextFactory implements PushContextFactory {
-
- public PushContext getPushContext() {
- throw new UnsupportedOperationException();
- }
-
-}
Copied: branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractRequest.java (from rev 19862, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/AbstractRequest.java)
===================================================================
--- branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractRequest.java (rev 0)
+++ branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractRequest.java 2010-11-01 23:43:58 UTC (rev 19869)
@@ -0,0 +1,231 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push.impl;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ajax4jsf.javascript.JSLiteral;
+import org.ajax4jsf.javascript.ScriptString;
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.atmosphere.cpr.AtmosphereEventLifecycle;
+import org.atmosphere.cpr.AtmosphereResource;
+import org.atmosphere.cpr.AtmosphereResourceEvent;
+import org.atmosphere.cpr.AtmosphereResourceEventListener;
+import org.atmosphere.websocket.WebSocketSupport;
+import org.richfaces.application.push.Request;
+import org.richfaces.application.push.Session;
+import org.richfaces.application.push.TopicKey;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class AbstractRequest implements Request {
+
+ private static final String TOPIC_KEY = "topic";
+
+ private static final String DATA_KEY = "data";
+
+ private static final int SUSPEND_TIMEOUT = 30 * 1000;
+
+ private static final class Message implements ScriptString {
+
+ private TopicKey topicKey;
+
+ private String serializedData;
+
+ public Message(TopicKey topicKey, String serializedData) {
+ super();
+ this.topicKey = topicKey;
+ this.serializedData = serializedData;
+ }
+
+ public String toScript() {
+ Map<String,Object> map = new HashMap<String, Object>(2);
+
+ map.put(TOPIC_KEY, topicKey.getTopicAddress());
+ map.put(DATA_KEY, new JSLiteral(serializedData));
+
+ return ScriptUtils.toScript(map);
+ }
+
+ public void appendScript(StringBuffer functionString) {
+ functionString.append(toScript());
+ }
+ }
+
+ private static final class FlushMessagesTask implements Runnable {
+
+ private Request request;
+
+ public FlushMessagesTask(Request request) {
+ super();
+ this.request = request;
+ }
+
+ public void run() {
+ try {
+ request.flushMessages();
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ private final AtmosphereResourceEventListener resourceEventListener = new AtmosphereResourceEventListener() {
+
+ public void onSuspend(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ AbstractRequest.this.onSuspend();
+ }
+
+ public void onResume(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ AbstractRequest.this.onResume();
+ }
+
+ public void onDisconnect(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ AbstractRequest.this.onDisconnect();
+ }
+
+ public void onBroadcast(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event) {
+ AbstractRequest.this.onBroadcast();
+ }
+ };
+
+ private final AtmosphereResource<HttpServletRequest, HttpServletResponse> atmosphereResource;
+
+ private final Session session;
+
+ private final ExecutorService executorService;
+
+ private final Queue<Message> messagesQueue = new ConcurrentLinkedQueue<Message>();
+
+ private AtomicBoolean submitted = new AtomicBoolean(false);
+
+ public AbstractRequest(AtmosphereResource<HttpServletRequest, HttpServletResponse> atmosphereResource, Session session,
+ ExecutorService executorService) {
+
+ super();
+
+ this.atmosphereResource = atmosphereResource;
+
+ ((AtmosphereEventLifecycle) atmosphereResource).addEventListener(resourceEventListener);
+
+ this.session = session;
+ this.executorService = executorService;
+ }
+
+ private void submitToWorker() {
+ if (submitted.compareAndSet(false, true)) {
+ executorService.submit(new FlushMessagesTask(this));
+ }
+ }
+
+ private String serializeMessages() {
+ return ScriptUtils.toScript(new ConsumingCollection<Message>(messagesQueue));
+ }
+
+ public void flushMessages() throws IOException {
+ String serializedMessages = serializeMessages();
+ PrintWriter writer = atmosphereResource.getResponse().getWriter();
+ writer.write(serializedMessages);
+ writer.flush();
+
+ submitted.compareAndSet(true, false);
+
+ if (isPolling()) {
+ atmosphereResource.resume();
+ } else if (!messagesQueue.isEmpty()) {
+ submitToWorker();
+ }
+ }
+
+ public void postMessage(TopicKey topicKey, String serializedMessage) {
+ messagesQueue.add(new Message(topicKey, serializedMessage));
+ submitToWorker();
+ }
+
+ public void suspend() throws IOException {
+ atmosphereResource.suspend(SUSPEND_TIMEOUT, isPolling());
+ }
+
+ public void resume() throws IOException {
+ atmosphereResource.resume();
+ }
+
+ public boolean isSuspended() {
+ return atmosphereResource.getAtmosphereResourceEvent().isSuspended();
+ }
+
+ public boolean isPolling() {
+ HttpServletRequest req = atmosphereResource.getRequest();
+ boolean isWebsocket = req.getAttribute(WebSocketSupport.WEBSOCKET_SUSPEND) != null ||
+ req.getAttribute(WebSocketSupport.WEBSOCKET_RESUME) != null;
+
+ //TODO how to detect non-polling transports?
+ return !isWebsocket;
+ }
+
+ public Session getSession() {
+ return session;
+ }
+
+ protected AtmosphereResource<HttpServletRequest, HttpServletResponse> getResource() {
+ return atmosphereResource;
+ }
+
+ protected void onSuspend() {
+ }
+
+ protected void onResume() {
+ try {
+ session.disconnect();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ protected void onDisconnect() {
+ try {
+ session.disconnect();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ protected void onBroadcast() {
+ }
+
+}
Copied: branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractSession.java (from rev 19862, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/AbstractSession.java)
===================================================================
--- branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractSession.java (rev 0)
+++ branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractSession.java 2010-11-01 23:43:58 UTC (rev 19869)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push.impl;
+
+import java.io.IOException;
+
+import org.richfaces.application.push.Request;
+import org.richfaces.application.push.Session;
+import org.richfaces.application.push.SessionManager;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class AbstractSession implements Session {
+
+ private static final int MAX_INACTIVE_INTERVAL = 5 * 60 * 1000;
+
+ private final String id;
+
+ private final SessionManager sessionManager;
+
+ private volatile long lastAccessedTime;
+
+ private volatile Request request;
+
+ public AbstractSession(String id, SessionManager sessionManager) {
+ super();
+ this.id = id;
+ this.sessionManager = sessionManager;
+
+ resetLastAccessedTimeToCurrent();
+ }
+
+ private void resetLastAccessedTimeToCurrent() {
+ lastAccessedTime = System.currentTimeMillis();
+ }
+
+ private void requeue() {
+ resetLastAccessedTimeToCurrent();
+ sessionManager.requeue(this);
+ }
+
+ public void connect(Request request) throws Exception {
+ if (this.request != null) {
+ this.request.resume();
+ }
+
+ this.request = request;
+
+ requeue();
+
+ request.suspend();
+ }
+
+ public void disconnect() throws Exception {
+ this.request = null;
+ }
+
+ public long getLastAccessedTime() {
+ if (request != null) {
+ return System.currentTimeMillis();
+ }
+
+ return lastAccessedTime;
+ }
+
+ public int getMaxInactiveInterval() {
+ return MAX_INACTIVE_INTERVAL;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public Request getRequest() {
+ return request;
+ }
+
+ public void destroy() {
+ if (request != null) {
+ try {
+ request.resume();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ request = null;
+ //TODO - clean up request
+ }
+
+ sessionManager.removePushSession(this);
+ // TODO Auto-generated method stub
+
+ }
+}
Copied: branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractTopic.java (from rev 19862, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/AbstractTopic.java)
===================================================================
--- branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractTopic.java (rev 0)
+++ branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AbstractTopic.java 2010-11-01 23:43:58 UTC (rev 19869)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push.impl;
+
+import java.text.MessageFormat;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.richfaces.application.push.EventAbortedException;
+import org.richfaces.application.push.MessageDataSerializer;
+import org.richfaces.application.push.MessageException;
+import org.richfaces.application.push.Topic;
+import org.richfaces.application.push.TopicEvent;
+import org.richfaces.application.push.TopicKey;
+import org.richfaces.application.push.TopicListener;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class AbstractTopic implements Topic {
+
+ private static final Logger LOGGER = RichfacesLogger.APPLICATION.getLogger();
+
+ private TopicKey key;
+
+ private volatile MessageDataSerializer serializer;
+
+ private volatile boolean allowSubtopics;
+
+ private List<TopicListener> listeners = new CopyOnWriteArrayList<TopicListener>();
+
+ public AbstractTopic(TopicKey key) {
+ super();
+ this.key = key;
+ }
+
+ public MessageDataSerializer getMessageDataSerializer() {
+ if (serializer == null) {
+ return DefaultMessageDataSerializer.instance();
+ }
+
+ return serializer;
+ }
+
+ public void setMessageDataSerializer(MessageDataSerializer serializer) {
+ this.serializer = serializer;
+ }
+
+ public boolean isAllowSubtopics() {
+ return allowSubtopics;
+ }
+
+ public void setAllowSubtopics(boolean allowSubtopics) {
+ this.allowSubtopics = allowSubtopics;
+ }
+
+ public TopicKey getKey() {
+ return key;
+ }
+
+ public void addTopicListener(TopicListener topicListener) {
+ listeners.add(topicListener);
+ }
+
+ public void removeTopicListener(TopicListener topicListener) {
+ listeners.remove(topicListener);
+ }
+
+ public void publishEvent(TopicEvent event) throws EventAbortedException {
+ for (TopicListener listener: listeners) {
+ if (event.isAppropriateListener(listener)) {
+ try {
+ event.invokeListener(listener);
+ } catch (EventAbortedException e) {
+ throw e;
+ } catch (Exception e) {
+ LOGGER.error(MessageFormat.format("Exception invoking listener: {0}", e.getMessage()), e);
+ }
+ }
+ }
+ }
+
+ public abstract void publish(String subtopic, Object messageData) throws MessageException;
+
+}
Copied: branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AtmosphereHandlerProvider.java (from rev 19862, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/AtmosphereHandlerProvider.java)
===================================================================
--- branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AtmosphereHandlerProvider.java (rev 0)
+++ branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AtmosphereHandlerProvider.java 2010-11-01 23:43:58 UTC (rev 19869)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push.impl;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.atmosphere.cpr.AtmosphereHandler;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public interface AtmosphereHandlerProvider {
+
+ public AtmosphereHandler<HttpServletRequest, HttpServletResponse> getHandler();
+
+}
Copied: branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AtmospherePushHandler.java (from rev 19862, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/AtmospherePushHandler.java)
===================================================================
--- branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AtmospherePushHandler.java (rev 0)
+++ branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/AtmospherePushHandler.java 2010-11-01 23:43:58 UTC (rev 19869)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push.impl;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.atmosphere.cpr.AtmosphereHandler;
+import org.atmosphere.cpr.AtmosphereResource;
+import org.atmosphere.cpr.AtmosphereResourceEvent;
+import org.richfaces.application.push.Request;
+import org.richfaces.application.push.Session;
+import org.richfaces.application.push.SessionManager;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class AtmospherePushHandler implements AtmosphereHandler<HttpServletRequest, HttpServletResponse> {
+
+ private static final ThreadFactory DAEMON_THREADS_FACTORY = new ThreadFactory() {
+
+ private final AtomicInteger threadsCounter = new AtomicInteger();
+
+ public Thread newThread(Runnable r) {
+ Thread t = new Thread(r, "rf-push-worker-thread-" + threadsCounter.getAndIncrement());
+ t.setDaemon(true);
+
+ return t;
+ }
+ };
+
+ private static final String PUSH_SESSION_ID_PARAM = "pushSessionId";
+
+ private SessionManager sessionManager;
+
+ private ExecutorService worker;
+
+ public AtmospherePushHandler() {
+ super();
+
+ sessionManager = new SessionManagerImpl(DAEMON_THREADS_FACTORY);
+ worker = Executors.newCachedThreadPool(DAEMON_THREADS_FACTORY);
+ }
+
+ public SessionManager getSessionManager() {
+ return sessionManager;
+ }
+
+ public void onRequest(AtmosphereResource<HttpServletRequest, HttpServletResponse> resource) throws IOException {
+ // TODO Auto-generated method stub
+
+ HttpServletRequest req = resource.getRequest();
+ HttpServletResponse resp = resource.getResponse();
+
+ String pushSessionId = req.getParameter(PUSH_SESSION_ID_PARAM);
+
+ Session session = null;
+
+ if (pushSessionId != null) {
+ session = getSessionManager().getPushSession(pushSessionId);
+ }
+
+ if (session == null) {
+ //TODO - debug log
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
+ return;
+ }
+
+ resp.setContentType("text/plain");
+
+ try {
+ session.connect(createRequest(resource, session));
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void onStateChange(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event)
+ throws IOException {
+ //do nothing
+ }
+
+ protected abstract Request createRequest(AtmosphereResource<HttpServletRequest, HttpServletResponse> resource, Session session);
+
+ protected ExecutorService getWorker() {
+ return worker;
+ }
+
+ public void init(ServletConfig servletConfig) throws Exception {
+ }
+
+ public void destroy() throws Exception {
+ sessionManager.destroy();
+ }
+
+}
Copied: branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/ConsumingCollection.java (from rev 19862, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/ConsumingCollection.java)
===================================================================
--- branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/ConsumingCollection.java (rev 0)
+++ branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/ConsumingCollection.java 2010-11-01 23:43:58 UTC (rev 19869)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push.impl;
+
+import java.util.AbstractCollection;
+import java.util.Iterator;
+import java.util.Queue;
+
+import com.google.common.collect.AbstractIterator;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ConsumingCollection<T> extends AbstractCollection<T> {
+
+ private final class ConsumingIterator extends AbstractIterator<T> {
+ @Override
+ protected T computeNext() {
+ T next = queue.poll();
+ if (next == null) {
+ endOfData();
+ }
+ return next;
+ }
+ }
+
+ private Queue<T> queue;
+
+ public ConsumingCollection(Queue<T> queue) {
+ super();
+ this.queue = queue;
+ }
+
+ @Override
+ public Iterator<T> iterator() {
+ return new ConsumingIterator();
+ }
+
+ @Override
+ public int size() {
+ return queue.size();
+ }
+
+}
Copied: branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/DefaultMessageDataSerializer.java (from rev 19862, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/DefaultMessageDataSerializer.java)
===================================================================
--- branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/DefaultMessageDataSerializer.java (rev 0)
+++ branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/DefaultMessageDataSerializer.java 2010-11-01 23:43:58 UTC (rev 19869)
@@ -0,0 +1,44 @@
+package org.richfaces.application.push.impl;
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.richfaces.application.push.MessageDataSerializer;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public final class DefaultMessageDataSerializer implements MessageDataSerializer {
+
+ private static final MessageDataSerializer INSTANCE = new DefaultMessageDataSerializer();
+
+ private DefaultMessageDataSerializer() {}
+
+ public static MessageDataSerializer instance() {
+ return INSTANCE;
+ }
+
+ public String serialize(Object data) {
+ return ScriptUtils.toScript(data);
+ }
+}
Copied: branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/SessionManagerImpl.java (from rev 19862, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/SessionManagerImpl.java)
===================================================================
--- branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/SessionManagerImpl.java (rev 0)
+++ branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/SessionManagerImpl.java 2010-11-01 23:43:58 UTC (rev 19869)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push.impl;
+
+import java.util.Iterator;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ThreadFactory;
+
+import org.richfaces.application.push.Session;
+import org.richfaces.application.push.SessionManager;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
+
+import com.google.common.collect.MapMaker;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class SessionManagerImpl implements SessionManager {
+
+ private static final Logger LOGGER = RichfacesLogger.APPLICATION.getLogger();
+
+ private final class SessionsExpirationRunnable implements Runnable {
+ public void run() {
+ while (true) {
+ try {
+ Session session = sessionQueue.take();
+ sessionMap.remove(session.getId());
+ session.destroy();
+ } catch (InterruptedException e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ }
+
+ }
+ }
+
+ private ConcurrentMap<String, Session> sessionMap = new MapMaker().makeMap();
+
+ private SessionQueue sessionQueue = new SessionQueue();
+
+ public SessionManagerImpl(ThreadFactory threadFactory) {
+ threadFactory.newThread(new SessionsExpirationRunnable()).start();
+ }
+
+ public Session getPushSession(String id) {
+ return sessionMap.get(id);
+ }
+
+ public void removePushSession(Session session) {
+ sessionMap.remove(session.getId());
+ if (session != null) {
+ sessionQueue.remove(session);
+ }
+ }
+
+ public void destroy() {
+ //TODO notify all session
+ sessionQueue.clear();
+
+ while (!sessionMap.isEmpty()) {
+ for (Iterator<Session> sessionsItr = sessionMap.values().iterator(); sessionsItr.hasNext(); ) {
+ Session session = sessionsItr.next();
+ sessionsItr.remove();
+
+ session.destroy();
+ }
+ }
+
+ sessionMap.clear();
+ }
+
+ public void putPushSession(Session session) throws IllegalStateException {
+ Session existingSession = sessionMap.putIfAbsent(session.getId(), session);
+ if (existingSession != null) {
+ throw new IllegalStateException();
+ }
+
+ requeue(session);
+ }
+
+ public void requeue(Session session) {
+ sessionQueue.requeue(session);
+ }
+}
Copied: branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/SessionQueue.java (from rev 19862, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/SessionQueue.java)
===================================================================
--- branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/SessionQueue.java (rev 0)
+++ branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/SessionQueue.java 2010-11-01 23:43:58 UTC (rev 19869)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.application.push.impl;
+
+import java.util.Comparator;
+import java.util.PriorityQueue;
+import java.util.Queue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.richfaces.application.push.Session;
+
+/**
+ * Based on DelayQueue by Doug Lea: http://gee.cs.oswego.edu/
+ * @author Nick Belaevski
+ *
+ */
+//TODO - optimize algorithm
+final class SessionQueue {
+
+ private static final Comparator<? super Session> SESSIONS_COMPARATOR = new Comparator<Session>() {
+
+ public int compare(Session o1, Session o2) {
+ Long delay1 = Long.valueOf(o1.getLastAccessedTime() + o1.getMaxInactiveInterval());
+ Long delay2 = Long.valueOf(o2.getLastAccessedTime() + o2.getMaxInactiveInterval());
+
+ return delay1.compareTo(delay2);
+ }
+
+ };
+
+ private final Queue<Session> queue = new PriorityQueue<Session>(1, SESSIONS_COMPARATOR);
+
+ private final ReentrantLock lock = new ReentrantLock();
+
+ private final Condition available = lock.newCondition();
+
+ private long getDelay(Session session, TimeUnit unit) {
+ return unit.convert(session.getLastAccessedTime() + session.getMaxInactiveInterval() - System.currentTimeMillis(),
+ TimeUnit.MILLISECONDS);
+ }
+
+ public Session take() throws InterruptedException {
+ final ReentrantLock lock = this.lock;
+ lock.lockInterruptibly();
+ try {
+ while (true) {
+ Session first = queue.peek();
+ if (first == null) {
+ available.await();
+ } else {
+ long delay = getDelay(first, TimeUnit.NANOSECONDS);
+ if (delay > 0) {
+ available.awaitNanos(delay);
+ } else {
+ Session x = queue.poll();
+ assert x != null;
+ if (queue.size() != 0) {
+ available.signalAll(); // wake up other takers
+ }
+ return x;
+ }
+ }
+ }
+ } finally {
+ lock.unlock();
+ }
+
+ }
+
+ public void remove(Session session) {
+ final ReentrantLock lock = this.lock;
+ lock.lock();
+ try {
+ queue.remove(session);
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ public void requeue(Session session) {
+ final ReentrantLock lock = this.lock;
+ lock.lock();
+ try {
+ queue.remove(session);
+
+ Session first = queue.peek();
+ queue.offer(session);
+ if (first == null || SESSIONS_COMPARATOR.compare(session, first) < 0) {
+ available.signalAll();
+ }
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ public void clear() {
+ final ReentrantLock lock = this.lock;
+ lock.lock();
+ try {
+ queue.clear();
+ } finally {
+ lock.unlock();
+ }
+ }
+}
Copied: branches/RF-7817/core/impl/src/main/java/org/richfaces/application/push/impl/jms (from rev 19862, branches/RF-7817/push-redesign/src/main/java/org/richfaces/application/push/impl/jms)
Copied: branches/RF-7817/core/impl/src/main/java/org/richfaces/webapp/PushFilter.java (from rev 19862, branches/RF-7817/push-redesign/src/main/java/org/richfaces/webapp/PushFilter.java)
===================================================================
--- branches/RF-7817/core/impl/src/main/java/org/richfaces/webapp/PushFilter.java (rev 0)
+++ branches/RF-7817/core/impl/src/main/java/org/richfaces/webapp/PushFilter.java 2010-11-01 23:43:58 UTC (rev 19869)
@@ -0,0 +1,159 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.webapp;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Set;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.atmosphere.cpr.AtmosphereServlet;
+import org.richfaces.application.push.PushContext;
+import org.richfaces.application.push.impl.AtmosphereHandlerProvider;
+
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Sets;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+//TODO override broadcaster
+public class PushFilter implements Filter {
+
+ private static final String PUSH_HUB_MAPPING = "/*";
+
+ private static final long serialVersionUID = 7616370505508715222L;
+
+ /**
+ * @author Nick Belaevski
+ *
+ */
+ private final class ServletConfigFacade implements ServletConfig {
+ /**
+ *
+ */
+ private final FilterConfig filterConfig;
+
+ /**
+ * @param filterConfig
+ */
+ private ServletConfigFacade(FilterConfig filterConfig) {
+ this.filterConfig = filterConfig;
+ }
+
+ public String getServletName() {
+ return filterConfig.getFilterName();
+ }
+
+ public ServletContext getServletContext() {
+ return filterConfig.getServletContext();
+ }
+
+ public String getInitParameter(String name) {
+ String result = filterConfig.getInitParameter(name);
+
+ if (result == null) {
+ result = filterConfig.getServletContext().getInitParameter(name);
+ }
+
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Enumeration<String> getInitParameterNames() {
+ Set<String> result = Sets.newLinkedHashSet();
+
+ result.addAll(Collections.list(filterConfig.getInitParameterNames()));
+ result.addAll(Collections.list(filterConfig.getServletContext().getInitParameterNames()));
+
+ return Iterators.asEnumeration(result.iterator());
+ }
+ }
+
+ private AtmosphereServlet atmosphereServlet;
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ AtmosphereHandlerProvider handlerProvider = (AtmosphereHandlerProvider) filterConfig.getServletContext().getAttribute(PushContext.INSTANCE_KEY_NAME);
+
+ if (handlerProvider == null) {
+ return;
+ }
+
+ atmosphereServlet = new AtmosphereServlet() {
+
+ private static final long serialVersionUID = -8719394110408476331L;
+
+ protected boolean detectSupportedFramework(ServletConfig sc) throws ClassNotFoundException, IllegalAccessException, InstantiationException ,NoSuchMethodException ,java.lang.reflect.InvocationTargetException {
+ return false;
+ };
+ };
+ ServletConfigFacade servletConfig = new ServletConfigFacade(filterConfig);
+ atmosphereServlet.init(servletConfig);
+
+ atmosphereServlet.addAtmosphereHandler(PUSH_HUB_MAPPING, handlerProvider.getHandler());
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
+ */
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
+ ServletException {
+
+ if (atmosphereServlet != null && request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
+ HttpServletRequest httpReq = (HttpServletRequest) request;
+ HttpServletResponse httpResp = (HttpServletResponse) response;
+
+ if ("GET".equals(httpReq.getMethod()) && httpReq.getQueryString() != null && httpReq.getQueryString().contains("__richfacesPushAsync")) {
+ atmosphereServlet.doGet(httpReq, httpResp);
+ return;
+ }
+ }
+
+ // TODO Auto-generated method stub
+ chain.doFilter(request, response);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.Filter#destroy()
+ */
+ public void destroy() {
+ if (atmosphereServlet != null) {
+ atmosphereServlet.removeAtmosphereHandler(PUSH_HUB_MAPPING);
+ atmosphereServlet.destroy();
+ atmosphereServlet = null;
+ }
+ // TODO Auto-generated method stub
+ }
+
+}
15 years
JBoss Rich Faces SVN: r19868 - branches/RF-7817/bom.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-11-01 19:42:34 -0400 (Mon, 01 Nov 2010)
New Revision: 19868
Modified:
branches/RF-7817/bom/pom.xml
Log:
https://jira.jboss.org/browse/RF-9158
Modified: branches/RF-7817/bom/pom.xml
===================================================================
--- branches/RF-7817/bom/pom.xml 2010-11-01 22:55:36 UTC (rev 19867)
+++ branches/RF-7817/bom/pom.xml 2010-11-01 23:42:34 UTC (rev 19868)
@@ -191,6 +191,18 @@
<artifactId>ehcache</artifactId>
<version>1.6.0</version>
</dependency>
+
+ <!-- Push dependencies -->
+ <dependency>
+ <groupId>org.atmosphere</groupId>
+ <artifactId>atmosphere-runtime</artifactId>
+ <version>0.6.3</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.jms</groupId>
+ <artifactId>jms</artifactId>
+ <version>1.1</version>
+ </dependency>
</dependencies>
</dependencyManagement>
15 years
JBoss Rich Faces SVN: r19867 - trunk.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-11-01 18:55:36 -0400 (Mon, 01 Nov 2010)
New Revision: 19867
Modified:
trunk/
Log:
Initialized merge tracking via "svnmerge" with revisions "1-19175" from
https://svn.jboss.org/repos/richfaces/branches/RF-8742
Property changes on: trunk
___________________________________________________________________
Name: svnmerge-integrated
- /branches/RF-7817:1-19154 /branches/RF-9309:1-19112,19378
+ /branches/RF-7817:1-19154 /branches/RF-8742:1-19175 /branches/RF-9309:1-19112,19378
15 years
JBoss Rich Faces SVN: r19866 - trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2010-11-01 18:34:12 -0400 (Mon, 01 Nov 2010)
New Revision: 19866
Modified:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/SimpleTreeBean.java
Log:
checkstyle correction
Modified: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/SimpleTreeBean.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/SimpleTreeBean.java 2010-11-01 22:33:11 UTC (rev 19865)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/SimpleTreeBean.java 2010-11-01 22:34:12 UTC (rev 19866)
@@ -42,9 +42,9 @@
private List<CD> cds;
@PostConstruct
public void init() {
- for (CD cd : cds) {
-
- }
+// for (CD cd : cds) {
+//
+// }
}
public List<CD> getCds() {
15 years
JBoss Rich Faces SVN: r19865 - in trunk/examples/richfaces-showcase/src/main: java/org/richfaces/demo/tree and 7 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2010-11-01 18:33:11 -0400 (Mon, 01 Nov 2010)
New Revision: 19865
Added:
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/CDParser.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/SimpleTreeBean.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Artist.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/CD.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Company.java
trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Country.java
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/tree/
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/tree/CDCatalog.xml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml
trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/tree.xhtml
Modified:
trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
Log:
https://jira.jboss.org/browse/RF-9611
Added: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/CDParser.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/CDParser.java (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/CDParser.java 2010-11-01 22:33:11 UTC (rev 19865)
@@ -0,0 +1,54 @@
+package org.richfaces.demo.tree;
+
+import java.net.URL;
+import java.util.List;
+
+import javax.faces.FacesException;
+import javax.faces.bean.ApplicationScoped;
+import javax.faces.bean.ManagedBean;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.richfaces.demo.tree.model.CD;
+
+@ManagedBean(name="cdsParser")
+@ApplicationScoped
+public class CDParser {
+
+ private List<CD> cdsList;
+
+ @XmlRootElement(name = "CATALOG")
+ private static final class CDsHolder {
+
+ private List<CD> cds;
+
+ @XmlElement(name = "CD")
+ public List<CD> getCds() {
+ return cds;
+ }
+
+ @SuppressWarnings("unused")
+ public void setCds(List<CD> cds) {
+ this.cds = cds;
+ }
+ }
+
+ public synchronized List<CD> getCdsList() {
+ if (cdsList == null) {
+ ClassLoader ccl = Thread.currentThread().getContextClassLoader();
+ URL resource = ccl.getResource("org/richfaces/demo/tree/CDCatalog.xml");
+ JAXBContext context;
+ try {
+ context = JAXBContext.newInstance(CDsHolder.class);
+ CDsHolder cdsHolder = (CDsHolder) context.createUnmarshaller().unmarshal(resource);
+ cdsList = cdsHolder.getCds();
+ } catch (JAXBException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+ }
+
+ return cdsList;
+ }
+}
Added: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/SimpleTreeBean.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/SimpleTreeBean.java (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/SimpleTreeBean.java 2010-11-01 22:33:11 UTC (rev 19865)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.demo.tree;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ManagedProperty;
+import javax.faces.bean.SessionScoped;
+
+import org.richfaces.demo.tree.model.CD;
+
+/**
+ * @author Ilya Shaikovsky
+ *
+ */
+@ManagedBean(name = "treeBean")
+@SessionScoped
+public class SimpleTreeBean implements Serializable {
+ @ManagedProperty(value = "#{cdsParser.cdsList}")
+ private List<CD> cds;
+ @PostConstruct
+ public void init() {
+ for (CD cd : cds) {
+
+ }
+ }
+
+ public List<CD> getCds() {
+ return cds;
+ }
+
+ public void setCds(List<CD> cds) {
+ this.cds = cds;
+ }
+
+}
Added: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Artist.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Artist.java (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Artist.java 2010-11-01 22:33:11 UTC (rev 19865)
@@ -0,0 +1,44 @@
+package org.richfaces.demo.tree.model;
+
+import java.util.Enumeration;
+
+import javax.swing.tree.TreeNode;
+
+public class Artist implements TreeNode{
+
+ public TreeNode getChildAt(int childIndex) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getChildCount() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public TreeNode getParent() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getIndex(TreeNode node) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public boolean getAllowsChildren() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isLeaf() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Enumeration children() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/CD.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/CD.java (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/CD.java 2010-11-01 22:33:11 UTC (rev 19865)
@@ -0,0 +1,69 @@
+package org.richfaces.demo.tree.model;
+
+import java.io.Serializable;
+
+import javax.xml.bind.annotation.XmlElement;
+
+public class CD implements Serializable {
+ private String artist;
+ private String title;
+ private String country;
+ private String company;
+ private float price;
+ private int year;
+
+ @XmlElement(name = "ARTIST")
+ public String getArtist() {
+ return artist;
+ }
+
+ public void setArtist(String artist) {
+ this.artist = artist;
+ }
+
+ @XmlElement(name = "TITLE")
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ @XmlElement(name = "COUNTRY")
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+
+ @XmlElement(name = "COMPANY")
+ public String getCompany() {
+ return company;
+ }
+
+ public void setCompany(String company) {
+ this.company = company;
+ }
+
+ @XmlElement(name = "PRICE")
+ public float getPrice() {
+ return price;
+ }
+
+ public void setPrice(float price) {
+ this.price = price;
+ }
+
+ @XmlElement(name = "YEAR")
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
Added: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Company.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Company.java (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Company.java 2010-11-01 22:33:11 UTC (rev 19865)
@@ -0,0 +1,44 @@
+package org.richfaces.demo.tree.model;
+
+import java.util.Enumeration;
+
+import javax.swing.tree.TreeNode;
+
+public class Company implements TreeNode{
+
+ public TreeNode getChildAt(int childIndex) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getChildCount() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public TreeNode getParent() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int getIndex(TreeNode node) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public boolean getAllowsChildren() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isLeaf() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Enumeration children() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Country.java
===================================================================
--- trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Country.java (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/java/org/richfaces/demo/tree/model/Country.java 2010-11-01 22:33:11 UTC (rev 19865)
@@ -0,0 +1,43 @@
+package org.richfaces.demo.tree.model;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+import javax.swing.tree.TreeNode;
+
+import com.google.common.collect.Iterators;
+
+public class Country implements TreeNode {
+ private String name;
+ private List<Company> companies = new ArrayList<Company>();
+
+ public TreeNode getChildAt(int childIndex) {
+ return companies.get(childIndex);
+ }
+
+ public int getChildCount() {
+ return companies.size();
+ }
+
+ public TreeNode getParent() {
+ return null;
+ }
+
+ public int getIndex(TreeNode node) {
+ return companies.indexOf(node);
+ }
+
+ public boolean getAllowsChildren() {
+ return true;
+ }
+
+ public boolean isLeaf() {
+ return companies.isEmpty();
+ }
+
+ public Enumeration<Company> children() {
+ return Iterators.asEnumeration(companies.iterator());
+ }
+
+}
Modified: trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-11-01 22:21:36 UTC (rev 19864)
+++ trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/data/common/navigation.xml 2010-11-01 22:33:11 UTC (rev 19865)
@@ -290,6 +290,21 @@
</demo>
</demos>
</group>
+ <!-- group>
+ <name>Trees</name>
+ <demos>
+ <demo new="true">
+ <id>tree</id>
+ <name>rich:tree</name>
+ <samples>
+ <sample>
+ <id>tree</id>
+ <name>Simple tree from XML</name>
+ </sample>
+ </samples>
+ </demo>
+ </demos>
+ </group-->
<group>
<name>Output/Panels</name>
<demos>
Added: trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/tree/CDCatalog.xml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/tree/CDCatalog.xml (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/resources/org/richfaces/demo/tree/CDCatalog.xml 2010-11-01 22:33:11 UTC (rev 19865)
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="ISO8859-1" ?>
+<CATALOG>
+ <CD>
+ <TITLE>Empire Burlesque</TITLE>
+ <ARTIST>Bob Dylan</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>Columbia</COMPANY>
+ <PRICE>10.90</PRICE>
+ <YEAR>1985</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Hide your heart</TITLE>
+ <ARTIST>Bonnie Tylor</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>CBS Records</COMPANY>
+ <PRICE>9.90</PRICE>
+ <YEAR>1988</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Greatest Hits</TITLE>
+ <ARTIST>Dolly Parton</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>RCA</COMPANY>
+ <PRICE>9.90</PRICE>
+ <YEAR>1982</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Still got the blues</TITLE>
+ <ARTIST>Gary More</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Virgin redords</COMPANY>
+ <PRICE>10.20</PRICE>
+ <YEAR>1990</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Eros</TITLE>
+ <ARTIST>Eros Ramazzotti</ARTIST>
+ <COUNTRY>EU</COUNTRY>
+ <COMPANY>BMG</COMPANY>
+ <PRICE>9.90</PRICE>
+ <YEAR>1997</YEAR>
+ </CD>
+ <CD>
+ <TITLE>One night only</TITLE>
+ <ARTIST>Bee Gees</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Polydor</COMPANY>
+ <PRICE>10.90</PRICE>
+ <YEAR>1998</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Sylvias Mother</TITLE>
+ <ARTIST>Dr.Hook</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>CBS</COMPANY>
+ <PRICE>8.10</PRICE>
+ <YEAR>1973</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Maggie May</TITLE>
+ <ARTIST>Rod Stewart</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Pickwick</COMPANY>
+ <PRICE>8.50</PRICE>
+ <YEAR>1990</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Romanza</TITLE>
+ <ARTIST>Andrea Bocelli</ARTIST>
+ <COUNTRY>EU</COUNTRY>
+ <COMPANY>Polydor</COMPANY>
+ <PRICE>10.80</PRICE>
+ <YEAR>1996</YEAR>
+ </CD>
+ <CD>
+ <TITLE>When a man loves a woman</TITLE>
+ <ARTIST>Percy Sledge</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>Atlantic</COMPANY>
+ <PRICE>8.70</PRICE>
+ <YEAR>1987</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Black angel</TITLE>
+ <ARTIST>Savage Rose</ARTIST>
+ <COUNTRY>EU</COUNTRY>
+ <COMPANY>Mega</COMPANY>
+ <PRICE>10.90</PRICE>
+ <YEAR>1995</YEAR>
+ </CD>
+ <CD>
+ <TITLE>1999 Grammy Nominees</TITLE>
+ <ARTIST>Many</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>Grammy</COMPANY>
+ <PRICE>10.20</PRICE>
+ <YEAR>1999</YEAR>
+ </CD>
+ <CD>
+ <TITLE>For the good times</TITLE>
+ <ARTIST>Kenny Rogers</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Mucik Master</COMPANY>
+ <PRICE>8.70</PRICE>
+ <YEAR>1995</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Big Willie style</TITLE>
+ <ARTIST>Will Smith</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>Columbia</COMPANY>
+ <PRICE>9.90</PRICE>
+ <YEAR>1997</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Tupelo Honey</TITLE>
+ <ARTIST>Van Morrison</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Polydor</COMPANY>
+ <PRICE>8.20</PRICE>
+ <YEAR>1971</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Soulsville</TITLE>
+ <ARTIST>Jorn Hoel</ARTIST>
+ <COUNTRY>Norway</COUNTRY>
+ <COMPANY>WEA</COMPANY>
+ <PRICE>7.90</PRICE>
+ <YEAR>1996</YEAR>
+ </CD>
+ <CD>
+ <TITLE>The very best of</TITLE>
+ <ARTIST>Cat Stevens</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Island</COMPANY>
+ <PRICE>8.90</PRICE>
+ <YEAR>1990</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Stop</TITLE>
+ <ARTIST>Sam Brown</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>A and M</COMPANY>
+ <PRICE>8.90</PRICE>
+ <YEAR>1988</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Bridge of Spies</TITLE>
+ <ARTIST>T`Pau</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Siren</COMPANY>
+ <PRICE>7.90</PRICE>
+ <YEAR>1987</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Private Dancer</TITLE>
+ <ARTIST>Tina Turner</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>Capitol</COMPANY>
+ <PRICE>8.90</PRICE>
+ <YEAR>1983</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Midt om natten</TITLE>
+ <ARTIST>Kim Larsen</ARTIST>
+ <COUNTRY>EU</COUNTRY>
+ <COMPANY>Medley</COMPANY>
+ <PRICE>7.80</PRICE>
+ <YEAR>1983</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Pavarotti Gala Concert</TITLE>
+ <ARTIST>Luciano Pavarotti</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>DECCA</COMPANY>
+ <PRICE>9.90</PRICE>
+ <YEAR>1991</YEAR>
+ </CD>
+ <CD>
+ <TITLE>The dock of the bay</TITLE>
+ <ARTIST>Otis Redding</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>Atlantic</COMPANY>
+ <PRICE>7.90</PRICE>
+ <YEAR>1987</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Picture book</TITLE>
+ <ARTIST>Simply Red</ARTIST>
+ <COUNTRY>EU</COUNTRY>
+ <COMPANY>Elektra</COMPANY>
+ <PRICE>7.20</PRICE>
+ <YEAR>1985</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Red</TITLE>
+ <ARTIST>The Communards</ARTIST>
+ <COUNTRY>UK</COUNTRY>
+ <COMPANY>London</COMPANY>
+ <PRICE>7.80</PRICE>
+ <YEAR>1987</YEAR>
+ </CD>
+ <CD>
+ <TITLE>Unchain my heart</TITLE>
+ <ARTIST>Joe Cocker</ARTIST>
+ <COUNTRY>USA</COUNTRY>
+ <COMPANY>EMI</COMPANY>
+ <PRICE>8.20</PRICE>
+ <YEAR>1987</YEAR>
+ </CD>
+</CATALOG>
Added: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/samples/tree-sample.xhtml 2010-11-01 22:33:11 UTC (rev 19865)
@@ -0,0 +1,26 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich">
+ <h:form id="form">
+ <a4j:repeat value="#{treeBean.cds}" var="cd">#{cd.artist}</a4j:repeat>
+ <ui:remove>
+ <rich:tree id="tree" nodeType="#{node.parent == null ? 'rootNode': 'childNode'}" var="node" value="#{treeBean.rootNodes}"
+ selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}">
+ <rich:treeNode type="rootNode">
+ <h:panelGroup id="rootNodeGroup">
+ Root node: #{node.data} -
+ </h:panelGroup>
+ </rich:treeNode>
+ <rich:treeNode type="childNode">
+ <h:panelGroup id="childNodeGroup">
+ #{node.data} -
+ </h:panelGroup>
+ </rich:treeNode>
+ </rich:tree>
+ </ui:remove>
+ </h:form>
+</ui:composition>
\ No newline at end of file
Added: trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/tree.xhtml
===================================================================
--- trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/tree.xhtml (rev 0)
+++ trunk/examples/richfaces-showcase/src/main/webapp/richfaces/tree/tree.xhtml 2010-11-01 22:33:11 UTC (rev 19865)
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition>
+ <p>DESC</p>
+
+ <ui:include src="#{demoNavigator.sampleIncludeURI}" />
+ <ui:include src="/templates/includes/source-view.xhtml">
+ <ui:param name="src" value="#{demoNavigator.sampleIncludeURI}" />
+ <ui:param name="sourceType" value="xhtml" />
+ <ui:param name="openLabel" value="View Source" />
+ <ui:param name="hideLabel" value="Hide Source" />
+ </ui:include>
+</ui:composition>
+
+</html>
\ No newline at end of file
15 years
JBoss Rich Faces SVN: r19864 - in branches/RF-8742: examples and 14 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-11-01 18:21:36 -0400 (Mon, 01 Nov 2010)
New Revision: 19864
Added:
branches/RF-8742/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TracingSet.java
branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/BaseTreeImage.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineImage.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineLastImage.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeMinusImage.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreePlusImage.java
Removed:
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/last.gif
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/line.gif
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/minus.gif
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/plus.gif
Modified:
branches/RF-8742/
branches/RF-8742/examples/input-demo/src/main/webapp/examples/calendar.xhtml
branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java
branches/RF-8742/examples/iteration-demo/src/main/webapp/tree.xhtml
branches/RF-8742/examples/pom.xml
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.ecss
branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java
branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss
branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties
Log:
Merged revisions 19852-19855,19857-19860 via svnmerge from
https://svn.jboss.org/repos/richfaces/trunk
.......
r19852 | amarkhel | 2010-11-01 09:20:40 -0700 (Mon, 01 Nov 2010) | 1 line
RF-9603
.......
r19853 | amarkhel | 2010-11-01 09:23:04 -0700 (Mon, 01 Nov 2010) | 1 line
extend calendar demo
.......
r19854 | nbelaevski | 2010-11-01 09:42:07 -0700 (Mon, 01 Nov 2010) | 2 lines
https://jira.jboss.org/browse/RF-9315
- selection refactoring
.......
r19855 | amarkhel | 2010-11-01 09:54:18 -0700 (Mon, 01 Nov 2010) | 1 line
RF-9598, RF-9594
.......
r19857 | nbelaevski | 2010-11-01 11:02:02 -0700 (Mon, 01 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9316
.......
r19858 | nbelaevski | 2010-11-01 12:09:23 -0700 (Mon, 01 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9609
.......
r19859 | nbelaevski | 2010-11-01 12:11:05 -0700 (Mon, 01 Nov 2010) | 1 line
https://jira.jboss.org/browse/RF-9600
.......
r19860 | nbelaevski | 2010-11-01 12:15:29 -0700 (Mon, 01 Nov 2010) | 1 line
Added mergeinfo for RF-7817
.......
Property changes on: branches/RF-8742
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-19851
+ /trunk:1-19863
Copied: branches/RF-8742/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java (from rev 19860, trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java)
===================================================================
--- branches/RF-8742/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java (rev 0)
+++ branches/RF-8742/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -0,0 +1,86 @@
+package org.richfaces.demo;
+
+import java.util.Date;
+import java.util.Locale;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+import javax.faces.event.ValueChangeEvent;
+
+@ManagedBean
+@RequestScoped
+public class CalendarBean {
+
+ private Locale locale;
+ private boolean popup;
+ private String pattern;
+ private Date selectedDate;
+ private boolean showApply = true;
+ private boolean useCustomDayLabels;
+
+ public CalendarBean() {
+
+ locale = Locale.US;
+ popup = true;
+ pattern = "d/M/yy HH:mm";
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+ public boolean isPopup() {
+ return popup;
+ }
+
+ public void setPopup(boolean popup) {
+ this.popup = popup;
+ }
+
+ public String getPattern() {
+ return pattern;
+ }
+
+ public void setPattern(String pattern) {
+ this.pattern = pattern;
+ }
+
+ public void selectLocale(ValueChangeEvent event) {
+
+ String tLocale = (String) event.getNewValue();
+ if (tLocale != null) {
+ String lang = tLocale.substring(0, 2);
+ String country = tLocale.substring(3);
+ locale = new Locale(lang, country, "");
+ }
+ }
+
+ public boolean isUseCustomDayLabels() {
+ return useCustomDayLabels;
+ }
+
+ public void setUseCustomDayLabels(boolean useCustomDayLabels) {
+ this.useCustomDayLabels = useCustomDayLabels;
+ }
+
+ public Date getSelectedDate() {
+ return selectedDate;
+ }
+
+ public void setSelectedDate(Date selectedDate) {
+ this.selectedDate = selectedDate;
+ }
+
+ public boolean isShowApply() {
+ return showApply;
+ }
+
+ public void setShowApply(boolean showApply) {
+ this.showApply = showApply;
+ }
+
+}
\ No newline at end of file
Modified: branches/RF-8742/examples/input-demo/src/main/webapp/examples/calendar.xhtml
===================================================================
--- branches/RF-8742/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-01 22:21:36 UTC (rev 19864)
@@ -29,13 +29,52 @@
Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
- <h:head>
- <title>Richfaces Calendar Demo</title>
- </h:head>
- <h:body>
- <h:form id="form">
- <calendar:calendar popup="true"/>
- <h:commandButton value="submit"></h:commandButton>
- </h:form>
- </h:body>
+<h:head>
+ <title>Richfaces Calendar Demo</title>
+</h:head>
+<h:body>
+ <h:form id="form">
+ <h:panelGrid id="panel" columns="2">
+ <h:panelGroup layout="block">
+ <calendar:calendar value="#{calendarBean.selectedDate}" id="calendar"
+ locale="#{calendarBean.locale}" popup="#{calendarBean.popup}"
+ datePattern="#{calendarBean.pattern}"
+ showApplyButton="#{calendarBean.showApply}" cellWidth="24px"
+ cellHeight="22px" style="width:200px">
+ <f:convertDateTime pattern="#{calendarBean.pattern}"
+ onchange="alert('1')" />
+ </calendar:calendar>
+ </h:panelGroup>
+ <h:panelGrid columns="2">
+ <h:outputText value="Popup Mode:" />
+ <h:selectBooleanCheckbox value="#{calendarBean.popup}">
+ <f:ajax event="click" execute="@form" render="calendar @this" />
+ </h:selectBooleanCheckbox>
+ <h:outputText value="Apply Button:" />
+ <h:selectBooleanCheckbox value="#{calendarBean.showApply}">
+ <f:ajax event="click" execute="@form" render="calendar @this" />
+ </h:selectBooleanCheckbox>
+ <h:outputText value="Select Locale" />
+ <h:selectOneRadio value="en/US"
+ valueChangeListener="#{calendarBean.selectLocale}">
+ <f:ajax execute="@form" event="click" render="calendar @this" />
+ <f:selectItem itemLabel="US" itemValue="en/US" />
+ <f:selectItem itemLabel="DE" itemValue="de/DE" />
+ <f:selectItem itemLabel="FR" itemValue="fr/FR" />
+ <f:selectItem itemLabel="RU" itemValue="ru/RU" />
+ </h:selectOneRadio>
+
+ <h:outputText value="Select Date Pattern:" />
+ <h:selectOneMenu value="#{calendarBean.pattern}">
+ <f:ajax execute="@form" event="change" render="calendar @this" />
+ <f:selectItem itemLabel="d/M/yy HH:mm" itemValue="d/M/yy HH:mm" />
+ <f:selectItem itemLabel="dd/M/yy hh:mm a"
+ itemValue="dd/M/yy hh:mm a" />
+ <f:selectItem itemLabel="d/MMM/y" itemValue="d/MMM/y" />
+ <f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy" />
+ </h:selectOneMenu>
+ </h:panelGrid>
+ </h:panelGrid>
+ </h:form>
+</h:body>
</html>
Copied: branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TracingSet.java (from rev 19860, trunk/examples/iteration-demo/src/main/java/org/richfaces/demo/TracingSet.java)
===================================================================
--- branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TracingSet.java (rev 0)
+++ branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TracingSet.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.demo;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import org.richfaces.log.LogFactory;
+import org.richfaces.log.Logger;
+
+import com.google.common.collect.ForwardingIterator;
+import com.google.common.collect.ForwardingSet;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class TracingSet<E> extends ForwardingSet<E> implements Serializable {
+
+ private static final long serialVersionUID = 267329344963751893L;
+
+ private static final Logger LOGGER = LogFactory.getLogger(TracingSet.class);
+
+ private class TracingIterator extends ForwardingIterator<E> {
+
+ private final Iterator<E> itr = backingCollection.iterator();
+
+ private E lastObject;
+
+ @Override
+ protected Iterator<E> delegate() {
+ return itr;
+ }
+
+ @Override
+ public E next() {
+ try {
+ lastObject = super.next();
+ return lastObject;
+ } catch (NoSuchElementException e) {
+ lastObject = null;
+ throw e;
+ }
+ }
+
+ @Override
+ public void remove() {
+ LOGGER.info("TracingSet.TracingIterator.remove() " + lastObject);
+ super.remove();
+ }
+ }
+
+ private Set<E> backingCollection = new HashSet<E>();
+
+ @Override
+ protected Set<E> delegate() {
+ return backingCollection;
+ }
+
+ @Override
+ public boolean removeAll(Collection<?> collection) {
+ LOGGER.info("TracingSet.removeAll() " + collection);
+ return super.removeAll(collection);
+ }
+
+ @Override
+ public boolean add(E element) {
+ LOGGER.info("TracingSet.add() " + element);
+ return super.add(element);
+ }
+
+ @Override
+ public boolean remove(Object object) {
+ LOGGER.info("TracingSet.remove() " + object);
+ return super.remove(object);
+ }
+
+ @Override
+ public boolean addAll(Collection<? extends E> collection) {
+ LOGGER.info("TracingSet.addAll() " + collection);
+ return super.addAll(collection);
+ }
+
+ @Override
+ public void clear() {
+ LOGGER.info("TracingSet.clear()");
+ super.clear();
+ }
+
+ @Override
+ public Iterator<E> iterator() {
+ return new TracingIterator();
+ }
+}
Modified: branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java
===================================================================
--- branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -56,7 +56,7 @@
private Object nodeData;
- private Collection<Object> selection;
+ private Collection<Object> selection = new TracingSet<Object>();
@PostConstruct
public void init() {
Modified: branches/RF-8742/examples/iteration-demo/src/main/webapp/tree.xhtml
===================================================================
--- branches/RF-8742/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-11-01 22:21:36 UTC (rev 19864)
@@ -24,7 +24,8 @@
</h:form>
<h:form id="form">
- <it:tree id="tree" nodeType="#{node.parent == null ? 'rootNode': 'childNode'}" var="node" value="#{treeBean.rootNodes}" selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}">
+ <it:tree id="tree" nodeType="#{node.parent == null ? 'rootNode': 'childNode'}" var="node" value="#{treeBean.rootNodes}"
+ selectionType="#{treeBean.selectionType}" toggleType="#{treeBean.toggleType}" selection="#{treeBean.selection}">
<it:treeNode type="rootNode">
<h:panelGroup id="rootNodeGroup">
Root node: #{node.data} -
Modified: branches/RF-8742/examples/pom.xml
===================================================================
--- branches/RF-8742/examples/pom.xml 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/examples/pom.xml 2010-11-01 22:21:36 UTC (rev 19864)
@@ -45,7 +45,7 @@
<module>output-demo</module>
<module>input-demo</module>
<module>repeater-demo</module>
- <!--module>iteration-demo</module-->
+ <module>iteration-demo</module>
<module>richfaces-showcase</module>
<!--<module>dist</module>-->
</modules>
Modified: branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
--- branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -572,7 +572,7 @@
public void buildAddLocaleScript(ResponseWriter writer, FacesContext facesContext, UIComponent component) throws IOException {
if(component instanceof AbstractCalendar) {
AbstractCalendar calendar = (AbstractCalendar)component;
- JSFunction function = new JSFunction("RichFaces.ui.Calendar.addLocale", CalendarHelper.getAsLocale(facesContext, calendar), getLocaleOptions(facesContext, calendar));
+ JSFunction function = new JSFunction("RichFaces.ui.Calendar.addLocale", CalendarHelper.getAsLocale(facesContext, calendar).toString(), getLocaleOptions(facesContext, calendar));
writer.write(function.toScript());
writer.write(";");
}
@@ -582,7 +582,7 @@
if(component instanceof AbstractCalendar) {
AbstractCalendar calendar = (AbstractCalendar)component;
ScriptOptions scriptOptions = createCalendarScriptOption(facesContext, calendar);
- JSFunction function = new JSFunction("new RichFaces.ui.Calendar", calendar.getClientId(facesContext), CalendarHelper.getAsLocale(facesContext, calendar), scriptOptions, "");
+ JSFunction function = new JSFunction("new RichFaces.ui.Calendar", calendar.getClientId(facesContext), CalendarHelper.getAsLocale(facesContext, calendar).toString(), scriptOptions, "");
StringBuffer scriptBuffer = new StringBuffer();
scriptBuffer.append(function.toScript()).append(".load();");
writer.write(scriptBuffer.toString());
Modified: branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.ecss
===================================================================
--- branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.ecss 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.ecss 2010-11-01 22:21:36 UTC (rev 19864)
@@ -243,7 +243,6 @@
.rf-ca-edtr-shdw {
background: '#{richSkin.tableBackgroundColor}';
opacity: 0.5;
- filter: alpha(opacity=50);
}
.rf-ca-time-layout {
@@ -328,18 +327,20 @@
margin: 0px 2px;
}
-.rf-ca-sp-up {
- background-image: "url(#{resource['org.richfaces.renderkit.html.images.StandardButtonBgImage']})";
+.rf-ca-sp-up, .rf-ca-sp-down {
+ background-repeat: no-repeat;
+ background-position: 50% 40%;
height: 7px;
width: 14px;
- margin: 0px 1px 1px 0px;
+ margin: 0px 1px 1px 0px;
}
+.rf-ca-sp-up {
+ background-image: "url(#{resource['org.richfaces.renderkit.html.images.SpinnerArrowTop']})";
+}
+
.rf-ca-sp-down {
- background-image: "url(#{resource['org.richfaces.renderkit.html.images.StandardButtonPressedBgImage']})";
- height: 7px;
- width: 14px;
- margin: 0px 1px 1px 0px;
+ background-image: "url(#{resource['org.richfaces.renderkit.html.images.SpinnerArrowBottom']})";
}
.rf-ca-sp-press {
@@ -356,7 +357,6 @@
background-color: '#{richSkin.shadowBackgroundColor}';
position: absolute;
opacity: 0.3;
- filter: alpha(opacity=30);
}
.rf-ca-edtr-btn {
Modified: branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java
===================================================================
--- branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/event/TreeSelectionEvent.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -22,7 +22,6 @@
package org.richfaces.event;
import java.util.Collection;
-import java.util.HashSet;
import javax.faces.component.UIComponent;
import javax.faces.event.FacesEvent;
@@ -36,15 +35,15 @@
private static final long serialVersionUID = 6292604445872458007L;
- private Collection<Object> addedKeys = new HashSet<Object>();
+ private Collection<Object> oldSelection;
- private Collection<Object> removedKeys = new HashSet<Object>();
+ private Collection<Object> newSelection;
- public TreeSelectionEvent(UIComponent component, Collection<Object> addedKeys, Collection<Object> removedKeys) {
+ public TreeSelectionEvent(UIComponent component, Collection<Object> oldSelection, Collection<Object> newSelection) {
super(component);
-
- this.addedKeys = addedKeys;
- this.removedKeys = removedKeys;
+
+ this.oldSelection = oldSelection;
+ this.newSelection = newSelection;
}
@Override
@@ -57,11 +56,12 @@
((TreeSelectionListener) listener).processSelection(this);
}
- public Collection<Object> getAddedKeys() {
- return addedKeys;
+ public Collection<Object> getOldSelection() {
+ return oldSelection;
}
- public Collection<Object> getRemovedKeys() {
- return removedKeys;
+ public Collection<Object> getNewSelection() {
+ return newSelection;
}
+
}
Copied: branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java (from rev 19860, trunk/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java)
===================================================================
--- branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java (rev 0)
+++ branches/RF-8742/ui/iteration/api/src/main/java/org/richfaces/model/TreeDataModel.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.model;
+
+import java.util.Iterator;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+//TODO - add necessary methods for tree adaptors support
+public interface TreeDataModel<E> {
+
+ public Object getRowKey();
+
+ public void setRowKey(Object rowKey);
+
+ public boolean isDataAvailable();
+
+ public E getData();
+
+ public Iterator<Object> getChildrenRowKeysIterator(Object rowKey);
+
+ public Object getParentRowKey(Object rowKey);
+
+ public Object getWrappedData();
+
+ public void setWrappedData(Object data);
+
+}
Modified: branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -43,6 +43,7 @@
import javax.faces.event.ExceptionQueuedEventContext;
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
+import javax.swing.tree.TreeNode;
import org.ajax4jsf.model.DataComponentState;
import org.ajax4jsf.model.ExtendedDataModel;
@@ -62,10 +63,13 @@
import org.richfaces.event.TreeSelectionListener;
import org.richfaces.event.TreeToggleEvent;
import org.richfaces.event.TreeToggleListener;
-import org.richfaces.model.TreeDataModelImpl;
+import org.richfaces.model.ExtendedTreeDataModelImpl;
+import org.richfaces.model.SwingTreeNodeDataModelImpl;
+import org.richfaces.model.TreeDataModel;
import org.richfaces.renderkit.MetaComponentRenderer;
import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
/**
@@ -209,12 +213,9 @@
getStateHelper().put(PropertyKeys.expanded, this.getClientId(getFacesContext()), newValue);
}
- /* (non-Javadoc)
- * @see org.richfaces.component.UIDataAdaptor#createExtendedDataModel()
- */
@Override
protected ExtendedDataModel<?> createExtendedDataModel() {
- TreeDataModelImpl model = new TreeDataModelImpl();
+ ExtendedTreeDataModelImpl<?> model = new ExtendedTreeDataModelImpl<TreeNode>(new SwingTreeNodeDataModelImpl());
model.setWrappedData(getValue());
return model;
}
@@ -234,8 +235,9 @@
return converter;
}
- public Iterator<Object> getChildrenIterator(FacesContext faces, Object rowKey) {
- return ((TreeDataModelImpl) getExtendedDataModel()).getChildrenIterator(faces, rowKey);
+ public Iterator<Object> getChildrenRowKeysIterator(FacesContext faces, Object rowKey) {
+ TreeDataModel<?> dataModel = (TreeDataModel<?>) getExtendedDataModel();
+ return dataModel.getChildrenRowKeysIterator(rowKey);
}
public AbstractTreeNode getTreeNodeComponent() {
@@ -313,14 +315,18 @@
} else if (event instanceof TreeSelectionEvent) {
TreeSelectionEvent selectionEvent = (TreeSelectionEvent) event;
- Collection<Object> selection = getSelection();
+ final Collection<Object> newSelection = selectionEvent.getNewSelection();
+
+ Collection<Object> selectionCollection = getSelection();
- for (Object addedKey: selectionEvent.getAddedKeys()) {
- selection.add(addedKey);
- }
+ Iterables.removeIf(selectionCollection, new Predicate<Object>() {
+ public boolean apply(Object input) {
+ return !newSelection.contains(input);
+ };
+ });
- for (Object removedKey: selectionEvent.getRemovedKeys()) {
- selection.remove(removedKey);
+ if (!newSelection.isEmpty()) {
+ Iterables.addAll(selectionCollection, newSelection);
}
}
}
Copied: branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java (from rev 19860, trunk/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java)
===================================================================
--- branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java (rev 0)
+++ branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/ExtendedTreeDataModelImpl.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -0,0 +1,131 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.model;
+
+import java.util.Iterator;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitResult;
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.richfaces.component.TreeRange;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ExtendedTreeDataModelImpl<E> extends ExtendedDataModel<E> implements TreeDataModel<E> {
+
+ private TreeDataModel<E> wrappedModel;
+
+ public ExtendedTreeDataModelImpl(TreeDataModel<E> wrappedModel) {
+ super();
+ this.wrappedModel = wrappedModel;
+ }
+
+ public boolean isDataAvailable() {
+ return wrappedModel.isDataAvailable();
+ }
+
+ public E getData() {
+ return wrappedModel.getData();
+ }
+
+ public Iterator<Object> getChildrenRowKeysIterator(Object rowKey) {
+ return wrappedModel.getChildrenRowKeysIterator(rowKey);
+ }
+
+ public Object getParentRowKey(Object rowKey) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setRowKey(Object key) {
+ wrappedModel.setRowKey(key);
+ }
+
+ @Override
+ public Object getRowKey() {
+ return wrappedModel.getRowKey();
+ }
+
+ protected void walk(FacesContext context, DataVisitor visitor, Range range, Object argument, Iterator<Object> keysIterator) {
+ while (keysIterator.hasNext()) {
+ Object object = (Object) keysIterator.next();
+
+ DataVisitResult visitResult = visitor.process(context, object, argument);
+ if (visitResult == DataVisitResult.CONTINUE) {
+ if (((TreeRange) range).shouldIterateChildren(object)) {
+ Iterator<Object> childrenIterator = getChildrenRowKeysIterator(object);
+ walk(context, visitor, range, argument, childrenIterator);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {
+ TreeRange treeRange = (TreeRange) range;
+ if (treeRange.shouldIterateChildren(null)) {
+ Iterator<Object> iterator = getChildrenRowKeysIterator(null);
+ walk(context, visitor, range, argument, iterator);
+ }
+ }
+
+ @Override
+ public boolean isRowAvailable() {
+ return wrappedModel.isDataAvailable();
+ }
+
+ @Override
+ public int getRowCount() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public E getRowData() {
+ return wrappedModel.getData();
+ }
+
+ @Override
+ public int getRowIndex() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setRowIndex(int rowIndex) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Object getWrappedData() {
+ return wrappedModel.getWrappedData();
+ }
+
+ @Override
+ public void setWrappedData(Object data) {
+ wrappedModel.setWrappedData(data);
+ }
+
+
+}
Modified: branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java
===================================================================
--- branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SequenceRowKey.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -74,4 +74,9 @@
}
return true;
}
+
+ @Override
+ public String toString() {
+ return getClass().getName() + Arrays.toString(simpleKeys);
+ }
}
Copied: branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java (from rev 19860, trunk/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java)
===================================================================
--- branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java (rev 0)
+++ branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/SwingTreeNodeDataModelImpl.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -0,0 +1,179 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.model;
+
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import javax.swing.tree.TreeNode;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Iterators;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class SwingTreeNodeDataModelImpl implements TreeDataModel<TreeNode> {
+
+ /**
+ * @author Nick Belaevski
+ *
+ */
+ private final class FakeRootNode implements TreeNode {
+ public boolean isLeaf() {
+ return !wrappedData.isEmpty();
+ }
+
+ public TreeNode getParent() {
+ return null;
+ }
+
+ public int getIndex(TreeNode node) {
+ if (wrappedData == null) {
+ return -1;
+ }
+
+ return Iterables.indexOf(wrappedData, Predicates.equalTo(node));
+ }
+
+ public int getChildCount() {
+ if (wrappedData == null) {
+ return 0;
+ }
+
+ return wrappedData.size();
+ }
+
+ public TreeNode getChildAt(int childIndex) {
+ if (wrappedData == null) {
+ throw new NoSuchElementException(String.valueOf(childIndex));
+ }
+
+ return Iterables.get(wrappedData, childIndex);
+ }
+
+ public boolean getAllowsChildren() {
+ return true;
+ }
+
+ public Enumeration<?> children() {
+ if (wrappedData == null) {
+ return Iterators.asEnumeration(Iterators.emptyIterator());
+ }
+
+ return Iterators.asEnumeration(wrappedData.iterator());
+ }
+ }
+
+ private static final SequenceRowKey<Integer> EMPTY_SEQUENCE_ROW_KEY = new SequenceRowKey<Integer>();
+
+ private Collection<TreeNode> wrappedData = null;
+
+ private TreeNode fakeRootNode = new FakeRootNode();
+
+ private TreeNode selectedNode;
+
+ private SequenceRowKey<Integer> selectedRowKey;
+
+ private Iterator<TreeNode> findChildren(SequenceRowKey<Integer> compositeKey) {
+ TreeNode treeNode = findNode(compositeKey);
+
+ if (treeNode == null) {
+ return Iterators.emptyIterator();
+ }
+
+ return Iterators.forEnumeration((Enumeration<TreeNode>) treeNode.children());
+ }
+
+ private TreeNode findNode(SequenceRowKey<Integer> compositeKey) {
+ if (compositeKey == null) {
+ return null;
+ }
+
+ TreeNode result = fakeRootNode;
+
+ for (Integer simpleKey : compositeKey.getSimpleKeys()) {
+ int idx = simpleKey.intValue();
+
+ if (idx < result.getChildCount()) {
+ result = result.getChildAt(idx);
+ } else {
+ result = null;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ public void setRowKey(Object key) {
+ this.selectedRowKey = (SequenceRowKey<Integer>) key;
+ this.selectedNode = findNode(selectedRowKey);
+ }
+
+ public Object getRowKey() {
+ return selectedRowKey;
+ }
+
+ private SequenceRowKey<Integer> castKeyAndWrapNull(Object rowKey) {
+ if (rowKey == null) {
+ return EMPTY_SEQUENCE_ROW_KEY;
+ }
+
+ return (SequenceRowKey<Integer>) rowKey;
+ }
+
+ public Iterator<Object> getChildrenRowKeysIterator(Object rowKey) {
+ SequenceRowKey<Integer> sequenceKey = castKeyAndWrapNull(rowKey);
+ Iterator<TreeNode> itr = findChildren(sequenceKey);
+
+ return new SequenceRowKeyIterator<TreeNode>(sequenceKey, itr);
+ }
+
+ public TreeNode getData() {
+ if (!isDataAvailable()) {
+ throw new IllegalArgumentException();
+ }
+
+ return selectedNode;
+ }
+
+ public Object getParentRowKey(Object rowKey) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isDataAvailable() {
+ return selectedNode != null;
+ }
+
+ public Object getWrappedData() {
+ return wrappedData;
+ }
+
+ public void setWrappedData(Object wrappedData) {
+ this.wrappedData = (Collection<TreeNode>) wrappedData;
+ }
+}
Deleted: branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java
===================================================================
--- branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/model/TreeDataModelImpl.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -1,184 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.model;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.faces.context.FacesContext;
-import javax.swing.tree.TreeNode;
-
-import org.ajax4jsf.model.DataVisitResult;
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.richfaces.component.TreeRange;
-
-import com.google.common.collect.Iterators;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class TreeDataModelImpl extends ExtendedDataModel<TreeNode> {
-
- private static final SequenceRowKey<Integer> EMPTY_SEQUENCE_ROW_KEY = new SequenceRowKey<Integer>();
-
- private SwingTreeNodeImpl<?> rootNode;
-
- private TreeNode selectedNode;
-
- private SequenceRowKey<Integer> selectedRowKey;
-
- private Iterator<TreeNode> findChildren(SequenceRowKey<Integer> compositeKey) {
- TreeNode treeNode = findNode(compositeKey);
-
- if (treeNode == null) {
- return Iterators.emptyIterator();
- }
-
- return Iterators.forEnumeration((Enumeration<TreeNode>) treeNode.children());
- }
-
- private TreeNode findNode(SequenceRowKey<Integer> compositeKey) {
- if (compositeKey == null) {
- return null;
- }
-
- TreeNode result = rootNode;
-
- for (Integer simpleKey : compositeKey.getSimpleKeys()) {
- int idx = simpleKey.intValue();
-
- if (idx < result.getChildCount()) {
- result = result.getChildAt(idx);
- } else {
- result = null;
- break;
- }
- }
-
- return result;
- }
-
- @Override
- public void setRowKey(Object key) {
- this.selectedRowKey = (SequenceRowKey<Integer>) key;
- this.selectedNode = findNode(selectedRowKey);
- }
-
- @Override
- public Object getRowKey() {
- return selectedRowKey;
- }
-
- @Override
- public boolean isRowAvailable() {
- return selectedNode != null;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowCount()
- */
- @Override
- public int getRowCount() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public TreeNode getRowData() {
- return selectedNode;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowIndex()
- */
- @Override
- public int getRowIndex() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- @Override
- public void setRowIndex(int rowIndex) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public Object getWrappedData() {
- return rootNode.getChildrenList();
- }
-
- @Override
- public void setWrappedData(Object data) {
- this.rootNode = new SwingTreeNodeImpl((List<TreeNode>) data);
- }
-
- private SequenceRowKey<Integer> castKeyAndWrapNull(Object rowKey) {
- if (rowKey == null) {
- return EMPTY_SEQUENCE_ROW_KEY;
- }
-
- return (SequenceRowKey<Integer>) rowKey;
- }
-
- public Iterator<Object> getChildrenIterator(FacesContext faces, Object rowKey) {
- SequenceRowKey<Integer> sequenceKey = castKeyAndWrapNull(rowKey);
- Iterator<TreeNode> itr = findChildren(sequenceKey);
-
- return new SequenceRowKeyIterator<TreeNode>(sequenceKey, itr);
- }
-
- protected void walk(FacesContext context, DataVisitor visitor, Range range, Object argument, Iterator<Object> keysIterator) {
- while (keysIterator.hasNext()) {
- Object object = (Object) keysIterator.next();
-
- DataVisitResult visitResult = visitor.process(context, object, argument);
- if (visitResult == DataVisitResult.CONTINUE) {
- if (((TreeRange) range).shouldIterateChildren(object)) {
- Iterator<Object> childrenIterator = getChildrenIterator(context, object);
- walk(context, visitor, range, argument, childrenIterator);
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)
- */
- @Override
- public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {
- // TODO Auto-generated method stub
-
- if (((TreeRange) range).shouldIterateChildren(null)) {
- Iterator<Object> iterator = getChildrenIterator(context, null);
- walk(context, visitor, range, argument, iterator);
- }
- }
-
-}
Modified: branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
===================================================================
--- branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -104,7 +104,7 @@
boolean iterateChildren = treeRange.shouldIterateChildren(rowKey);
if (iterateChildren) {
- encodeTree(tree.getChildrenIterator(context, rowKey));
+ encodeTree(tree.getChildrenRowKeysIterator(context, rowKey));
}
QueuedData data = queuedData.removeLast();
Modified: branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java
===================================================================
--- branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderFull.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -38,7 +38,7 @@
public void encode() throws java.io.IOException {
Object initialRowKey = tree.getRowKey();
try {
- encodeTree(tree.getChildrenIterator(context, null));
+ encodeTree(tree.getChildrenRowKeysIterator(context, null));
} finally {
try {
tree.setRowKey(context, initialRowKey);
Modified: branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -29,10 +29,9 @@
import java.io.IOException;
import java.util.Collection;
-import java.util.HashSet;
+import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
import javax.faces.component.UIComponent;
import javax.faces.component.UINamingContainer;
@@ -54,6 +53,7 @@
import org.richfaces.log.RichfacesLogger;
import com.google.common.base.Strings;
+import com.google.common.collect.Sets;
/**
@@ -304,18 +304,20 @@
Collection<Object> selection = tree.getSelection();
- Set<Object> addedKeys = new HashSet<Object>(2);
- Set<Object> removedKeys = new HashSet<Object>(2);
-
+ Collection<Object> newSelection = null;
+
if (selectionRowKey == null) {
- removedKeys.addAll(selection);
- } else if (!selection.contains(selectionRowKey)) {
- addedKeys.add(selectionRowKey);
- removedKeys.addAll(selection);
+ if (!selection.isEmpty()) {
+ newSelection = Collections.emptySet();
+ }
+ } else {
+ if (!selection.contains(selectionRowKey)) {
+ newSelection = Collections.singleton(selectionRowKey);
+ }
}
-
- if (!removedKeys.isEmpty() || !addedKeys.isEmpty()) {
- new TreeSelectionEvent(component, addedKeys, removedKeys).queue();
+
+ if (newSelection != null) {
+ new TreeSelectionEvent(component, Sets.newHashSet(selection), newSelection).queue();
}
PartialViewContext pvc = context.getPartialViewContext();
Copied: branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/BaseTreeImage.java (from rev 19860, trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/BaseTreeImage.java)
===================================================================
--- branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/BaseTreeImage.java (rev 0)
+++ branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/BaseTreeImage.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Dimension;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.CacheableResource;
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.resource.ImageType;
+import org.richfaces.resource.Java2DUserResource;
+import org.richfaces.resource.StateHolderResource;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public abstract class BaseTreeImage implements Java2DUserResource, StateHolderResource, CacheableResource {
+
+ private Dimension dimension;
+
+ protected BaseTreeImage(Dimension dimension) {
+ super();
+ this.dimension = dimension;
+ }
+ public boolean isCacheable(FacesContext context) {
+ return true;
+ }
+ public Date getExpires(FacesContext context) {
+ return null;
+ }
+
+ public int getTimeToLive(FacesContext context) {
+ return -1;
+ }
+
+ public String getEntityTag(FacesContext context) {
+ return null;
+ }
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ public Map<String, String> getResponseHeaders() {
+ return null;
+ }
+
+ public Date getLastModified() {
+ return null;
+ }
+
+ public ImageType getImageType() {
+ return ImageType.PNG;
+ }
+
+ public Dimension getDimension() {
+ return dimension;
+ }
+
+}
Copied: branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineImage.java (from rev 19860, trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineImage.java)
===================================================================
--- branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineImage.java (rev 0)
+++ branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineImage.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.resource.PostConstructResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public class TreeLineImage extends BaseTreeImage {
+
+ private static final Dimension DIMENSION = new Dimension(16, 16);
+
+ protected Integer trimColorValue;
+
+ public TreeLineImage() {
+ super(DIMENSION);
+ }
+
+ protected TreeLineImage(Dimension dimension) {
+ super(dimension);
+ }
+
+ @PostConstructResource
+ public void init() {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+
+ trimColorValue = skin.getColorParameter(context, Skin.TRIM_COLOR);
+ }
+
+ public void paint(Graphics2D g2d, Dimension dimension) {
+ g2d.setColor(new Color(trimColorValue));
+
+ g2d.drawLine(7, 0, 7, 15);
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws IOException {
+ dataOutput.writeInt(trimColorValue);
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException {
+ trimColorValue = dataInput.readInt();
+ }
+
+
+
+}
Copied: branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineLastImage.java (from rev 19860, trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineLastImage.java)
===================================================================
--- branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineLastImage.java (rev 0)
+++ branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeLineLastImage.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+
+import org.richfaces.resource.DynamicResource;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public class TreeLineLastImage extends TreeLineImage {
+
+ private static final Dimension DIMENSION = new Dimension(16, 200);
+
+ public TreeLineLastImage() {
+ super(DIMENSION);
+ }
+
+ public void paint(Graphics2D g2d, Dimension dimension) {
+ g2d.setColor(new Color(trimColorValue));
+
+ g2d.drawLine(7, 0, 7, 99);
+ g2d.drawLine(7, 99, 15, 99);
+ }
+
+}
Copied: branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeMinusImage.java (from rev 19860, trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeMinusImage.java)
===================================================================
--- branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeMinusImage.java (rev 0)
+++ branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreeMinusImage.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+
+import org.richfaces.resource.DynamicResource;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public class TreeMinusImage extends TreePlusImage {
+
+ public void paint(Graphics2D g2d, Dimension dimension) {
+ drawFrame(g2d);
+ drawHorizontalCrossLine(g2d);
+ }
+
+}
Copied: branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreePlusImage.java (from rev 19860, trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreePlusImage.java)
===================================================================
--- branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreePlusImage.java (rev 0)
+++ branches/RF-8742/ui/iteration/ui/src/main/java/org/richfaces/renderkit/html/images/TreePlusImage.java 2010-11-01 22:21:36 UTC (rev 19864)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.geom.Rectangle2D;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.resource.PostConstructResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@DynamicResource
+public class TreePlusImage extends BaseTreeImage {
+
+ private static final Dimension DIMENSION = new Dimension(16, 16);
+
+ protected Integer generalColorValue;
+
+ protected Integer controlColorValue;
+
+ protected Integer trimColorValue;
+
+ public TreePlusImage() {
+ super(DIMENSION);
+ }
+
+ @PostConstructResource
+ public void init() {
+ FacesContext context = FacesContext.getCurrentInstance();
+
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+
+ generalColorValue = skin.getColorParameter(context, Skin.GENERAL_TEXT_COLOR);
+ controlColorValue = skin.getColorParameter(context, Skin.CONTROL_BACKGROUND_COLOR);
+ trimColorValue = skin.getColorParameter(context, Skin.TRIM_COLOR);
+ }
+
+ protected void drawFrame(Graphics2D g2d) {
+ Color trimColor = new Color(trimColorValue);
+ Color controlColor = new Color(controlColorValue);
+
+ g2d.setColor(trimColor);
+ g2d.drawRect(3, 3, 8, 8);
+
+ Rectangle2D rect = new Rectangle2D.Float(4, 4, 7, 7);
+ GradientPaint gragient = new GradientPaint(4, 4, controlColor, 13, 13, trimColor);
+ g2d.setPaint(gragient);
+ g2d.fill(rect);
+ }
+
+ public void paint(Graphics2D g2d, Dimension dimension) {
+ drawFrame(g2d);
+
+ drawHorizontalCrossLine(g2d);
+ drawVerticalCrossLine(g2d);
+ }
+
+ protected void drawVerticalCrossLine(Graphics2D g2d) {
+ g2d.setColor(new Color(generalColorValue));
+ //vertical cross line
+ g2d.drawLine(7, 5, 7, 9);
+ }
+
+ protected void drawHorizontalCrossLine(Graphics2D g2d) {
+ g2d.setColor(new Color(generalColorValue));
+ //horizontal cross line
+ g2d.drawLine(5, 7, 9, 7);
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws IOException {
+ dataOutput.writeInt(generalColorValue);
+ dataOutput.writeInt(controlColorValue);
+ dataOutput.writeInt(trimColorValue);
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException {
+ generalColorValue = dataInput.readInt();
+ controlColorValue = dataInput.readInt();
+ trimColorValue = dataInput.readInt();
+ }
+
+}
Deleted: branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/last.gif
===================================================================
(Binary files differ)
Deleted: branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/line.gif
===================================================================
(Binary files differ)
Deleted: branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/minus.gif
===================================================================
(Binary files differ)
Deleted: branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/plus.gif
===================================================================
(Binary files differ)
Modified: branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss
===================================================================
--- branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-11-01 22:21:36 UTC (rev 19864)
@@ -1,5 +1,5 @@
.rf-trn {
- background: "url(#{resource['org.richfaces.images:last.gif']}) no-repeat center left";
+ background: "url(#{resource['org.richfaces.images:last.png']}) no-repeat center left";
cursor: default;
font-size: '#{richSkin.generalSizeFont}';
font-family: '#{richSkin.generalFamilyFont}';
@@ -26,7 +26,7 @@
}
.rf-tr-nd {
- background: "url(#{resource['org.richfaces.images:line.gif']}) repeat-y";
+ background: "url(#{resource['org.richfaces.images:line.png']}) repeat-y";
}
.rf-tr-nd-last {
@@ -51,11 +51,11 @@
}
.rf-trn-hnd-colps {
- background: "url(#{resource['org.richfaces.images:plus.gif']}) no-repeat center";
+ background: "url(#{resource['org.richfaces.images:plus.png']}) no-repeat center";
}
.rf-trn-hnd-exp {
- background: "url(#{resource['org.richfaces.images:minus.gif']}) no-repeat center";
+ background: "url(#{resource['org.richfaces.images:minus.png']}) no-repeat center";
}
.rf-trn-ico-nd {
Modified: branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties
===================================================================
--- branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties 2010-11-01 21:31:19 UTC (rev 19863)
+++ branches/RF-8742/ui/iteration/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties 2010-11-01 22:21:36 UTC (rev 19864)
@@ -6,9 +6,9 @@
{baseColorParam=additionalBackgroundColor, gradientColorParam=tableBackgroundColor}
org.richfaces.images\:colHdrGrad.png=org.richfaces.renderkit.html.BaseGradient\
{baseColorParam=tableSubHeaderBackgroundColor, gradientColorParam=tableHeaderBackgroundColor}
-org.richfaces.images\:last.gif=org.richfaces\:last.gif
-org.richfaces.images\:line.gif=org.richfaces\:line.gif
-org.richfaces.images\:plus.gif=org.richfaces\:plus.gif
-org.richfaces.images\:minus.gif=org.richfaces\:minus.gif
+org.richfaces.images\:last.png=org.richfaces.renderkit.html.images.TreeLineLastImage
+org.richfaces.images\:line.png=org.richfaces.renderkit.html.images.TreeLineImage
+org.richfaces.images\:plus.png=org.richfaces.renderkit.html.images.TreePlusImage
+org.richfaces.images\:minus.png=org.richfaces.renderkit.html.images.TreeMinusImage
org.richfaces.images\:node_icon.gif=org.richfaces\:node_icon.gif
org.richfaces.images\:leaf_icon.gif=org.richfaces\:leaf_icon.gif
\ No newline at end of file
15 years
JBoss Rich Faces SVN: r19863 - in branches/RF-8742/ui/validator/ui/src: main/java/org/richfaces/renderkit/html and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-11-01 17:31:19 -0400 (Mon, 01 Nov 2010)
New Revision: 19863
Added:
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/AjaxValidationTest.java
branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/WEB-INF/
branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/WEB-INF/faces-config.xml
branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/test.xhtml
Removed:
branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/faces-config.xml
Modified:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java
branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/faces-config.xml
branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/UIViewResourceTest.java
Log:
RESOLVED - issue RF-9593: CSV - create tests and implementation for AJAX transport.
https://jira.jboss.org/browse/RF-9593
Modified: branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java 2010-11-01 19:50:05 UTC (rev 19862)
+++ branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/UIValidatorScript.java 2010-11-01 21:31:19 UTC (rev 19863)
@@ -131,7 +131,7 @@
}
}
- public static final String COMPONENT_TYPE = "org.richfaces.ValidatroScript";
+ public static final String COMPONENT_TYPE = "org.richfaces.ValidatorScript";
public static final String COMPONENT_FAMILY = "org.richfaces.Script";
Modified: branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-11-01 19:50:05 UTC (rev 19862)
+++ branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-11-01 21:31:19 UTC (rev 19863)
@@ -235,10 +235,13 @@
private String createAjaxScript(ClientBehaviorContext behaviorContext, ClientValidatorBehavior behavior) {
String ajaxScript = behavior.getAjaxScript(behaviorContext);
- ajaxScript=ajaxScript.replace("this", "element");
+ ajaxScript=ajaxScript.replace("this", ValidatorScriptBase.ELEMENT);
String clientId = getComponentClientId(behaviorContext);
ajaxScript = replaceTextToVariable(ajaxScript, clientId, ValidatorScriptBase.CLIENT_ID);
- ajaxScript = replaceTextToVariable(ajaxScript, behaviorContext.getSourceId(), ValidatorScriptBase.SOURCE_ID);
+ String sourceId = behaviorContext.getSourceId();
+ if(null != sourceId){
+ ajaxScript = replaceTextToVariable(ajaxScript, sourceId, ValidatorScriptBase.ELEMENT);
+ }
return ajaxScript;
}
Modified: branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java 2010-11-01 19:50:05 UTC (rev 19862)
+++ branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java 2010-11-01 21:31:19 UTC (rev 19863)
@@ -6,6 +6,7 @@
public abstract class ValidatorScriptBase extends JSFunctionDefinition implements ComponentValidatorScript {
+ protected static final String ELEMENT = "element";
protected static final String EVENT = "event";
protected static final JSLiteral EVENT_LITERAL = new JSLiteral(EVENT);
protected static final JSLiteral THIS = new JSLiteral("this");
@@ -25,7 +26,7 @@
private boolean bodyProcessed = false;
public ValidatorScriptBase() {
- super(CLIENT_ID,SOURCE_ID,"element",EVENT,DISABLE_AJAX);
+ super(CLIENT_ID,ELEMENT,EVENT,DISABLE_AJAX);
}
public void appendScript(StringBuffer functionString) {
@@ -40,7 +41,7 @@
protected abstract Object buildBody();
public String createCallScript(String clientId,String sourceId) {
- JSFunction callFunction = new JSFunction(getName(),clientId,sourceId,THIS,EVENT_LITERAL);
+ JSFunction callFunction = new JSFunction(getName(),clientId,null!=sourceId?sourceId:THIS,EVENT_LITERAL);
return callFunction.toScript();
}
Modified: branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/faces-config.xml
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/faces-config.xml 2010-11-01 19:50:05 UTC (rev 19862)
+++ branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/faces-config.xml 2010-11-01 21:31:19 UTC (rev 19863)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0" metadata-complete="false" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<component>
- <component-type>org.richfaces.ValidatroScript</component-type>
+ <component-type>org.richfaces.ValidatorScript</component-type>
<component-class>org.richfaces.component.UIValidatorScript</component-class>
</component>
<behavior>
Added: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/AjaxValidationTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/AjaxValidationTest.java (rev 0)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/AjaxValidationTest.java 2010-11-01 21:31:19 UTC (rev 19863)
@@ -0,0 +1,90 @@
+package org.richfaces.component;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+import static org.junit.matchers.JUnitMatchers.*;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import org.hamcrest.Matcher;
+import org.jboss.test.faces.htmlunit.HtmlUnitEnvironment;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlInput;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+
+/**
+ * Test for dynamic add/remove {@link UIValidatorScript} as view resource.
+ * @author asmirnov
+ *
+ */
+public class AjaxValidationTest {
+
+ private HtmlUnitEnvironment environment;
+
+
+ @Before
+ public void setUp() {
+ this.environment = new HtmlUnitEnvironment();
+ this.environment.withWebRoot("org/richfaces/component/test.xhtml").start();
+ }
+
+ @After
+ public void thearDown() throws Exception{
+ environment.release();
+ environment = null;
+ }
+
+ @Test
+ public void testRequest() throws Exception {
+ HtmlPage page = requestPage();
+ HtmlInput input = hetInput(page);
+ assertNotNull(input);
+
+ }
+
+ @Test
+ public void testSubmitTooShortValue() throws Exception {
+ submitValueAndCheckMesage("",containsString("Error"));
+ }
+
+ @Test
+ public void testSubmitTooLongValue() throws Exception {
+ submitValueAndCheckMesage("123456",containsString("Error"));
+ }
+
+ @Test
+ public void testSubmitProperValue() throws Exception {
+ submitValueAndCheckMesage("ab",equalTo(""));
+ }
+
+ private void submitValueAndCheckMesage(String value, Matcher<String> matcher) throws Exception {
+ HtmlPage page = requestPage();
+ HtmlInput input = hetInput(page);
+ input.setValueAttribute(value);
+ input.fireEvent("keyup");
+ HtmlElement message = page.getElementById("form:message");
+ assertThat(message.getTextContent(), matcher);
+// System.out.println(page.asXml());
+ }
+ private HtmlInput hetInput(HtmlPage page) {
+ HtmlForm htmlForm = page.getFormByName("form");
+ assertNotNull(htmlForm);
+ HtmlInput input = htmlForm.getInputByName("form:text");
+ return input;
+ }
+
+ private HtmlPage requestPage() throws MalformedURLException, IOException {
+ HtmlPage page = environment.getPage("/test.jsf");
+// System.out.println(page.asXml());
+ return page;
+ }
+
+
+}
Property changes on: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/AjaxValidationTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/UIViewResourceTest.java
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/UIViewResourceTest.java 2010-11-01 19:50:05 UTC (rev 19862)
+++ branches/RF-8742/ui/validator/ui/src/test/java/org/richfaces/component/UIViewResourceTest.java 2010-11-01 21:31:19 UTC (rev 19863)
@@ -34,7 +34,7 @@
" <h:commandButton id=\"command\" value=\"Ok\" action=\"#{test.action}\"/>\n" +
"</h:form>\n" +
"</html>").
- withResource(FacesEnvironment.FACES_CONFIG_XML, "org/richfaces/component/faces-config.xml").
+ withResource(FacesEnvironment.FACES_CONFIG_XML, "org/richfaces/component/WEB-INF/faces-config.xml").
start();
}
Copied: branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/WEB-INF/faces-config.xml (from rev 19848, branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/faces-config.xml)
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/WEB-INF/faces-config.xml (rev 0)
+++ branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/WEB-INF/faces-config.xml 2010-11-01 21:31:19 UTC (rev 19863)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config version="2.0" metadata-complete="false" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<managed-bean>
+ <managed-bean-name>test</managed-bean-name>
+ <managed-bean-class>org.richfaces.component.TestBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+</managed-bean>
+</faces-config>
\ No newline at end of file
Property changes on: branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/WEB-INF/faces-config.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Deleted: branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/faces-config.xml
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/faces-config.xml 2010-11-01 19:50:05 UTC (rev 19862)
+++ branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/faces-config.xml 2010-11-01 21:31:19 UTC (rev 19863)
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<faces-config version="2.0" metadata-complete="false" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-<managed-bean>
- <managed-bean-name>test</managed-bean-name>
- <managed-bean-class>org.richfaces.component.TestBean</managed-bean-class>
- <managed-bean-scope>request</managed-bean-scope>
-</managed-bean>
-</faces-config>
\ No newline at end of file
Added: branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/test.xhtml
===================================================================
--- branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/test.xhtml (rev 0)
+++ branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/test.xhtml 2010-11-01 21:31:19 UTC (rev 19863)
@@ -0,0 +1,17 @@
+<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:csv="http://richfaces.org/csv">
+ <h:head><title>Ajax validator</title></h:head>
+ <h:body>
+ <h:form id="form">
+ <h:inputText id="text" value="#{test.value}">
+ <f:validateLength minimum="1" maximum="3"/>
+ <csv:validator event="keyup" />
+ </h:inputText>
+ <h:outputText id="out" value="#{test.value}"></h:outputText>
+ <h:message id="message" for="text" />
+ <h:commandLink id="submit">Submit</h:commandLink>
+ </h:form>
+ </h:body>
+</html>
Property changes on: branches/RF-8742/ui/validator/ui/src/test/resources/org/richfaces/component/test.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years