JBoss Rich Faces SVN: r1419 - in branches/refactor1: framework/api/src/main/java/org/ajax4jsf/framework/resource and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-06-29 14:13:40 -0400 (Fri, 29 Jun 2007)
New Revision: 1419
Added:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceComponent.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java
Removed:
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/resource/ResourceComponent.java
branches/refactor1/ui/core/src/main/java/org/ajax4jsf/framework/resource/UserResource.java
Modified:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java
branches/refactor1/framework/impl/pom.xml
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java
Log:
continue refactoring.
Modified: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java 2007-06-29 17:35:11 UTC (rev 1418)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java 2007-06-29 18:13:40 UTC (rev 1419)
@@ -111,4 +111,13 @@
public abstract Map getResponseDataMap();
+ public abstract void setAjaxRequest(boolean b);
+
+ public abstract boolean isSelfRender();
+
+ public abstract void setSelfRender(boolean b);
+
+ public abstract String getSubmittedRegionClientId(FacesContext context);
+
+ public abstract void saveViewState(FacesContext context) throws IOException;
}
\ No newline at end of file
Copied: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceComponent.java (from rev 1396, branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/resource/ResourceComponent.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceComponent.java (rev 0)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ResourceComponent.java 2007-06-29 18:13:40 UTC (rev 1419)
@@ -0,0 +1,121 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax.resource;
+
+import java.util.Date;
+
+import javax.faces.el.MethodBinding;
+
+/**
+ * @author shura (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:13 $
+ *
+ */
+public interface ResourceComponent {
+
+ /**
+ * Get Mime-type for target .
+ * @return
+ */
+ public abstract String getMimeType();
+
+ /**
+ * Set Mime-type for target .
+ * @param newvalue
+ */
+ public abstract void setMimeType(String newvalue);
+
+
+ /**
+ * Get Last modified date for target .
+ * @return
+ */
+ public abstract Date getLastModified();
+
+ /**
+ * Set Last modified for target .
+ * @param newvalue
+ */
+ public abstract void setLastModified(Date newvalue);
+
+
+ /**
+ * Get Expiration time for target .
+ * @return
+ */
+ public abstract Date getExpires();
+
+ /**
+ * Set Expiration time for target .
+ * @param newvalue
+ */
+ public abstract void setExpires(Date newvalue);
+
+
+ /**
+ * Get caching flag for resource.
+ * @return
+ */
+ public abstract boolean isCacheable();
+
+ /**
+ * Set caching flag for resource.
+ * @param newvalue
+ */
+ public abstract void setCacheable(boolean newvalue);
+
+ /**
+ * Get session-avare flag for resource.
+ * @return true if resource depend of client session. If false, no JSESSIONID encoded in URI
+ */
+ public abstract boolean isSession();
+
+ /**
+ * Set session-avare flag for resource.
+ * @param newvalue
+ */
+ public abstract void setSession(boolean newvalue);
+
+ /**
+ * Get Data object, encoded in uri and passed to "send" method for generate resource content.
+ * @return
+ */
+ public abstract Object getValue();
+
+ /**
+ * Set Data object, encoded in uri and passed to "send" method for generate resource content.
+ * @param newvalue
+ */
+ public abstract void setValue(Object newvalue);
+
+ /**
+ * Get El binding to method in user bean to send resource. Method will called with two parameters - restored data object and servlet output stream.
+ * @return
+ */
+ public abstract MethodBinding getCreateContent();
+
+ /**
+ * Set El binding to method in user bean to send resource. Method will called with two parameters - restored data object and servlet output stream.
+ * @param newvalue
+ */
+ public abstract void setCreateContent(MethodBinding newvalue);
+}
Modified: branches/refactor1/framework/impl/pom.xml
===================================================================
--- branches/refactor1/framework/impl/pom.xml 2007-06-29 17:35:11 UTC (rev 1418)
+++ branches/refactor1/framework/impl/pom.xml 2007-06-29 18:13:40 UTC (rev 1419)
@@ -1,299 +1,292 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <artifactId>framework</artifactId>
- <groupId>org.richfaces</groupId>
- <version>3.1.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces.framework</groupId>
- <artifactId>impl</artifactId>
- <name>Java Server Faces AJAX framework implementation</name>
- <properties>
- <jsfVersion>1.1</jsfVersion>
- </properties>
- <build>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- </resource>
- <resource>
- <directory>target/javascript</directory>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <phase>generate-resources</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <ant antfile="${basedir}/generatescript.xml" inheritRefs="true">
- <target name="assembly" />
- <property name="target-dir" value="${project.build.directory}/javascript">
- </property>
- </ant>
- </tasks>
- <resourceRoot>
- ${project.build.directory}/javascript
- </resourceRoot>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-source</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <!-- temporary solution, until maven-antlr-plugin will not become mature -->
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <configuration>
- <tasks>
- <java classname="org.antlr.Tool"
- classpathref="maven.plugin.classpath"
- fork="true"
- dir="src/main/antlr">
- <arg value="RichMacroDefinition.g"/>
- <arg line="-o ${project.build.directory}/generated-sources/antlr/org/richfaces"/>
- </java>
- </tasks>
- <sourceRoot>${project.build.directory}/generated-sources/antlr</sourceRoot>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>antlr</artifactId>
- <version>3.0</version>
- <scope>compile</scope>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>opensymphony</groupId>
- <artifactId>oscache</artifactId>
- <version>2.3</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>com.sun.facelets</groupId>
- <artifactId>jsf-facelets</artifactId>
- <version>1.1.11</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- <version>1.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>nekohtml</groupId>
- <artifactId>nekohtml</artifactId>
- <version>0.9.5</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.0.4</version>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.14</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>commons-beanutils</groupId>
- <artifactId>commons-beanutils</artifactId>
- <version>1.7.0</version>
- </dependency>
- <dependency>
- <groupId>commons-digester</groupId>
- <artifactId>commons-digester</artifactId>
- <version>1.8</version>
- </dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2</version>
- </dependency>
- <dependency>
- <groupId>org.richfaces.framework</groupId>
- <artifactId>api</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <profiles>
- <profile>
- <id>jsf1_1</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- <property>
- <name>jsfVersion</name>
- <value>1.1</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.4</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jsp-api</artifactId>
- <version>2.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-api</artifactId>
- <version>1.1_02</version>
- <exclusions>
- <!-- No longer presented in any repo -->
- <exclusion>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.servlet.jsp.jstl</groupId>
- <artifactId>jstl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-impl</artifactId>
- <version>1.1_02</version>
- <scope>runtime</scope>
- <exclusions>
- <!-- No longer presented in any repo -->
- <exclusion>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.servlet.jsp.jstl</groupId>
- <artifactId>jstl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jstl</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
- </profile>
- <profile>
- <id>jsf1_2</id>
- <activation>
- <property>
- <name>jsfVersion</name>
- <value>1.2</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <!-- append JSF 1.2 related sources -->
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>
- build-helper-maven-plugin
- </artifactId>
- <executions>
- <execution>
- <id>add-source</id>
- <phase>process-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>src/main/jsf12</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- <version>2.1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-api</artifactId>
- <version>1.2_03</version>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-impl</artifactId>
- <version>1.2_03</version>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
-</project>
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>framework</artifactId>
+ <groupId>org.richfaces</groupId>
+ <version>3.1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.framework</groupId>
+ <artifactId>impl</artifactId>
+ <name>Java Server Faces AJAX framework implementation</name>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <directory>target/javascript</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <ant>
+ <target />
+ <property />
+ </ant>
+ </tasks>
+ <resourceRoot>${project.build.directory}/javascript</resourceRoot>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-source</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <java>
+ <arg />
+ <arg />
+ </java>
+ </tasks>
+ <sourceRoot>${project.build.directory}/generated-sources/antlr</sourceRoot>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr</artifactId>
+ <version>3.0</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ <profiles>
+ <profile>
+ <id>jsf1_1</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ <property>
+ <name>jsfVersion</name>
+ <value>1.1</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>1.1_02</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>jsp-api</artifactId>
+ <groupId>javax.servlet.jsp</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jstl</artifactId>
+ <groupId>javax.servlet.jsp.jstl</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>1.1_02</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <artifactId>jsp-api</artifactId>
+ <groupId>javax.servlet.jsp</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jstl</artifactId>
+ <groupId>javax.servlet.jsp.jstl</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ <profile>
+ <id>jsf1_2</id>
+ <activation>
+ <property>
+ <name>jsfVersion</name>
+ <value>1.2</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>src/main/jsf12</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>2.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>1.2_03</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>1.2_03</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>opensymphony</groupId>
+ <artifactId>oscache</artifactId>
+ <version>2.3</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.facelets</groupId>
+ <artifactId>jsf-facelets</artifactId>
+ <version>1.1.11</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>nekohtml</groupId>
+ <artifactId>nekohtml</artifactId>
+ <version>0.9.5</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-digester</groupId>
+ <artifactId>commons-digester</artifactId>
+ <version>1.8</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.framework</groupId>
+ <artifactId>api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr</artifactId>
+ <version>3.0</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <jsfVersion>1.1</jsfVersion>
+ </properties>
+</project>
+
Copied: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java (from rev 1396, branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java)
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java (rev 0)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java 2007-06-29 18:13:40 UTC (rev 1419)
@@ -0,0 +1,127 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.ajax;
+
+import java.io.IOException;
+import java.util.Locale;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author shura
+ *
+ */
+public abstract class UILoadBundle extends UIComponentBase {
+
+ public static final String COMPONENT_FAMILY = "org.ajax4jsf.Bundle";
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.ajax.Bundle";
+
+ private static final Log _log = LogFactory.getLog(UILoadBundle.class);
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return COMPONENT_FAMILY;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
+ */
+ public void encodeBegin(FacesContext context) throws IOException {
+ loadBundle(context);
+
+ }
+
+ public void decode(FacesContext context) {
+ loadBundle(context);
+ }
+ /**
+ * @param context
+ */
+ public void loadBundle(FacesContext context) {
+ UIViewRoot viewRoot = context.getViewRoot();
+ Locale locale = viewRoot.getLocale();
+ if (locale == null) {
+ locale = context.getApplication().getDefaultLocale();
+ }
+
+ ResourceBundle bundle;
+ try {
+ bundle = ResourceBundle.getBundle(getBasename(), locale, Thread
+ .currentThread().getContextClassLoader());
+ } catch (MissingResourceException e) {
+ _log.error(Messages.getMessage(Messages.COULD_NOT_LOAD_RESOURCE_BUNDLE, getBasename()));
+ return;
+ }
+
+ context.getExternalContext().getRequestMap().put(getVar(),
+ new ResourceBundleMap(bundle));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#getRendererType()
+ */
+ public String getRendererType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * @return Returns the basename.
+ */
+ public abstract String getBasename();
+
+ /**
+ * @param basename
+ * The basename to set.
+ */
+ public abstract void setBasename(String basename);
+
+ /**
+ * @return Returns the var.
+ */
+ public abstract String getVar();
+
+ /**
+ * @param var
+ * The var to set.
+ */
+ public abstract void setVar(String var);
+
+}
Modified: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java 2007-06-29 17:35:11 UTC (rev 1418)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java 2007-06-29 18:13:40 UTC (rev 1419)
@@ -268,7 +268,7 @@
if (context == null)
throw new NullPointerException("context");
singleComponent = null;
- AjaxContext.invokeOnRegionOrRoot(this, context, _decodeInvoker);
+ AjaxContextImpl.invokeOnRegionOrRoot(this, context, _decodeInvoker);
try {
broadcastEvents(context, PhaseId.APPLY_REQUEST_VALUES);
} catch (AjaxSingleException e) {
@@ -297,7 +297,7 @@
if (context == null)
throw new NullPointerException("context");
if (null == singleComponent) {
- AjaxContext.invokeOnRegionOrRoot(this, context, _updatesInvoker);
+ AjaxContextImpl.invokeOnRegionOrRoot(this, context, _updatesInvoker);
} else {
singleComponent.processUpdates(context);
}
@@ -325,7 +325,7 @@
if (context == null)
throw new NullPointerException("context");
if (null == singleComponent) {
- AjaxContext.invokeOnRegionOrRoot(this, context, _validatorsInvoker);
+ AjaxContextImpl.invokeOnRegionOrRoot(this, context, _validatorsInvoker);
} else {
singleComponent.processValidators(context);
}
@@ -393,7 +393,7 @@
if (!isHavePage()
&& AjaxContext.getCurrentInstance(context).isAjaxRequest(
context)) {
- AjaxContext.invokeOnRegionOrRoot(this, context, _ajaxInvoker);
+ AjaxContextImpl.invokeOnRegionOrRoot(this, context, _ajaxInvoker);
} else {
super.encodeChildren(context);
}
Modified: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java 2007-06-29 17:35:11 UTC (rev 1418)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java 2007-06-29 18:13:40 UTC (rev 1419)
@@ -30,6 +30,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import org.ajax4jsf.ajax.UILoadBundle;
import org.ajax4jsf.framework.ajax.AjaxChildrenEncoder;
import org.ajax4jsf.framework.ajax.AjaxOutput;
import org.ajax4jsf.framework.util.message.Messages;
Modified: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java 2007-06-29 17:35:11 UTC (rev 1418)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java 2007-06-29 18:13:40 UTC (rev 1419)
@@ -43,6 +43,7 @@
import javax.faces.context.ResponseWriter;
import javax.servlet.http.HttpServletResponse;
+import org.ajax4jsf.ajax.UILoadBundle;
import org.ajax4jsf.framework.ajax.AjaxComponent;
import org.ajax4jsf.framework.ajax.AjaxContainer;
import org.ajax4jsf.framework.ajax.AjaxContext;
Copied: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java (from rev 1396, branches/refactor1/ui/core/src/main/java/org/ajax4jsf/framework/resource/UserResource.java)
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java (rev 0)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/UserResource.java 2007-06-29 18:13:40 UTC (rev 1419)
@@ -0,0 +1,135 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.resource;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.util.Date;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
+
+/**
+ * @author shura
+ *
+ */
+public class UserResource extends InternetResourceBase {
+
+ private String contentType;
+ /**
+ *
+ */
+ public UserResource(boolean cacheable, boolean session, String mime) {
+ super();
+ setCacheable(cacheable);
+ setSessionAware(session);
+ setContentType(mime);
+ }
+ /**
+ * @return Returns the contentType.
+ */
+ public String getContentType(ResourceContext resourceContext) {
+ return contentType;
+ }
+ /**
+ * @param contentType The contentType to set.
+ */
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.InternetResourceBase#getDataToStore(javax.faces.context.FacesContext, java.lang.Object)
+ */
+ public Object getDataToStore(FacesContext context, Object data) {
+ UriData dataToStore = null;
+ if (data instanceof ResourceComponent) {
+ ResourceComponent resource = (ResourceComponent) data;
+ dataToStore = new UriData();
+ dataToStore.value = resource.getValue();
+ dataToStore.createContent = UIComponentBase.saveAttachedState(context,resource.getCreateContent());
+ if (data instanceof UIComponent) {
+ UIComponent component = (UIComponent) data;
+ ValueBinding expires = component.getValueBinding("expires");
+ if (null != expires) {
+ dataToStore.expires = UIComponentBase.saveAttachedState(context,expires);
+ }
+ ValueBinding lastModified = component.getValueBinding("lastModified");
+ if (null != lastModified) {
+ dataToStore.modified = UIComponentBase.saveAttachedState(context,lastModified);
+ }
+ }
+ }
+ return dataToStore;
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.InternetResourceBase#send(org.ajax4jsf.framework.resource.ResourceContext)
+ */
+ public void send(ResourceContext context) throws IOException {
+ UriData data = (UriData) restoreData(context);
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (null != data && null != facesContext ) {
+ // Send headers
+ if(data.expires != null){
+ ValueBinding binding = (ValueBinding) UIComponentBase.restoreAttachedState(facesContext,data.expires);
+ Date expires = (Date) binding.getValue(facesContext);
+ context.setDateHeader("Expires",expires.getTime());
+ }
+ if(data.modified != null){
+ ValueBinding binding = (ValueBinding) UIComponentBase.restoreAttachedState(facesContext,data.modified);
+ Date modified = (Date) binding.getValue(facesContext);
+ context.setDateHeader("Last-Modified",modified.getTime());
+ }
+ // Send content
+ OutputStream out = context.getOutputStream();
+ MethodBinding send = (MethodBinding) UIComponentBase.restoreAttachedState(facesContext,data.createContent);
+ send.invoke(facesContext,new Object[]{out,data.value});
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.InternetResourceBase#requireFacesContext()
+ */
+ public boolean requireFacesContext() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+ public static class UriData implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1258987L;
+
+ private Object value;
+
+ private Object createContent;
+
+ private Object expires;
+
+ private Object modified;
+ }
+
+}
Deleted: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java 2007-06-29 17:35:11 UTC (rev 1418)
+++ branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/UILoadBundle.java 2007-06-29 18:13:40 UTC (rev 1419)
@@ -1,127 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax;
-
-import java.io.IOException;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import javax.faces.component.UIComponentBase;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author shura
- *
- */
-public abstract class UILoadBundle extends UIComponentBase {
-
- public static final String COMPONENT_FAMILY = "org.ajax4jsf.Bundle";
-
- public static final String COMPONENT_TYPE = "org.ajax4jsf.ajax.Bundle";
-
- private static final Log _log = LogFactory.getLog(UILoadBundle.class);
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIComponent#getFamily()
- */
- public String getFamily() {
- // TODO Auto-generated method stub
- return COMPONENT_FAMILY;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
- */
- public void encodeBegin(FacesContext context) throws IOException {
- loadBundle(context);
-
- }
-
- public void decode(FacesContext context) {
- loadBundle(context);
- }
- /**
- * @param context
- */
- public void loadBundle(FacesContext context) {
- UIViewRoot viewRoot = context.getViewRoot();
- Locale locale = viewRoot.getLocale();
- if (locale == null) {
- locale = context.getApplication().getDefaultLocale();
- }
-
- ResourceBundle bundle;
- try {
- bundle = ResourceBundle.getBundle(getBasename(), locale, Thread
- .currentThread().getContextClassLoader());
- } catch (MissingResourceException e) {
- _log.error(Messages.getMessage(Messages.COULD_NOT_LOAD_RESOURCE_BUNDLE, getBasename()));
- return;
- }
-
- context.getExternalContext().getRequestMap().put(getVar(),
- new ResourceBundleMap(bundle));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIComponentBase#getRendererType()
- */
- public String getRendererType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /**
- * @return Returns the basename.
- */
- public abstract String getBasename();
-
- /**
- * @param basename
- * The basename to set.
- */
- public abstract void setBasename(String basename);
-
- /**
- * @return Returns the var.
- */
- public abstract String getVar();
-
- /**
- * @param var
- * The var to set.
- */
- public abstract void setVar(String var);
-
-}
Deleted: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/resource/ResourceComponent.java
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/resource/ResourceComponent.java 2007-06-29 17:35:11 UTC (rev 1418)
+++ branches/refactor1/ui/core/src/main/java/org/ajax4jsf/ajax/resource/ResourceComponent.java 2007-06-29 18:13:40 UTC (rev 1419)
@@ -1,121 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.ajax.resource;
-
-import java.util.Date;
-
-import javax.faces.el.MethodBinding;
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:13 $
- *
- */
-public interface ResourceComponent {
-
- /**
- * Get Mime-type for target .
- * @return
- */
- public abstract String getMimeType();
-
- /**
- * Set Mime-type for target .
- * @param newvalue
- */
- public abstract void setMimeType(String newvalue);
-
-
- /**
- * Get Last modified date for target .
- * @return
- */
- public abstract Date getLastModified();
-
- /**
- * Set Last modified for target .
- * @param newvalue
- */
- public abstract void setLastModified(Date newvalue);
-
-
- /**
- * Get Expiration time for target .
- * @return
- */
- public abstract Date getExpires();
-
- /**
- * Set Expiration time for target .
- * @param newvalue
- */
- public abstract void setExpires(Date newvalue);
-
-
- /**
- * Get caching flag for resource.
- * @return
- */
- public abstract boolean isCacheable();
-
- /**
- * Set caching flag for resource.
- * @param newvalue
- */
- public abstract void setCacheable(boolean newvalue);
-
- /**
- * Get session-avare flag for resource.
- * @return true if resource depend of client session. If false, no JSESSIONID encoded in URI
- */
- public abstract boolean isSession();
-
- /**
- * Set session-avare flag for resource.
- * @param newvalue
- */
- public abstract void setSession(boolean newvalue);
-
- /**
- * Get Data object, encoded in uri and passed to "send" method for generate resource content.
- * @return
- */
- public abstract Object getValue();
-
- /**
- * Set Data object, encoded in uri and passed to "send" method for generate resource content.
- * @param newvalue
- */
- public abstract void setValue(Object newvalue);
-
- /**
- * Get El binding to method in user bean to send resource. Method will called with two parameters - restored data object and servlet output stream.
- * @return
- */
- public abstract MethodBinding getCreateContent();
-
- /**
- * Set El binding to method in user bean to send resource. Method will called with two parameters - restored data object and servlet output stream.
- * @param newvalue
- */
- public abstract void setCreateContent(MethodBinding newvalue);
-}
Deleted: branches/refactor1/ui/core/src/main/java/org/ajax4jsf/framework/resource/UserResource.java
===================================================================
--- branches/refactor1/ui/core/src/main/java/org/ajax4jsf/framework/resource/UserResource.java 2007-06-29 17:35:11 UTC (rev 1418)
+++ branches/refactor1/ui/core/src/main/java/org/ajax4jsf/framework/resource/UserResource.java 2007-06-29 18:13:40 UTC (rev 1419)
@@ -1,137 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.resource;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.ValueBinding;
-
-import org.ajax4jsf.ajax.resource.ResourceComponent;
-
-/**
- * @author shura
- *
- */
-public class UserResource extends InternetResourceBase {
-
- private String contentType;
- /**
- *
- */
- public UserResource(boolean cacheable, boolean session, String mime) {
- super();
- setCacheable(cacheable);
- setSessionAware(session);
- setContentType(mime);
- }
- /**
- * @return Returns the contentType.
- */
- public String getContentType(ResourceContext resourceContext) {
- return contentType;
- }
- /**
- * @param contentType The contentType to set.
- */
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.resource.InternetResourceBase#getDataToStore(javax.faces.context.FacesContext, java.lang.Object)
- */
- public Object getDataToStore(FacesContext context, Object data) {
- UriData dataToStore = null;
- if (data instanceof ResourceComponent) {
- ResourceComponent resource = (ResourceComponent) data;
- dataToStore = new UriData();
- dataToStore.value = resource.getValue();
- dataToStore.createContent = UIComponentBase.saveAttachedState(context,resource.getCreateContent());
- if (data instanceof UIComponent) {
- UIComponent component = (UIComponent) data;
- ValueBinding expires = component.getValueBinding("expires");
- if (null != expires) {
- dataToStore.expires = UIComponentBase.saveAttachedState(context,expires);
- }
- ValueBinding lastModified = component.getValueBinding("lastModified");
- if (null != lastModified) {
- dataToStore.modified = UIComponentBase.saveAttachedState(context,lastModified);
- }
- }
- }
- return dataToStore;
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.resource.InternetResourceBase#send(org.ajax4jsf.framework.resource.ResourceContext)
- */
- public void send(ResourceContext context) throws IOException {
- UriData data = (UriData) restoreData(context);
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if (null != data && null != facesContext ) {
- // Send headers
- if(data.expires != null){
- ValueBinding binding = (ValueBinding) UIComponentBase.restoreAttachedState(facesContext,data.expires);
- Date expires = (Date) binding.getValue(facesContext);
- context.setDateHeader("Expires",expires.getTime());
- }
- if(data.modified != null){
- ValueBinding binding = (ValueBinding) UIComponentBase.restoreAttachedState(facesContext,data.modified);
- Date modified = (Date) binding.getValue(facesContext);
- context.setDateHeader("Last-Modified",modified.getTime());
- }
- // Send content
- OutputStream out = context.getOutputStream();
- MethodBinding send = (MethodBinding) UIComponentBase.restoreAttachedState(facesContext,data.createContent);
- send.invoke(facesContext,new Object[]{out,data.value});
- }
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.resource.InternetResourceBase#requireFacesContext()
- */
- public boolean requireFacesContext() {
- // TODO Auto-generated method stub
- return true;
- }
-
- public static class UriData implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 1258987L;
-
- private Object value;
-
- private Object createContent;
-
- private Object expires;
-
- private Object modified;
- }
-
-}
17 years, 2 months
JBoss Rich Faces SVN: r1418 - in branches/refactor1/framework/impl/src/main/java/org: ajax4jsf/framework/ajax/xmlfilter and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-06-29 13:35:11 -0400 (Fri, 29 Jun 2007)
New Revision: 1418
Removed:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/JSONDataSerializer.java
Modified:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxInputComponent.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxRegionBrige.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewHandler.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AJAXDataSerializer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxContainerRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxViewRootRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/CachedResourceBuilder.java
branches/refactor1/framework/impl/src/main/java/org/richfaces/json/JSContentHandler.java
branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java
Log:
continue refactoring. API project restored
Modified: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java 2007-06-29 17:33:47 UTC (rev 1417)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java 2007-06-29 17:35:11 UTC (rev 1418)
@@ -29,7 +29,6 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
-import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -62,7 +61,6 @@
import org.ajax4jsf.framework.skin.Skin;
import org.ajax4jsf.framework.skin.SkinFactory;
import org.ajax4jsf.framework.skin.SkinNotFoundException;
-import org.ajax4jsf.framework.util.config.WebXml;
import org.ajax4jsf.framework.util.message.Messages;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxInputComponent.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxInputComponent.java 2007-06-29 17:33:47 UTC (rev 1417)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxInputComponent.java 2007-06-29 17:35:11 UTC (rev 1418)
@@ -29,9 +29,7 @@
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-
/**
* Base class for all AJAX-enabled Input components
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
Modified: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxRegionBrige.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxRegionBrige.java 2007-06-29 17:33:47 UTC (rev 1417)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxRegionBrige.java 2007-06-29 17:35:11 UTC (rev 1418)
@@ -21,12 +21,6 @@
package org.ajax4jsf.framework.ajax;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.faces.FacesException;
import javax.faces.application.Application;
import javax.faces.component.StateHolder;
import javax.faces.component.UIComponent;
@@ -36,7 +30,6 @@
import javax.faces.el.ValueBinding;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
-import javax.faces.event.PhaseId;
import org.ajax4jsf.framework.util.message.Messages;
import org.apache.commons.logging.Log;
Modified: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewHandler.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewHandler.java 2007-06-29 17:33:47 UTC (rev 1417)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewHandler.java 2007-06-29 17:35:11 UTC (rev 1418)
@@ -26,7 +26,6 @@
import javax.faces.FacesException;
import javax.faces.application.ViewHandler;
-import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
Modified: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java 2007-06-29 17:33:47 UTC (rev 1417)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxViewRoot.java 2007-06-29 17:35:11 UTC (rev 1418)
@@ -24,7 +24,6 @@
import java.io.IOException;
import javax.faces.FacesException;
-import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
Modified: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java 2007-06-29 17:33:47 UTC (rev 1417)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/xmlfilter/BaseFilter.java 2007-06-29 17:35:11 UTC (rev 1418)
@@ -39,7 +39,6 @@
import javax.servlet.http.HttpSession;
import org.ajax4jsf.ajax.PushEventsCounter;
-import org.ajax4jsf.cache.Cache;
import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
import org.ajax4jsf.framework.resource.InternetResourceService;
import org.ajax4jsf.framework.util.message.Messages;
Modified: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AJAXDataSerializer.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AJAXDataSerializer.java 2007-06-29 17:33:47 UTC (rev 1417)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AJAXDataSerializer.java 2007-06-29 17:35:11 UTC (rev 1418)
@@ -21,8 +21,8 @@
package org.ajax4jsf.framework.renderer;
-import net.sf.json.JSONSerializer;
+
import org.ajax4jsf.framework.util.javascript.ScriptUtils;
/**
Modified: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java 2007-06-29 17:33:47 UTC (rev 1417)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java 2007-06-29 17:35:11 UTC (rev 1418)
@@ -30,7 +30,6 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import org.ajax4jsf.ajax.UILoadBundle;
import org.ajax4jsf.framework.ajax.AjaxChildrenEncoder;
import org.ajax4jsf.framework.ajax.AjaxOutput;
import org.ajax4jsf.framework.util.message.Messages;
Modified: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxContainerRenderer.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxContainerRenderer.java 2007-06-29 17:33:47 UTC (rev 1417)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxContainerRenderer.java 2007-06-29 17:35:11 UTC (rev 1418)
@@ -22,19 +22,16 @@
package org.ajax4jsf.framework.renderer;
import java.io.IOException;
-import java.util.Locale;
import java.util.Map;
import java.util.Set;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
import org.ajax4jsf.framework.ajax.AjaxContainer;
import org.ajax4jsf.framework.ajax.AjaxContext;
import org.ajax4jsf.framework.ajax.AjaxEvent;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.framework.util.message.Messages;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java 2007-06-29 17:33:47 UTC (rev 1417)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxRendererUtils.java 2007-06-29 17:35:11 UTC (rev 1418)
@@ -32,20 +32,17 @@
import java.util.Map;
import java.util.Set;
-import javax.faces.application.ViewHandler;
import javax.faces.component.ActionSource;
import javax.faces.component.EditableValueHolder;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
import javax.faces.component.UIForm;
import javax.faces.component.UIParameter;
-import javax.faces.component.UIViewRoot;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.servlet.http.HttpServletResponse;
-import org.ajax4jsf.ajax.UILoadBundle;
import org.ajax4jsf.framework.ajax.AjaxComponent;
import org.ajax4jsf.framework.ajax.AjaxContainer;
import org.ajax4jsf.framework.ajax.AjaxContext;
Modified: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxViewRootRenderer.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxViewRootRenderer.java 2007-06-29 17:33:47 UTC (rev 1417)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxViewRootRenderer.java 2007-06-29 17:35:11 UTC (rev 1418)
@@ -21,13 +21,6 @@
package org.ajax4jsf.framework.renderer;
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.framework.ajax.AjaxContext;
import org.ajax4jsf.framework.ajax.AjaxViewRoot;
import org.ajax4jsf.framework.resource.InternetResource;
Deleted: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/JSONDataSerializer.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/JSONDataSerializer.java 2007-06-29 17:33:47 UTC (rev 1417)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/JSONDataSerializer.java 2007-06-29 17:35:11 UTC (rev 1418)
@@ -1,45 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import net.sf.json.JSONSerializer;
-
-/**
- * @author shura
- *
- */
-public class JSONDataSerializer extends AJAXDataSerializer {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.renderer.AJAXDataSerializer#asString(java.lang.Object)
- */
- public String asString(Object data) {
- StringBuffer result = new StringBuffer();
- if(null != data){
- result.append("<![CDATA[ ");
- result.append(JSONSerializer.toJSON(data));
- result.append(" ]]>");
- }
- return result.toString();
- }
-
-}
Modified: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/CachedResourceBuilder.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/CachedResourceBuilder.java 2007-06-29 17:33:47 UTC (rev 1417)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/cached/CachedResourceBuilder.java 2007-06-29 17:35:11 UTC (rev 1418)
@@ -27,8 +27,6 @@
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
import org.ajax4jsf.framework.resource.InternetResource;
import org.ajax4jsf.framework.resource.ResourceBuilderImpl;
Modified: branches/refactor1/framework/impl/src/main/java/org/richfaces/json/JSContentHandler.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/richfaces/json/JSContentHandler.java 2007-06-29 17:33:47 UTC (rev 1417)
+++ branches/refactor1/framework/impl/src/main/java/org/richfaces/json/JSContentHandler.java 2007-06-29 17:35:11 UTC (rev 1418)
@@ -22,7 +22,6 @@
package org.richfaces.json;
import java.io.IOException;
-import java.io.StringWriter;
import java.io.Writer;
import java.util.Arrays;
Modified: branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java 2007-06-29 17:33:47 UTC (rev 1417)
+++ branches/refactor1/framework/impl/src/main/java/org/richfaces/renderkit/MacroDefinitionJSContentHandler.java 2007-06-29 17:35:11 UTC (rev 1418)
@@ -8,12 +8,6 @@
import java.util.Iterator;
import java.util.List;
-import org.antlr.runtime.ANTLRStringStream;
-import org.antlr.runtime.CommonTokenStream;
-import org.antlr.runtime.RecognitionException;
-import org.richfaces.RichMacroDefinitionLexer;
-import org.richfaces.RichMacroDefinitionParser;
-import org.richfaces.RichMacroDefinitionParser.expression_return;
import org.richfaces.json.JSContentHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
17 years, 2 months
JBoss Rich Faces SVN: r1417 - trunk/sandbox/panelmenu/design/funcspec.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2007-06-29 13:33:47 -0400 (Fri, 29 Jun 2007)
New Revision: 1417
Modified:
trunk/sandbox/panelmenu/design/funcspec/FuncSpec - RF Panel Menu Component.doc
Log:
Modified: trunk/sandbox/panelmenu/design/funcspec/FuncSpec - RF Panel Menu Component.doc
===================================================================
(Binary files differ)
17 years, 2 months
JBoss Rich Faces SVN: r1416 - in branches/refactor1: framework/api/src/main/java/org/ajax4jsf/framework/resource and 6 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-06-29 13:25:00 -0400 (Fri, 29 Jun 2007)
New Revision: 1416
Added:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/ViewIdHolder.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java
branches/refactor1/ui/tree/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java
Removed:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java
branches/refactor1/framework/api/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ViewIdHolder.java
Modified:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBuilder.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinFactory.java
Log:
continue refactoring
Added: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java (rev 0)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java 2007-06-29 17:25:00 UTC (rev 1416)
@@ -0,0 +1,114 @@
+package org.ajax4jsf.framework.ajax;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.VariableResolver;
+
+public abstract class AjaxContext {
+
+ /**
+ * Key for keep request state information in request-scope attributes.
+ */
+ public static final String AJAX_CONTEXT_KEY = "ajaxContext";
+
+ public abstract Map getCommonAjaxParameters();
+
+ public abstract String getAjaxActionURL(FacesContext context);
+
+ public abstract String getAjaxActionURL();
+
+ public abstract void setResponseData(Object responseData);
+
+ public abstract Object getResponseData();
+
+ public abstract void setViewIdHolder(ViewIdHolder viewIdHolder);
+
+ public abstract ViewIdHolder getViewIdHolder();
+
+ public abstract boolean removeRenderedArea(String id);
+
+ public abstract void addRenderedArea(String id);
+
+ public abstract Set getAjaxRenderedAreas();
+
+ public abstract void addComponentToAjaxRender(UIComponent base, String id);
+
+ public abstract void addComponentToAjaxRender(UIComponent component);
+
+ public abstract void addRegionsFromComponent(UIComponent component);
+
+ public abstract Set getAjaxAreasToRender();
+
+ public abstract boolean isAjaxRequest(FacesContext context);
+
+ public abstract boolean isAjaxRequest();
+
+ public abstract void processHeadResources(FacesContext context)
+ throws FacesException;
+
+ public abstract void encodeAjaxEnd(FacesContext context, UIComponent component)
+ throws IOException;
+
+ public abstract void encodeAjaxBegin(FacesContext context, UIComponent component)
+ throws IOException;
+
+ public abstract void renderAjaxRegion(FacesContext context, UIComponent component,
+ boolean useFilterWriter) throws FacesException;
+
+ public abstract void renderSubmittedAjaxRegion(FacesContext context, final boolean useFilterWriter);
+
+ public abstract void renderSubmittedAjaxRegion(FacesContext context);
+
+ public static final String SCRIPTS_PARAMETER = "org.ajax4jsf.framework.HEADER_SCRIPTS";
+ public static final String STYLES_PARAMETER = "org.ajax4jsf.framework.HEADER_STYLES";
+ public static final String RESPONSE_DATA_KEY = "_ajax:data";
+
+ /**
+ * Get instance of current AJAX Context. Instance get by
+ * {@link VariableResolver#resolveVariable(FacesContext, String)} for
+ * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
+ *
+ * @return memento instance for current request
+ */
+ public static AjaxContext getCurrentInstance() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ return getCurrentInstance(context);
+ }
+
+ /**
+ * Get instance of current AJAX Context. Instance get by
+ * {@link VariableResolver#resolveVariable(FacesContext, String)} for
+ * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
+ *
+ * @param context
+ * current FacesContext
+ * @return instance of AjaxContext.
+ */
+ public static AjaxContext getCurrentInstance(FacesContext context) {
+ if (null == context) {
+ throw new NullPointerException("FacesContext is null");
+ }
+ AjaxContext ajaxContext = (AjaxContext) context.getApplication()
+ .getVariableResolver().resolveVariable(context,
+ AJAX_CONTEXT_KEY);
+ if (null == ajaxContext) {
+ // TODO Create default implementation.
+// ajaxContext = new AjaxContext();
+// context.getExternalContext().getRequestMap().put(AJAX_CONTEXT_KEY,
+// ajaxContext);
+ }
+ return ajaxContext;
+ }
+
+ public AjaxContext() {
+ super();
+ }
+
+ public abstract Map getResponseDataMap();
+
+}
\ No newline at end of file
Deleted: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java 2007-06-29 17:10:57 UTC (rev 1415)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java 2007-06-29 17:25:00 UTC (rev 1416)
@@ -1,806 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.application.StateManager;
-import javax.faces.application.ViewHandler;
-import javax.faces.application.StateManager.SerializedView;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.el.VariableResolver;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-import javax.faces.render.Renderer;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
-import org.ajax4jsf.framework.ajax.xmlfilter.FilterServletResponseWrapper;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.HeaderResourceProducer;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-import org.ajax4jsf.framework.skin.Skin;
-import org.ajax4jsf.framework.skin.SkinFactory;
-import org.ajax4jsf.framework.skin.SkinNotFoundException;
-import org.ajax4jsf.framework.util.config.WebXml;
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * This class incapsulated
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.7 $ $Date: 2007/02/08 19:07:16 $
- *
- */
-public class AjaxContext {
- /**
- * Key for keep request state information in request-scope attributes.
- */
- public static final String AJAX_CONTEXT_KEY = "ajaxContext";
-
- public static final String SCRIPTS_PARAMETER = "org.ajax4jsf.framework.HEADER_SCRIPTS";
-
- public static final String STYLES_PARAMETER = "org.ajax4jsf.framework.HEADER_STYLES";
-
- public static final String RESOURCES_PROCESSED = "org.ajax4jsf.framework.HEADER_PROCESSED";
-
- public static final String RESPONSE_DATA_KEY = "_ajax:data";
-
- private static final Log log = LogFactory.getLog(AjaxContext.class);
-
- private static ComponentInvoker invoker;
-
- private static Map contextClasses = new HashMap();
-
- Set ajaxAreasToRender = new HashSet();
-
- Set ajaxRenderedAreas = new HashSet();
-
- boolean ajaxRequest = false;
-
- boolean ajaxRequestSet = false;
-
- boolean selfRender = false;
-
- Integer viewSequence = new Integer(1);
-
- String submittedRegionClientId = null;
-
- boolean submittedRegionSet = false;
-
- ViewIdHolder viewIdHolder = null;
-
- Map responseDataMap = new HashMap();
-
- Map commonAjaxParameters = new HashMap();
-
- static {
- try {
- // Attempt to create JSF1.2 specific invoker.
- invoker = new JsfOneOneInvoker();
- } catch (Exception e) {
- invoker = new JsfOneOneInvoker();
- }
- }
-
- /**
- * Get instance of current AJAX Context. Instance get by
- * {@link VariableResolver#resolveVariable(FacesContext, String)} for
- * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
- *
- * @return memento instance for current request
- */
- public static AjaxContext getCurrentInstance() {
- FacesContext context = FacesContext.getCurrentInstance();
- return getCurrentInstance(context);
- }
-
- /**
- * Get instance of current AJAX Context. Instance get by
- * {@link VariableResolver#resolveVariable(FacesContext, String)} for
- * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
- *
- * @param context
- * current FacesContext
- * @return instance of AjaxContext.
- */
- public static AjaxContext getCurrentInstance(FacesContext context) {
- if (null == context) {
- throw new NullPointerException("FacesContext is null");
- }
- AjaxContext ajaxContext = (AjaxContext) context.getApplication()
- .getVariableResolver().resolveVariable(context,
- AJAX_CONTEXT_KEY);
- if (null == ajaxContext) {
- // Create default implementation.
- ajaxContext = new AjaxContext();
- context.getExternalContext().getRequestMap().put(AJAX_CONTEXT_KEY,
- ajaxContext);
- }
- return ajaxContext;
- }
-
- /**
- * @param root
- * @param context
- * @param callback
- * @param regionId
- * @return
- * @see org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnComponent(javax.faces.component.UIComponent,
- * javax.faces.context.FacesContext,
- * org.ajax4jsf.framework.ajax.InvokerCallback, java.lang.String)
- */
- public static boolean invokeOnComponent(UIComponent root,
- FacesContext context, InvokerCallback callback, String regionId) {
- return invoker.invokeOnComponent(root, context, callback, regionId);
- }
-
- /**
- * @param viewRoot
- * @param context
- * @param callback
- * @see org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnRegionOrRoot(org.ajax4jsf.framework.ajax.AjaxViewRoot,
- * javax.faces.context.FacesContext,
- * org.ajax4jsf.framework.ajax.InvokerCallback)
- */
- public static void invokeOnRegionOrRoot(AjaxViewRoot viewRoot,
- FacesContext context, InvokerCallback callback) {
- invoker.invokeOnRegionOrRoot(viewRoot, context, callback);
- }
-
- private InvokerCallback _ajaxInvoker = new InvokerCallback() {
-
- public void invoke(FacesContext context, UIComponent component) {
- if (component instanceof AjaxContainer) {
- AjaxContainer ajax = (AjaxContainer) component;
- renderAjaxRegion(context, component, true);
- } else {
- // Container not found, use Root for encode.
- renderAjaxRegion(context, context.getViewRoot(), true);
- }
- }
-
- public void invokeRoot(FacesContext context) {
- renderAjaxRegion(context, context.getViewRoot(), true);
- }
-
- };
-
- public void renderSubmittedAjaxRegion(FacesContext context) {
- renderSubmittedAjaxRegion(context, true);
- }
-
- public void renderSubmittedAjaxRegion(FacesContext context,
- final boolean useFilterWriter) {
- InvokerCallback ajaxInvoker = new InvokerCallback() {
-
- public void invoke(FacesContext context, UIComponent component) {
- if (component instanceof AjaxContainer) {
- renderAjaxRegion(context, component, useFilterWriter);
- } else {
- // Container not found, use Root for encode.
- renderAjaxRegion(context, context.getViewRoot(),
- useFilterWriter);
- }
- }
-
- public void invokeRoot(FacesContext context) {
- renderAjaxRegion(context, context.getViewRoot(),
- useFilterWriter);
- }
-
- };
- if (!invokeOnComponent(context.getViewRoot(), context, ajaxInvoker,
- getSubmittedRegionClientId(context))) {
- renderAjaxRegion(context, context.getViewRoot(), useFilterWriter);
- }
-
- }
-
- /**
- * @param context
- * @param useFilterWriter
- * TODO
- * @throws AbortProcessingException
- */
- public void renderAjaxRegion(FacesContext context, UIComponent component,
- boolean useFilterWriter) throws FacesException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.RENDER_AJAX_REQUEST,
- component.getId()));
- }
- try {
- setSelfRender(true);
- // create response writer.
- ExternalContext extContext = context.getExternalContext();
- RenderKit renderKit = context.getRenderKit();
- String encoding;
- // Depends if we talk about servlets, portlets, ...
- if (extContext.getRequest() instanceof ServletRequest) {
- ServletRequest request = (ServletRequest) extContext
- .getRequest();
- ServletResponse response = (ServletResponse) extContext
- .getResponse();
- // HACK - bypass MyFaces ( and other ) extensions filter.
-
- // Setup encoding and content type
- String contentType = "text/xml";
- // get the encoding - must be setup by faces context or filter.
- encoding = request.getCharacterEncoding();
- if (encoding == null) {
- encoding = "UTF-8";
- }
- response.setContentType(contentType + ";charset=" + encoding);
- } else
- encoding = "UTF-8";
-
- PrintWriter servletWriter;
- if (useFilterWriter
- && extContext.getRequestMap().containsKey(
- BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
- // HACK - Special case for MyFaces, since <f:view don't call
- // encode methods,
- // encode response as for self-rendered region directly to
- // filter response wrpper.
- // to avoid exceptions, inform wrapper to ignore illegal states
- // for getWriter/Stream.
- ServletResponse servletResponse = (ServletResponse) extContext
- .getRequestMap().get(
- BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE);
- servletResponse.resetBuffer();
- servletWriter = servletResponse.getWriter();
- ((FilterServletResponseWrapper) servletResponse)
- .setUseNullStream(true);
- } else {
- servletWriter = getWriter(extContext);
- }
- ResponseWriter writer = renderKit.createResponseWriter(
- servletWriter, null, encoding);
- context.setResponseWriter(writer);
- // make response
- writer.startDocument();
- encodeAjaxBegin(context, component);
- component.encodeBegin(context);
- ((AjaxContainer) component).encodeAjax(context);
- component.encodeEnd(context);
- saveViewState(context);
- encodeAjaxEnd(context, component);
- writer.endDocument();
- writer.flush();
- writer.close();
- servletWriter.close();
- // Save tree state.
- } catch (IOException e) {
- throw new FacesException(Messages.getMessage(
- Messages.RENDERING_AJAX_REGION_ERROR, component
- .getClientId(context)), e);
- } finally {
- context.responseComplete();
- // component.setRendererType(defaultRenderer);
- }
- }
-
- /**
- * Encode declaration for AJAX response. Render <html><body>
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeAjaxBegin(FacesContext context, UIComponent component)
- throws IOException {
- // AjaxContainer ajax = (AjaxContainer) component;
- ResponseWriter out = context.getResponseWriter();
- // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
- out.startElement(HTML.HTML_ELEMENT, component);
- // TODO - html attributes. lang - from current locale ?
- Locale locale = context.getViewRoot().getLocale();
- out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
- out.startElement(HTML.BODY_ELEMENT, component);
- }
-
- /**
- * End encoding of AJAX response. Render tag with included areas and
- * close </body></html>
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeAjaxEnd(FacesContext context, UIComponent component)
- throws IOException {
- // AjaxContainer ajax = (AjaxContainer) component;
- ResponseWriter out = context.getResponseWriter();
- // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
- out.endElement(HTML.BODY_ELEMENT);
- out.endElement(HTML.HTML_ELEMENT);
- }
-
- /**
- * @param context
- * @param root
- * @throws FacesException
- */
- public void processHeadResources(FacesContext context)
- throws FacesException {
- ExternalContext externalContext = context.getExternalContext();
- Map requestMap = externalContext.getRequestMap();
- if (!Boolean.TRUE.equals(requestMap.get(RESOURCES_PROCESSED))) {
- if (null != requestMap.get(BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
- if (log.isDebugEnabled()) {
- log
- .debug("Process component tree for collect used scripts and styles");
- }
- UIViewRoot root = context.getViewRoot();
- Set scripts = new LinkedHashSet();
- Set styles = new LinkedHashSet();
- RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
- .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- RenderKit renderKit = rkFactory.getRenderKit(context, context
- .getViewRoot().getRenderKitId());
- processHeadResources(context, root, scripts, styles, renderKit);
- if (scripts.size() > 0) {
- if (log.isDebugEnabled()) {
- StringBuffer buff = new StringBuffer(
- "Scripts for insert into head : \n");
- for (Iterator iter = scripts.iterator(); iter.hasNext();) {
- String script = (String) iter.next();
- buff.append(script).append("\n");
- }
- log.debug(buff.toString());
- }
- requestMap.put(SCRIPTS_PARAMETER, scripts);
- }
- // Set default style sheet for current skin.
- String styleSheetUri = null;
- try {
- styleSheetUri = (String) SkinFactory.getInstance().getSkin(
- context).getParameter(context,
- Skin.generalStyleSheet);
- } catch (SkinNotFoundException e) {
- log.warn("Current Skin is not found", e);
- }
- if (null != styleSheetUri) {
- String resourceURL = context.getApplication()
- .getViewHandler().getResourceURL(context,
- styleSheetUri);
- // TODO - some resources can be non-session aware, we
- // must
- // skip encoding for this case ?
- // But, in common case - static links not need session
- // info,
- // and dynamic resources perform encodings if nessesary
- // resourceURL =
- // context.getExternalContext().encodeResourceURL(resourceURL);
- styles.add(resourceURL);
- }
- if (styles.size() > 0) {
- if (log.isDebugEnabled()) {
- StringBuffer buff = new StringBuffer(
- "Styles for insert into head : \n");
- for (Iterator iter = styles.iterator(); iter.hasNext();) {
- String style = (String) iter.next();
- buff.append(style).append("\n");
- }
- log.debug(buff.toString());
- }
- requestMap.put(STYLES_PARAMETER, styles);
- }
- // Mark as processed.
- requestMap.put(RESOURCES_PROCESSED, Boolean.TRUE);
- }
-
- }
- }
-
- /**
- * Append nessesary scripts and styles from component ( if renderer
- * implements {@link HeaderResourceProducer}) and recursive process all
- * facets and childrens.
- *
- * @param context
- * TODO
- * @param root
- * @param scripts
- * @param styles
- * @param renderKit
- * TODO
- */
- private void processHeadResources(FacesContext context, UIComponent root,
- Set scripts, Set styles, RenderKit renderKit) {
- Renderer renderer = getRenderer(context, root, renderKit);
- if (null != renderer) {
- if (renderer instanceof HeaderResourceProducer) {
- HeaderResourceProducer producer = (HeaderResourceProducer) renderer;
- Set set = producer.getHeaderScripts(context, root);
- if (null != set) {
- scripts.addAll(set);
- }
- set = producer.getHeaderStyles(context, root);
- if (null != set) {
- styles.addAll(set);
- }
- }
- }
- for (Iterator iter = root.getFacets().values().iterator(); iter
- .hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- processHeadResources(context, child, scripts, styles, renderKit);
- }
- for (Iterator iter = root.getChildren().iterator(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- processHeadResources(context, child, scripts, styles, renderKit);
- }
- }
-
- /**
- * Find renderer for given component.
- *
- * @param context
- * @param comp
- * @param renderKit
- * @return
- */
- private Renderer getRenderer(FacesContext context, UIComponent comp,
- RenderKit renderKit) {
-
- String rendererType = comp.getRendererType();
- if (rendererType != null) {
- return (renderKit.getRenderer(comp.getFamily(), rendererType));
- } else {
- return (null);
- }
-
- }
-
- public void saveViewState(FacesContext context) throws IOException {
- // TODO - for facelets environment, we need to remove transient
- // components.
- try {
- Application.class.getMethod("getExpressionFactory", null);
- } catch (NoSuchMethodException e) {
- // JSF 1.1 !
- }
- ResponseWriter writer = context.getResponseWriter();
- StateManager stateManager = context.getApplication().getStateManager();
- SerializedView serializedView = stateManager
- .saveSerializedView(context);
- if (null != serializedView) {
- StringWriter bufWriter = new StringWriter();
- ResponseWriter cloneWithWriter = writer.cloneWithWriter(bufWriter);
- context.setResponseWriter(cloneWithWriter);
- stateManager.writeState(context, serializedView);
- cloneWithWriter.flush();
- if (bufWriter.getBuffer().length() > 0) {
- context.getExternalContext().getRequestMap().put(
- AjaxViewHandler.SERIALIZED_STATE_KEY,
- bufWriter.toString());
- }
- // Restore original writer.
- context.setResponseWriter(writer);
- }
- }
-
- /**
- * @return Returns the ajaxRequest.
- */
- public boolean isAjaxRequest() {
- return isAjaxRequest(FacesContext.getCurrentInstance());
- }
-
- /**
- * @return Returns the ajaxRequest.
- */
- public boolean isAjaxRequest(FacesContext context) {
- if (!this.ajaxRequestSet) {
- ajaxRequest = null != getSubmittedRegionClientId(context);
- ajaxRequestSet = true;
- }
- return ajaxRequest;
- }
-
- /**
- * @param ajaxRequest
- * The ajaxRequest to set.
- */
- public void setAjaxRequest(boolean ajaxRequest) {
- this.ajaxRequest = ajaxRequest;
- this.ajaxRequestSet = true;
- }
-
- /**
- * @return Returns the ajaxAreasToRender.
- */
- public Set getAjaxAreasToRender() {
- return this.ajaxAreasToRender;
- }
-
- /**
- * Add affected regions's ID to ajaxView component.
- *
- * @param component
- */
- public void addRegionsFromComponent(UIComponent component) {
- // First step - find parent ajax view
- Set ajaxRegions = AjaxRendererUtils.getAjaxAreas(component);
- // if (ajaxRegions == null){
- // FacesContext context = FacesContext.getCurrentInstance();
- // ajaxRegions = AjaxRendererUtils.getAbsoluteId(context,component);
- // }
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.INVOKE_AJAX_REGION_LISTENER,
- component.getId()));
- }
- if (ajaxRegions != null) {
- for (Iterator iter = ajaxRegions.iterator(); iter.hasNext();) {
- String id = iter.next().toString();
- ajaxAreasToRender.add(convertId(component, id));
- }
- }
- }
-
- public void addComponentToAjaxRender(UIComponent component) {
- this.ajaxAreasToRender.add(AjaxRendererUtils.getAbsoluteId(component));
- }
-
- public void addComponentToAjaxRender(UIComponent base, String id) {
- this.ajaxAreasToRender.add(convertId(base, id));
- }
-
- /**
- * Test for relative id of target components. Attempt convert to
- * absolute. For use as argument for
- * {@link UIComponent#findComponent(java.lang.String)}
- *
- * @param component
- * @param id
- * @return
- */
- private String convertId(UIComponent component, String id) {
- if (id.charAt(0) == NamingContainer.SEPARATOR_CHAR) {
- return id;
- }
- if (null == component) {
- throw new NullPointerException(
- "Base component for search re-rendered compnnent is null");
- }
- UIComponent target = null;
- UIComponent parent = component;
- UIComponent root = component;
- while (null == target && null != parent) {
- target = parent.findComponent(id);
- root = parent;
- parent = parent.getParent();
- }
- if (null == target) {
- target = findUIComponentBelow(root, id);
- }
- if (null != target) {
- return AjaxRendererUtils.getAbsoluteId(target);
- }
- log.warn("Target component for id "+id+" not found");
- return id;
- }
-
- private UIComponent findUIComponentBelow(UIComponent root,
- String id) {
-
- UIComponent target = null;
- for (Iterator iter = root.getFacetsAndChildren(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- if (child instanceof NamingContainer) {
- try {
- target = child.findComponent(id);
- } catch (IllegalArgumentException iae) {
- continue;
- }
- }
- if (target == null) {
- if (child.getChildCount() > 0) {
- target = findUIComponentBelow(child, id);
- }
- }
-
- if (target != null) {
- break;
- }
-
- }
- return target;
- }
-
- /**
- * @return Returns the ajaxRenderedAreas.
- */
- public Set getAjaxRenderedAreas() {
- return ajaxRenderedAreas;
- }
-
- public void addRenderedArea(String id) {
- ajaxRenderedAreas.add(id);
- }
-
- public boolean removeRenderedArea(String id) {
- return ajaxRenderedAreas.remove(id);
- }
-
- /**
- * @return Returns the submittedClientId.
- */
- public String getSubmittedRegionClientId(FacesContext context) {
- if (!this.submittedRegionSet) {
- this.submittedRegionClientId = (String) context
- .getExternalContext().getRequestParameterMap().get(
- AjaxContainerRenderer.AJAX_PARAMETER_NAME);
- this.submittedRegionSet = true;
- if (!this.ajaxRequestSet) {
- setAjaxRequest(this.submittedRegionClientId != null);
- }
- }
- return this.submittedRegionClientId;
- }
-
- /**
- * @param submittedClientId
- * The submittedClientId to set.
- */
- public void setSubmittedRegionClientId(String submittedClientId) {
- this.submittedRegionClientId = submittedClientId;
- this.submittedRegionSet = true;
- }
-
- /**
- * @return Returns the selfRender.
- */
- public boolean isSelfRender() {
- return selfRender;
- }
-
- /**
- * @param selfRender
- * The selfRender to set.
- */
- public void setSelfRender(boolean selfRender) {
- this.selfRender = selfRender;
- }
-
- /**
- * @return the vievIdHolder
- */
- public ViewIdHolder getViewIdHolder() {
- return viewIdHolder;
- }
-
- /**
- * @param viewIdHolder
- * the vievIdHolder to set
- */
- public void setViewIdHolder(ViewIdHolder viewIdHolder) {
- this.viewIdHolder = viewIdHolder;
- }
-
- /**
- * @return the responseData
- */
- public Object getResponseData() {
- return responseDataMap.get(RESPONSE_DATA_KEY);
- }
-
- /**
- * @param responseData
- * the responseData to set
- */
- public void setResponseData(Object responseData) {
- this.responseDataMap.put(RESPONSE_DATA_KEY, responseData);
- }
-
- /**
- * @return the responseDataMap
- */
- public Map getResponseDataMap() {
- return responseDataMap;
- }
-
- /**
- * Gives back the writer of a Response object.
- *
- * @param extContext
- * The external context.
- * @return The writer of the response.
- * @throws FacesException
- * If the response object has no getWriter() method.
- */
- protected PrintWriter getWriter(ExternalContext extContext)
- throws FacesException {
- PrintWriter writer = null;
- Object response = extContext.getResponse();
- try {
- Method gW = response.getClass()
- .getMethod("getWriter", new Class[0]);
- writer = (PrintWriter) gW.invoke(response, new Object[0]);
- } catch (Exception e) {
- throw new FacesException(e);
- }
- return writer;
- }
-
- public String getAjaxActionURL() {
- return getAjaxActionURL(FacesContext.getCurrentInstance());
- }
-
- public String getAjaxActionURL(FacesContext context) {
- // Check arguments
- if (null == context) {
- throw new NullPointerException(
- "Faces context for build AJAX Action URL is null");
- }
- UIViewRoot viewRoot = context.getViewRoot();
- if (null == viewRoot) {
- throw new NullPointerException(
- "Faces view tree for build AJAX Action URL is null");
- }
- String viewId = viewRoot.getViewId();
- if (null == viewId) {
- throw new NullPointerException(
- "View id for build AJAX Action URL is null");
- }
- if (!viewId.startsWith("/")) {
- throw new IllegalArgumentException(
- "Illegal view Id for build AJAX Action URL: " + viewId);
- }
- ViewHandler viewHandler = context.getApplication().getViewHandler();
- return context.getExternalContext().encodeActionURL(
- viewHandler.getActionURL(context, viewId));
- }
-
- /**
- * @return the commonAjaxParameters
- */
- public Map getCommonAjaxParameters() {
- return commonAjaxParameters;
- }
-
-}
\ No newline at end of file
Copied: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/ViewIdHolder.java (from rev 1393, branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ViewIdHolder.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/ViewIdHolder.java (rev 0)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/ViewIdHolder.java 2007-06-29 17:25:00 UTC (rev 1416)
@@ -0,0 +1,37 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+/**
+ * Interface to skip navigation cases in ViewHandler and , instead, store new ViewId.
+ * @author shura
+ *
+ */
+public interface ViewIdHolder {
+
+ public boolean skipNavigation(String ViewId);
+
+ public String getViewId();
+
+ public void setViewId(String newViewId);
+
+}
Modified: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBuilder.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBuilder.java 2007-06-29 17:10:57 UTC (rev 1415)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/InternetResourceBuilder.java 2007-06-29 17:25:00 UTC (rev 1416)
@@ -148,7 +148,8 @@
log
.debug("Create default implementation instance of InternetBuilder");
}
- instance = new ResourceBuilderImpl();
+ // TODO - detect default instance.
+// instance = new ResourceBuilderImpl();
}
instances.put(loader, instance);
}
Modified: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinFactory.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinFactory.java 2007-06-29 17:10:57 UTC (rev 1415)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/skin/SkinFactory.java 2007-06-29 17:25:00 UTC (rev 1416)
@@ -113,7 +113,8 @@
}
}
if (instance == null) {
- instance = new SkinFactoryImpl();
+ // TODO - create default instance
+// instance = new SkinFactoryImpl();
}
instances.put(loader, instance);
}
Deleted: branches/refactor1/framework/api/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java 2007-06-29 17:10:57 UTC (rev 1415)
+++ branches/refactor1/framework/api/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java 2007-06-29 17:25:00 UTC (rev 1416)
@@ -1,60 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.state;
-
-import org.richfaces.component.UITree;
-
-
-/**
- * @author Nick Belaevski - mailto:nbelaevski@exadel.com
- * created 19.06.2007
- *
- * This interface is intended to "advising" changes to tree state. Tree component should queue user-provided
- * instance of the interface for changes during RENDER_RESPONSE phase. Changes advised by user should be
- * immediately applied. Advisor methods are provided with {@link UITree} component instance to queue current
- * tree state.
- */
-public interface TreeStateAdvisor {
- /**
- * Advises new node opened/closed state
- * @param tree {@link UITree} component state to queue state
- * @return
- * <ul>
- * <li><code>null</code> if changes are not needed</li>
- * <li>{@link Boolean#TRUE} to advise node to be opened</li>
- * <li>{@link Boolean#FALSE} to advise node to be closed</li>
- * </ul>
- */
- public Boolean adviseNodeOpened(UITree tree);
-
- /**
- * Advises new node selection
- * @param tree {@link UITree} component state to queue state
- * @return
- * <ul>
- * <li><code>null</code> if changes are not needed</li>
- * <li>{@link Boolean#TRUE} to advise current node to be selected</li>
- * <li>{@link Boolean#FALSE} to advise current node to be unselected</li>
- * </ul>
- */
- public Boolean adviseNodeSelected(UITree tree);
-}
Deleted: branches/refactor1/framework/api/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java 2007-06-29 17:10:57 UTC (rev 1415)
+++ branches/refactor1/framework/api/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java 2007-06-29 17:25:00 UTC (rev 1416)
@@ -1,164 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.xml;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.digester.Digester;
-import org.apache.commons.digester.RulesBase;
-import org.richfaces.component.TreeNode;
-import org.richfaces.component.TreeNodeImpl;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 16.11.2006
- *
- */
-public class XmlTreeDataBuilder {
-
- private final static class Rule extends org.apache.commons.digester.Rule {
- private int level = -1;
- private List idsList = new ArrayList();
- private List treeNodesList = new ArrayList();
- private List exclusionSets = new ArrayList();
- private TreeNode treeNode = new TreeNodeImpl(); //add empty node to serve as root
-
- public void begin(String namespace, String name, Attributes attributes)
- throws Exception {
- super.begin(namespace, name, attributes);
-
- level++;
-
- XmlNodeData xmlNodeData = new XmlNodeData();
- xmlNodeData.setName(name);
- xmlNodeData.setNamespace(namespace);
-
- String id = null;
-
- if (attributes != null) {
- int length = attributes.getLength();
- for (int i = 0; i < length; i++) {
- xmlNodeData.setAttribute(attributes.getQName(i),
- attributes.getValue(i));
-
- }
-
- id = attributes.getValue("id");
- }
-
- if (exclusionSets.size() == level) {
- exclusionSets.add(null);
- }
-
- if (id == null || id.length() == 0) {
- int currentId = 0;
-
- if (idsList.size() <= level) {
- for (int i = idsList.size(); i <= level; i++) {
- idsList.add(null);
- }
- } else {
- Integer integer = (Integer) idsList.get(level);
- currentId = integer.intValue() + 1;
- }
-
- Set exclusions = (Set) exclusionSets.get(level);
-
- while (exclusions != null && exclusions.contains(Integer.toString(currentId))) {
- currentId++;
- }
-
- idsList.set(level, new Integer(currentId));
-
- id = Integer.toString(currentId);
- } else {
- Set exclusions = (Set) exclusionSets.get(level);
- if (exclusions == null) {
- exclusions = new HashSet();
-
- exclusionSets.set(level, exclusions);
- }
-
- exclusions.add(id);
- }
-
- TreeNode node = new TreeNodeImpl();
- node.setData(xmlNodeData);
-
- this.treeNode.addChild(id, node);
- this.treeNodesList.add(this.treeNode);
- this.treeNode = node;
- }
-
- public void body(String namespace, String name, String text)
- throws Exception {
- super.body(namespace, name, text);
-
- if (text != null) {
- ((XmlNodeData) this.treeNode.getData()).setText(text.trim());
- }
- }
-
- public void end(String namespace, String name) throws Exception {
- super.end(namespace, name);
-
- level--;
-
- if (idsList.size() - 1 > level + 1) {
- //idsList grew larger than we really need
- idsList.remove(idsList.size() - 1);
- }
-
- if (exclusionSets.size() - 1 > level + 1) {
- //the same condition as above
- exclusionSets.remove(exclusionSets.size() - 1);
- }
-
- this.treeNode = (TreeNode) this.treeNodesList.remove(this.treeNodesList.size() - 1);
- }
- }
-
- public static TreeNode build(InputSource inputSource) throws SAXException, IOException {
- Digester digester = new Digester();
- Rule rule = new Rule();
- final List rulesList = new ArrayList(1);
- rulesList.add(rule);
-
- RulesBase rulesBase = new RulesBase() {
- protected List lookup(String namespace, String name) {
- return rulesList;
- }
- };
- digester.setRules(rulesBase);
- digester.setNamespaceAware(true);
- digester.parse(inputSource);
-
- return rule.treeNode;
- }
-}
Copied: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java (from rev 1415, branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java)
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java (rev 0)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java 2007-06-29 17:25:00 UTC (rev 1416)
@@ -0,0 +1,757 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.StateManager;
+import javax.faces.application.ViewHandler;
+import javax.faces.application.StateManager.SerializedView;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.render.Renderer;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
+import org.ajax4jsf.framework.ajax.xmlfilter.FilterServletResponseWrapper;
+import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.renderer.HeaderResourceProducer;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.framework.skin.Skin;
+import org.ajax4jsf.framework.skin.SkinFactory;
+import org.ajax4jsf.framework.skin.SkinNotFoundException;
+import org.ajax4jsf.framework.util.config.WebXml;
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This class incapsulated
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.7 $ $Date: 2007/02/08 19:07:16 $
+ *
+ */
+public class AjaxContextImpl extends AjaxContext {
+ public static final String RESOURCES_PROCESSED = "org.ajax4jsf.framework.HEADER_PROCESSED";
+
+ private static final Log log = LogFactory.getLog(AjaxContext.class);
+
+ private static ComponentInvoker invoker;
+
+ private static Map contextClasses = new HashMap();
+
+ Set ajaxAreasToRender = new HashSet();
+
+ Set ajaxRenderedAreas = new HashSet();
+
+ boolean ajaxRequest = false;
+
+ boolean ajaxRequestSet = false;
+
+ boolean selfRender = false;
+
+ Integer viewSequence = new Integer(1);
+
+ String submittedRegionClientId = null;
+
+ boolean submittedRegionSet = false;
+
+ ViewIdHolder viewIdHolder = null;
+
+ Map responseDataMap = new HashMap();
+
+ Map commonAjaxParameters = new HashMap();
+
+ static {
+ try {
+ // Attempt to create JSF1.2 specific invoker.
+ invoker = new JsfOneOneInvoker();
+ } catch (Exception e) {
+ invoker = new JsfOneOneInvoker();
+ }
+ }
+
+ /**
+ * @param root
+ * @param context
+ * @param callback
+ * @param regionId
+ * @return
+ * @see org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnComponent(javax.faces.component.UIComponent,
+ * javax.faces.context.FacesContext,
+ * org.ajax4jsf.framework.ajax.InvokerCallback, java.lang.String)
+ */
+ public static boolean invokeOnComponent(UIComponent root,
+ FacesContext context, InvokerCallback callback, String regionId) {
+ return invoker.invokeOnComponent(root, context, callback, regionId);
+ }
+
+ /**
+ * @param viewRoot
+ * @param context
+ * @param callback
+ * @see org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnRegionOrRoot(org.ajax4jsf.framework.ajax.AjaxViewRoot,
+ * javax.faces.context.FacesContext,
+ * org.ajax4jsf.framework.ajax.InvokerCallback)
+ */
+ public static void invokeOnRegionOrRoot(AjaxViewRoot viewRoot,
+ FacesContext context, InvokerCallback callback) {
+ invoker.invokeOnRegionOrRoot(viewRoot, context, callback);
+ }
+
+ private InvokerCallback _ajaxInvoker = new InvokerCallback() {
+
+ public void invoke(FacesContext context, UIComponent component) {
+ if (component instanceof AjaxContainer) {
+ AjaxContainer ajax = (AjaxContainer) component;
+ renderAjaxRegion(context, component, true);
+ } else {
+ // Container not found, use Root for encode.
+ renderAjaxRegion(context, context.getViewRoot(), true);
+ }
+ }
+
+ public void invokeRoot(FacesContext context) {
+ renderAjaxRegion(context, context.getViewRoot(), true);
+ }
+
+ };
+
+ public void renderSubmittedAjaxRegion(FacesContext context) {
+ renderSubmittedAjaxRegion(context, true);
+ }
+
+ public void renderSubmittedAjaxRegion(FacesContext context,
+ final boolean useFilterWriter) {
+ InvokerCallback ajaxInvoker = new InvokerCallback() {
+
+ public void invoke(FacesContext context, UIComponent component) {
+ if (component instanceof AjaxContainer) {
+ renderAjaxRegion(context, component, useFilterWriter);
+ } else {
+ // Container not found, use Root for encode.
+ renderAjaxRegion(context, context.getViewRoot(),
+ useFilterWriter);
+ }
+ }
+
+ public void invokeRoot(FacesContext context) {
+ renderAjaxRegion(context, context.getViewRoot(),
+ useFilterWriter);
+ }
+
+ };
+ if (!invokeOnComponent(context.getViewRoot(), context, ajaxInvoker,
+ getSubmittedRegionClientId(context))) {
+ renderAjaxRegion(context, context.getViewRoot(), useFilterWriter);
+ }
+
+ }
+
+ /**
+ * @param context
+ * @param useFilterWriter
+ * TODO
+ * @throws AbortProcessingException
+ */
+ public void renderAjaxRegion(FacesContext context, UIComponent component,
+ boolean useFilterWriter) throws FacesException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.RENDER_AJAX_REQUEST,
+ component.getId()));
+ }
+ try {
+ setSelfRender(true);
+ // create response writer.
+ ExternalContext extContext = context.getExternalContext();
+ RenderKit renderKit = context.getRenderKit();
+ String encoding;
+ // Depends if we talk about servlets, portlets, ...
+ if (extContext.getRequest() instanceof ServletRequest) {
+ ServletRequest request = (ServletRequest) extContext
+ .getRequest();
+ ServletResponse response = (ServletResponse) extContext
+ .getResponse();
+ // HACK - bypass MyFaces ( and other ) extensions filter.
+
+ // Setup encoding and content type
+ String contentType = "text/xml";
+ // get the encoding - must be setup by faces context or filter.
+ encoding = request.getCharacterEncoding();
+ if (encoding == null) {
+ encoding = "UTF-8";
+ }
+ response.setContentType(contentType + ";charset=" + encoding);
+ } else
+ encoding = "UTF-8";
+
+ PrintWriter servletWriter;
+ if (useFilterWriter
+ && extContext.getRequestMap().containsKey(
+ BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
+ // HACK - Special case for MyFaces, since <f:view don't call
+ // encode methods,
+ // encode response as for self-rendered region directly to
+ // filter response wrpper.
+ // to avoid exceptions, inform wrapper to ignore illegal states
+ // for getWriter/Stream.
+ ServletResponse servletResponse = (ServletResponse) extContext
+ .getRequestMap().get(
+ BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE);
+ servletResponse.resetBuffer();
+ servletWriter = servletResponse.getWriter();
+ ((FilterServletResponseWrapper) servletResponse)
+ .setUseNullStream(true);
+ } else {
+ servletWriter = getWriter(extContext);
+ }
+ ResponseWriter writer = renderKit.createResponseWriter(
+ servletWriter, null, encoding);
+ context.setResponseWriter(writer);
+ // make response
+ writer.startDocument();
+ encodeAjaxBegin(context, component);
+ component.encodeBegin(context);
+ ((AjaxContainer) component).encodeAjax(context);
+ component.encodeEnd(context);
+ saveViewState(context);
+ encodeAjaxEnd(context, component);
+ writer.endDocument();
+ writer.flush();
+ writer.close();
+ servletWriter.close();
+ // Save tree state.
+ } catch (IOException e) {
+ throw new FacesException(Messages.getMessage(
+ Messages.RENDERING_AJAX_REGION_ERROR, component
+ .getClientId(context)), e);
+ } finally {
+ context.responseComplete();
+ // component.setRendererType(defaultRenderer);
+ }
+ }
+
+ /**
+ * Encode declaration for AJAX response. Render <html><body>
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeAjaxBegin(FacesContext context, UIComponent component)
+ throws IOException {
+ // AjaxContainer ajax = (AjaxContainer) component;
+ ResponseWriter out = context.getResponseWriter();
+ // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
+ out.startElement(HTML.HTML_ELEMENT, component);
+ // TODO - html attributes. lang - from current locale ?
+ Locale locale = context.getViewRoot().getLocale();
+ out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
+ out.startElement(HTML.BODY_ELEMENT, component);
+ }
+
+ /**
+ * End encoding of AJAX response. Render tag with included areas and
+ * close </body></html>
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeAjaxEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ // AjaxContainer ajax = (AjaxContainer) component;
+ ResponseWriter out = context.getResponseWriter();
+ // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
+ out.endElement(HTML.BODY_ELEMENT);
+ out.endElement(HTML.HTML_ELEMENT);
+ }
+
+ /**
+ * @param context
+ * @param root
+ * @throws FacesException
+ */
+ public void processHeadResources(FacesContext context)
+ throws FacesException {
+ ExternalContext externalContext = context.getExternalContext();
+ Map requestMap = externalContext.getRequestMap();
+ if (!Boolean.TRUE.equals(requestMap.get(RESOURCES_PROCESSED))) {
+ if (null != requestMap.get(BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
+ if (log.isDebugEnabled()) {
+ log
+ .debug("Process component tree for collect used scripts and styles");
+ }
+ UIViewRoot root = context.getViewRoot();
+ Set scripts = new LinkedHashSet();
+ Set styles = new LinkedHashSet();
+ RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
+ .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ RenderKit renderKit = rkFactory.getRenderKit(context, context
+ .getViewRoot().getRenderKitId());
+ processHeadResources(context, root, scripts, styles, renderKit);
+ if (scripts.size() > 0) {
+ if (log.isDebugEnabled()) {
+ StringBuffer buff = new StringBuffer(
+ "Scripts for insert into head : \n");
+ for (Iterator iter = scripts.iterator(); iter.hasNext();) {
+ String script = (String) iter.next();
+ buff.append(script).append("\n");
+ }
+ log.debug(buff.toString());
+ }
+ requestMap.put(SCRIPTS_PARAMETER, scripts);
+ }
+ // Set default style sheet for current skin.
+ String styleSheetUri = null;
+ try {
+ styleSheetUri = (String) SkinFactory.getInstance().getSkin(
+ context).getParameter(context,
+ Skin.generalStyleSheet);
+ } catch (SkinNotFoundException e) {
+ log.warn("Current Skin is not found", e);
+ }
+ if (null != styleSheetUri) {
+ String resourceURL = context.getApplication()
+ .getViewHandler().getResourceURL(context,
+ styleSheetUri);
+ // TODO - some resources can be non-session aware, we
+ // must
+ // skip encoding for this case ?
+ // But, in common case - static links not need session
+ // info,
+ // and dynamic resources perform encodings if nessesary
+ // resourceURL =
+ // context.getExternalContext().encodeResourceURL(resourceURL);
+ styles.add(resourceURL);
+ }
+ if (styles.size() > 0) {
+ if (log.isDebugEnabled()) {
+ StringBuffer buff = new StringBuffer(
+ "Styles for insert into head : \n");
+ for (Iterator iter = styles.iterator(); iter.hasNext();) {
+ String style = (String) iter.next();
+ buff.append(style).append("\n");
+ }
+ log.debug(buff.toString());
+ }
+ requestMap.put(STYLES_PARAMETER, styles);
+ }
+ // Mark as processed.
+ requestMap.put(RESOURCES_PROCESSED, Boolean.TRUE);
+ }
+
+ }
+ }
+
+ /**
+ * Append nessesary scripts and styles from component ( if renderer
+ * implements {@link HeaderResourceProducer}) and recursive process all
+ * facets and childrens.
+ *
+ * @param context
+ * TODO
+ * @param root
+ * @param scripts
+ * @param styles
+ * @param renderKit
+ * TODO
+ */
+ private void processHeadResources(FacesContext context, UIComponent root,
+ Set scripts, Set styles, RenderKit renderKit) {
+ Renderer renderer = getRenderer(context, root, renderKit);
+ if (null != renderer) {
+ if (renderer instanceof HeaderResourceProducer) {
+ HeaderResourceProducer producer = (HeaderResourceProducer) renderer;
+ Set set = producer.getHeaderScripts(context, root);
+ if (null != set) {
+ scripts.addAll(set);
+ }
+ set = producer.getHeaderStyles(context, root);
+ if (null != set) {
+ styles.addAll(set);
+ }
+ }
+ }
+ for (Iterator iter = root.getFacets().values().iterator(); iter
+ .hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ processHeadResources(context, child, scripts, styles, renderKit);
+ }
+ for (Iterator iter = root.getChildren().iterator(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ processHeadResources(context, child, scripts, styles, renderKit);
+ }
+ }
+
+ /**
+ * Find renderer for given component.
+ *
+ * @param context
+ * @param comp
+ * @param renderKit
+ * @return
+ */
+ private Renderer getRenderer(FacesContext context, UIComponent comp,
+ RenderKit renderKit) {
+
+ String rendererType = comp.getRendererType();
+ if (rendererType != null) {
+ return (renderKit.getRenderer(comp.getFamily(), rendererType));
+ } else {
+ return (null);
+ }
+
+ }
+
+ public void saveViewState(FacesContext context) throws IOException {
+ // TODO - for facelets environment, we need to remove transient
+ // components.
+ try {
+ Application.class.getMethod("getExpressionFactory", null);
+ } catch (NoSuchMethodException e) {
+ // JSF 1.1 !
+ }
+ ResponseWriter writer = context.getResponseWriter();
+ StateManager stateManager = context.getApplication().getStateManager();
+ SerializedView serializedView = stateManager
+ .saveSerializedView(context);
+ if (null != serializedView) {
+ StringWriter bufWriter = new StringWriter();
+ ResponseWriter cloneWithWriter = writer.cloneWithWriter(bufWriter);
+ context.setResponseWriter(cloneWithWriter);
+ stateManager.writeState(context, serializedView);
+ cloneWithWriter.flush();
+ if (bufWriter.getBuffer().length() > 0) {
+ context.getExternalContext().getRequestMap().put(
+ AjaxViewHandler.SERIALIZED_STATE_KEY,
+ bufWriter.toString());
+ }
+ // Restore original writer.
+ context.setResponseWriter(writer);
+ }
+ }
+
+ /**
+ * @return Returns the ajaxRequest.
+ */
+ public boolean isAjaxRequest() {
+ return isAjaxRequest(FacesContext.getCurrentInstance());
+ }
+
+ /**
+ * @return Returns the ajaxRequest.
+ */
+ public boolean isAjaxRequest(FacesContext context) {
+ if (!this.ajaxRequestSet) {
+ ajaxRequest = null != getSubmittedRegionClientId(context);
+ ajaxRequestSet = true;
+ }
+ return ajaxRequest;
+ }
+
+ /**
+ * @param ajaxRequest
+ * The ajaxRequest to set.
+ */
+ public void setAjaxRequest(boolean ajaxRequest) {
+ this.ajaxRequest = ajaxRequest;
+ this.ajaxRequestSet = true;
+ }
+
+ /**
+ * @return Returns the ajaxAreasToRender.
+ */
+ public Set getAjaxAreasToRender() {
+ return this.ajaxAreasToRender;
+ }
+
+ /**
+ * Add affected regions's ID to ajaxView component.
+ *
+ * @param component
+ */
+ public void addRegionsFromComponent(UIComponent component) {
+ // First step - find parent ajax view
+ Set ajaxRegions = AjaxRendererUtils.getAjaxAreas(component);
+ // if (ajaxRegions == null){
+ // FacesContext context = FacesContext.getCurrentInstance();
+ // ajaxRegions = AjaxRendererUtils.getAbsoluteId(context,component);
+ // }
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.INVOKE_AJAX_REGION_LISTENER,
+ component.getId()));
+ }
+ if (ajaxRegions != null) {
+ for (Iterator iter = ajaxRegions.iterator(); iter.hasNext();) {
+ String id = iter.next().toString();
+ ajaxAreasToRender.add(convertId(component, id));
+ }
+ }
+ }
+
+ public void addComponentToAjaxRender(UIComponent component) {
+ this.ajaxAreasToRender.add(AjaxRendererUtils.getAbsoluteId(component));
+ }
+
+ public void addComponentToAjaxRender(UIComponent base, String id) {
+ this.ajaxAreasToRender.add(convertId(base, id));
+ }
+
+ /**
+ * Test for relative id of target components. Attempt convert to
+ * absolute. For use as argument for
+ * {@link UIComponent#findComponent(java.lang.String)}
+ *
+ * @param component
+ * @param id
+ * @return
+ */
+ private String convertId(UIComponent component, String id) {
+ if (id.charAt(0) == NamingContainer.SEPARATOR_CHAR) {
+ return id;
+ }
+ if (null == component) {
+ throw new NullPointerException(
+ "Base component for search re-rendered compnnent is null");
+ }
+ UIComponent target = null;
+ UIComponent parent = component;
+ UIComponent root = component;
+ while (null == target && null != parent) {
+ target = parent.findComponent(id);
+ root = parent;
+ parent = parent.getParent();
+ }
+ if (null == target) {
+ target = findUIComponentBelow(root, id);
+ }
+ if (null != target) {
+ return AjaxRendererUtils.getAbsoluteId(target);
+ }
+ log.warn("Target component for id "+id+" not found");
+ return id;
+ }
+
+ private UIComponent findUIComponentBelow(UIComponent root,
+ String id) {
+
+ UIComponent target = null;
+ for (Iterator iter = root.getFacetsAndChildren(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ if (child instanceof NamingContainer) {
+ try {
+ target = child.findComponent(id);
+ } catch (IllegalArgumentException iae) {
+ continue;
+ }
+ }
+ if (target == null) {
+ if (child.getChildCount() > 0) {
+ target = findUIComponentBelow(child, id);
+ }
+ }
+
+ if (target != null) {
+ break;
+ }
+
+ }
+ return target;
+ }
+
+ /**
+ * @return Returns the ajaxRenderedAreas.
+ */
+ public Set getAjaxRenderedAreas() {
+ return ajaxRenderedAreas;
+ }
+
+ public void addRenderedArea(String id) {
+ ajaxRenderedAreas.add(id);
+ }
+
+ public boolean removeRenderedArea(String id) {
+ return ajaxRenderedAreas.remove(id);
+ }
+
+ /**
+ * @return Returns the submittedClientId.
+ */
+ public String getSubmittedRegionClientId(FacesContext context) {
+ if (!this.submittedRegionSet) {
+ this.submittedRegionClientId = (String) context
+ .getExternalContext().getRequestParameterMap().get(
+ AjaxContainerRenderer.AJAX_PARAMETER_NAME);
+ this.submittedRegionSet = true;
+ if (!this.ajaxRequestSet) {
+ setAjaxRequest(this.submittedRegionClientId != null);
+ }
+ }
+ return this.submittedRegionClientId;
+ }
+
+ /**
+ * @param submittedClientId
+ * The submittedClientId to set.
+ */
+ public void setSubmittedRegionClientId(String submittedClientId) {
+ this.submittedRegionClientId = submittedClientId;
+ this.submittedRegionSet = true;
+ }
+
+ /**
+ * @return Returns the selfRender.
+ */
+ public boolean isSelfRender() {
+ return selfRender;
+ }
+
+ /**
+ * @param selfRender
+ * The selfRender to set.
+ */
+ public void setSelfRender(boolean selfRender) {
+ this.selfRender = selfRender;
+ }
+
+ /**
+ * @return the vievIdHolder
+ */
+ public ViewIdHolder getViewIdHolder() {
+ return viewIdHolder;
+ }
+
+ /**
+ * @param viewIdHolder
+ * the vievIdHolder to set
+ */
+ public void setViewIdHolder(ViewIdHolder viewIdHolder) {
+ this.viewIdHolder = viewIdHolder;
+ }
+
+ /**
+ * @return the responseData
+ */
+ public Object getResponseData() {
+ return responseDataMap.get(RESPONSE_DATA_KEY);
+ }
+
+ /**
+ * @param responseData
+ * the responseData to set
+ */
+ public void setResponseData(Object responseData) {
+ this.responseDataMap.put(RESPONSE_DATA_KEY, responseData);
+ }
+
+ /**
+ * @return the responseDataMap
+ */
+ public Map getResponseDataMap() {
+ return responseDataMap;
+ }
+
+ /**
+ * Gives back the writer of a Response object.
+ *
+ * @param extContext
+ * The external context.
+ * @return The writer of the response.
+ * @throws FacesException
+ * If the response object has no getWriter() method.
+ */
+ protected PrintWriter getWriter(ExternalContext extContext)
+ throws FacesException {
+ PrintWriter writer = null;
+ Object response = extContext.getResponse();
+ try {
+ Method gW = response.getClass()
+ .getMethod("getWriter", new Class[0]);
+ writer = (PrintWriter) gW.invoke(response, new Object[0]);
+ } catch (Exception e) {
+ throw new FacesException(e);
+ }
+ return writer;
+ }
+
+ public String getAjaxActionURL() {
+ return getAjaxActionURL(FacesContext.getCurrentInstance());
+ }
+
+ public String getAjaxActionURL(FacesContext context) {
+ // Check arguments
+ if (null == context) {
+ throw new NullPointerException(
+ "Faces context for build AJAX Action URL is null");
+ }
+ UIViewRoot viewRoot = context.getViewRoot();
+ if (null == viewRoot) {
+ throw new NullPointerException(
+ "Faces view tree for build AJAX Action URL is null");
+ }
+ String viewId = viewRoot.getViewId();
+ if (null == viewId) {
+ throw new NullPointerException(
+ "View id for build AJAX Action URL is null");
+ }
+ if (!viewId.startsWith("/")) {
+ throw new IllegalArgumentException(
+ "Illegal view Id for build AJAX Action URL: " + viewId);
+ }
+ ViewHandler viewHandler = context.getApplication().getViewHandler();
+ return context.getExternalContext().encodeActionURL(
+ viewHandler.getActionURL(context, viewId));
+ }
+
+ /**
+ * @return the commonAjaxParameters
+ */
+ public Map getCommonAjaxParameters() {
+ return commonAjaxParameters;
+ }
+
+}
\ No newline at end of file
Deleted: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ViewIdHolder.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ViewIdHolder.java 2007-06-29 17:10:57 UTC (rev 1415)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/ViewIdHolder.java 2007-06-29 17:25:00 UTC (rev 1416)
@@ -1,37 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-/**
- * Interface to skip navigation cases in ViewHandler and , instead, store new ViewId.
- * @author shura
- *
- */
-public interface ViewIdHolder {
-
- public boolean skipNavigation(String ViewId);
-
- public String getViewId();
-
- public void setViewId(String newViewId);
-
-}
Copied: branches/refactor1/ui/tree/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java (from rev 1393, branches/refactor1/framework/api/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java)
===================================================================
--- branches/refactor1/ui/tree/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java (rev 0)
+++ branches/refactor1/ui/tree/src/main/java/org/richfaces/component/state/TreeStateAdvisor.java 2007-06-29 17:25:00 UTC (rev 1416)
@@ -0,0 +1,60 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.state;
+
+import org.richfaces.component.UITree;
+
+
+/**
+ * @author Nick Belaevski - mailto:nbelaevski@exadel.com
+ * created 19.06.2007
+ *
+ * This interface is intended to "advising" changes to tree state. Tree component should queue user-provided
+ * instance of the interface for changes during RENDER_RESPONSE phase. Changes advised by user should be
+ * immediately applied. Advisor methods are provided with {@link UITree} component instance to queue current
+ * tree state.
+ */
+public interface TreeStateAdvisor {
+ /**
+ * Advises new node opened/closed state
+ * @param tree {@link UITree} component state to queue state
+ * @return
+ * <ul>
+ * <li><code>null</code> if changes are not needed</li>
+ * <li>{@link Boolean#TRUE} to advise node to be opened</li>
+ * <li>{@link Boolean#FALSE} to advise node to be closed</li>
+ * </ul>
+ */
+ public Boolean adviseNodeOpened(UITree tree);
+
+ /**
+ * Advises new node selection
+ * @param tree {@link UITree} component state to queue state
+ * @return
+ * <ul>
+ * <li><code>null</code> if changes are not needed</li>
+ * <li>{@link Boolean#TRUE} to advise current node to be selected</li>
+ * <li>{@link Boolean#FALSE} to advise current node to be unselected</li>
+ * </ul>
+ */
+ public Boolean adviseNodeSelected(UITree tree);
+}
Copied: branches/refactor1/ui/tree/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java (from rev 1393, branches/refactor1/framework/api/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java)
===================================================================
--- branches/refactor1/ui/tree/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java (rev 0)
+++ branches/refactor1/ui/tree/src/main/java/org/richfaces/component/xml/XmlTreeDataBuilder.java 2007-06-29 17:25:00 UTC (rev 1416)
@@ -0,0 +1,164 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.xml;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.digester.Digester;
+import org.apache.commons.digester.RulesBase;
+import org.richfaces.component.TreeNode;
+import org.richfaces.component.TreeNodeImpl;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 16.11.2006
+ *
+ */
+public class XmlTreeDataBuilder {
+
+ private final static class Rule extends org.apache.commons.digester.Rule {
+ private int level = -1;
+ private List idsList = new ArrayList();
+ private List treeNodesList = new ArrayList();
+ private List exclusionSets = new ArrayList();
+ private TreeNode treeNode = new TreeNodeImpl(); //add empty node to serve as root
+
+ public void begin(String namespace, String name, Attributes attributes)
+ throws Exception {
+ super.begin(namespace, name, attributes);
+
+ level++;
+
+ XmlNodeData xmlNodeData = new XmlNodeData();
+ xmlNodeData.setName(name);
+ xmlNodeData.setNamespace(namespace);
+
+ String id = null;
+
+ if (attributes != null) {
+ int length = attributes.getLength();
+ for (int i = 0; i < length; i++) {
+ xmlNodeData.setAttribute(attributes.getQName(i),
+ attributes.getValue(i));
+
+ }
+
+ id = attributes.getValue("id");
+ }
+
+ if (exclusionSets.size() == level) {
+ exclusionSets.add(null);
+ }
+
+ if (id == null || id.length() == 0) {
+ int currentId = 0;
+
+ if (idsList.size() <= level) {
+ for (int i = idsList.size(); i <= level; i++) {
+ idsList.add(null);
+ }
+ } else {
+ Integer integer = (Integer) idsList.get(level);
+ currentId = integer.intValue() + 1;
+ }
+
+ Set exclusions = (Set) exclusionSets.get(level);
+
+ while (exclusions != null && exclusions.contains(Integer.toString(currentId))) {
+ currentId++;
+ }
+
+ idsList.set(level, new Integer(currentId));
+
+ id = Integer.toString(currentId);
+ } else {
+ Set exclusions = (Set) exclusionSets.get(level);
+ if (exclusions == null) {
+ exclusions = new HashSet();
+
+ exclusionSets.set(level, exclusions);
+ }
+
+ exclusions.add(id);
+ }
+
+ TreeNode node = new TreeNodeImpl();
+ node.setData(xmlNodeData);
+
+ this.treeNode.addChild(id, node);
+ this.treeNodesList.add(this.treeNode);
+ this.treeNode = node;
+ }
+
+ public void body(String namespace, String name, String text)
+ throws Exception {
+ super.body(namespace, name, text);
+
+ if (text != null) {
+ ((XmlNodeData) this.treeNode.getData()).setText(text.trim());
+ }
+ }
+
+ public void end(String namespace, String name) throws Exception {
+ super.end(namespace, name);
+
+ level--;
+
+ if (idsList.size() - 1 > level + 1) {
+ //idsList grew larger than we really need
+ idsList.remove(idsList.size() - 1);
+ }
+
+ if (exclusionSets.size() - 1 > level + 1) {
+ //the same condition as above
+ exclusionSets.remove(exclusionSets.size() - 1);
+ }
+
+ this.treeNode = (TreeNode) this.treeNodesList.remove(this.treeNodesList.size() - 1);
+ }
+ }
+
+ public static TreeNode build(InputSource inputSource) throws SAXException, IOException {
+ Digester digester = new Digester();
+ Rule rule = new Rule();
+ final List rulesList = new ArrayList(1);
+ rulesList.add(rule);
+
+ RulesBase rulesBase = new RulesBase() {
+ protected List lookup(String namespace, String name) {
+ return rulesList;
+ }
+ };
+ digester.setRules(rulesBase);
+ digester.setNamespaceAware(true);
+ digester.parse(inputSource);
+
+ return rule.treeNode;
+ }
+}
17 years, 2 months
JBoss Rich Faces SVN: r1415 - in branches/refactor1/framework: api/src/main/java/org/ajax4jsf/framework/ajax and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-06-29 13:10:57 -0400 (Fri, 29 Jun 2007)
New Revision: 1415
Added:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java
Removed:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleEvent.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleException.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/message/
Modified:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
Log:
continue refactoring
Modified: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java 2007-06-29 17:01:45 UTC (rev 1414)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java 2007-06-29 17:10:57 UTC (rev 1415)
@@ -47,7 +47,6 @@
import javax.faces.model.ListDataModel;
import javax.faces.render.Renderer;
-import org.ajax4jsf.framework.renderer.AjaxChildrenRenderer;
import org.ajax4jsf.framework.renderer.AjaxRenderer;
/**
Deleted: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java 2007-06-29 17:01:45 UTC (rev 1414)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java 2007-06-29 17:10:57 UTC (rev 1415)
@@ -1,806 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.ajax;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.FacesException;
-import javax.faces.FactoryFinder;
-import javax.faces.application.Application;
-import javax.faces.application.StateManager;
-import javax.faces.application.ViewHandler;
-import javax.faces.application.StateManager.SerializedView;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.el.VariableResolver;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.render.RenderKit;
-import javax.faces.render.RenderKitFactory;
-import javax.faces.render.Renderer;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-
-import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
-import org.ajax4jsf.framework.ajax.xmlfilter.FilterServletResponseWrapper;
-import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.HeaderResourceProducer;
-import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
-import org.ajax4jsf.framework.skin.Skin;
-import org.ajax4jsf.framework.skin.SkinFactory;
-import org.ajax4jsf.framework.skin.SkinNotFoundException;
-import org.ajax4jsf.framework.util.config.WebXml;
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * This class incapsulated
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.7 $ $Date: 2007/02/08 19:07:16 $
- *
- */
-public class AjaxContext {
- /**
- * Key for keep request state information in request-scope attributes.
- */
- public static final String AJAX_CONTEXT_KEY = "ajaxContext";
-
- public static final String SCRIPTS_PARAMETER = "org.ajax4jsf.framework.HEADER_SCRIPTS";
-
- public static final String STYLES_PARAMETER = "org.ajax4jsf.framework.HEADER_STYLES";
-
- public static final String RESOURCES_PROCESSED = "org.ajax4jsf.framework.HEADER_PROCESSED";
-
- public static final String RESPONSE_DATA_KEY = "_ajax:data";
-
- private static final Log log = LogFactory.getLog(AjaxContext.class);
-
- private static ComponentInvoker invoker;
-
- private static Map contextClasses = new HashMap();
-
- Set ajaxAreasToRender = new HashSet();
-
- Set ajaxRenderedAreas = new HashSet();
-
- boolean ajaxRequest = false;
-
- boolean ajaxRequestSet = false;
-
- boolean selfRender = false;
-
- Integer viewSequence = new Integer(1);
-
- String submittedRegionClientId = null;
-
- boolean submittedRegionSet = false;
-
- ViewIdHolder viewIdHolder = null;
-
- Map responseDataMap = new HashMap();
-
- Map commonAjaxParameters = new HashMap();
-
- static {
- try {
- // Attempt to create JSF1.2 specific invoker.
- invoker = new JsfOneOneInvoker();
- } catch (Exception e) {
- invoker = new JsfOneOneInvoker();
- }
- }
-
- /**
- * Get instance of current AJAX Context. Instance get by
- * {@link VariableResolver#resolveVariable(FacesContext, String)} for
- * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
- *
- * @return memento instance for current request
- */
- public static AjaxContext getCurrentInstance() {
- FacesContext context = FacesContext.getCurrentInstance();
- return getCurrentInstance(context);
- }
-
- /**
- * Get instance of current AJAX Context. Instance get by
- * {@link VariableResolver#resolveVariable(FacesContext, String)} for
- * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
- *
- * @param context
- * current FacesContext
- * @return instance of AjaxContext.
- */
- public static AjaxContext getCurrentInstance(FacesContext context) {
- if (null == context) {
- throw new NullPointerException("FacesContext is null");
- }
- AjaxContext ajaxContext = (AjaxContext) context.getApplication()
- .getVariableResolver().resolveVariable(context,
- AJAX_CONTEXT_KEY);
- if (null == ajaxContext) {
- // Create default implementation.
- ajaxContext = new AjaxContext();
- context.getExternalContext().getRequestMap().put(AJAX_CONTEXT_KEY,
- ajaxContext);
- }
- return ajaxContext;
- }
-
- /**
- * @param root
- * @param context
- * @param callback
- * @param regionId
- * @return
- * @see org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnComponent(javax.faces.component.UIComponent,
- * javax.faces.context.FacesContext,
- * org.ajax4jsf.framework.ajax.InvokerCallback, java.lang.String)
- */
- public static boolean invokeOnComponent(UIComponent root,
- FacesContext context, InvokerCallback callback, String regionId) {
- return invoker.invokeOnComponent(root, context, callback, regionId);
- }
-
- /**
- * @param viewRoot
- * @param context
- * @param callback
- * @see org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnRegionOrRoot(org.ajax4jsf.framework.ajax.AjaxViewRoot,
- * javax.faces.context.FacesContext,
- * org.ajax4jsf.framework.ajax.InvokerCallback)
- */
- public static void invokeOnRegionOrRoot(AjaxViewRoot viewRoot,
- FacesContext context, InvokerCallback callback) {
- invoker.invokeOnRegionOrRoot(viewRoot, context, callback);
- }
-
- private InvokerCallback _ajaxInvoker = new InvokerCallback() {
-
- public void invoke(FacesContext context, UIComponent component) {
- if (component instanceof AjaxContainer) {
- AjaxContainer ajax = (AjaxContainer) component;
- renderAjaxRegion(context, component, true);
- } else {
- // Container not found, use Root for encode.
- renderAjaxRegion(context, context.getViewRoot(), true);
- }
- }
-
- public void invokeRoot(FacesContext context) {
- renderAjaxRegion(context, context.getViewRoot(), true);
- }
-
- };
-
- public void renderSubmittedAjaxRegion(FacesContext context) {
- renderSubmittedAjaxRegion(context, true);
- }
-
- public void renderSubmittedAjaxRegion(FacesContext context,
- final boolean useFilterWriter) {
- InvokerCallback ajaxInvoker = new InvokerCallback() {
-
- public void invoke(FacesContext context, UIComponent component) {
- if (component instanceof AjaxContainer) {
- renderAjaxRegion(context, component, useFilterWriter);
- } else {
- // Container not found, use Root for encode.
- renderAjaxRegion(context, context.getViewRoot(),
- useFilterWriter);
- }
- }
-
- public void invokeRoot(FacesContext context) {
- renderAjaxRegion(context, context.getViewRoot(),
- useFilterWriter);
- }
-
- };
- if (!invokeOnComponent(context.getViewRoot(), context, ajaxInvoker,
- getSubmittedRegionClientId(context))) {
- renderAjaxRegion(context, context.getViewRoot(), useFilterWriter);
- }
-
- }
-
- /**
- * @param context
- * @param useFilterWriter
- * TODO
- * @throws AbortProcessingException
- */
- public void renderAjaxRegion(FacesContext context, UIComponent component,
- boolean useFilterWriter) throws FacesException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.RENDER_AJAX_REQUEST,
- component.getId()));
- }
- try {
- setSelfRender(true);
- // create response writer.
- ExternalContext extContext = context.getExternalContext();
- RenderKit renderKit = context.getRenderKit();
- String encoding;
- // Depends if we talk about servlets, portlets, ...
- if (extContext.getRequest() instanceof ServletRequest) {
- ServletRequest request = (ServletRequest) extContext
- .getRequest();
- ServletResponse response = (ServletResponse) extContext
- .getResponse();
- // HACK - bypass MyFaces ( and other ) extensions filter.
-
- // Setup encoding and content type
- String contentType = "text/xml";
- // get the encoding - must be setup by faces context or filter.
- encoding = request.getCharacterEncoding();
- if (encoding == null) {
- encoding = "UTF-8";
- }
- response.setContentType(contentType + ";charset=" + encoding);
- } else
- encoding = "UTF-8";
-
- PrintWriter servletWriter;
- if (useFilterWriter
- && extContext.getRequestMap().containsKey(
- BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
- // HACK - Special case for MyFaces, since <f:view don't call
- // encode methods,
- // encode response as for self-rendered region directly to
- // filter response wrpper.
- // to avoid exceptions, inform wrapper to ignore illegal states
- // for getWriter/Stream.
- ServletResponse servletResponse = (ServletResponse) extContext
- .getRequestMap().get(
- BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE);
- servletResponse.resetBuffer();
- servletWriter = servletResponse.getWriter();
- ((FilterServletResponseWrapper) servletResponse)
- .setUseNullStream(true);
- } else {
- servletWriter = getWriter(extContext);
- }
- ResponseWriter writer = renderKit.createResponseWriter(
- servletWriter, null, encoding);
- context.setResponseWriter(writer);
- // make response
- writer.startDocument();
- encodeAjaxBegin(context, component);
- component.encodeBegin(context);
- ((AjaxContainer) component).encodeAjax(context);
- component.encodeEnd(context);
- saveViewState(context);
- encodeAjaxEnd(context, component);
- writer.endDocument();
- writer.flush();
- writer.close();
- servletWriter.close();
- // Save tree state.
- } catch (IOException e) {
- throw new FacesException(Messages.getMessage(
- Messages.RENDERING_AJAX_REGION_ERROR, component
- .getClientId(context)), e);
- } finally {
- context.responseComplete();
- // component.setRendererType(defaultRenderer);
- }
- }
-
- /**
- * Encode declaration for AJAX response. Render <html><body>
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeAjaxBegin(FacesContext context, UIComponent component)
- throws IOException {
- // AjaxContainer ajax = (AjaxContainer) component;
- ResponseWriter out = context.getResponseWriter();
- // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
- out.startElement(HTML.HTML_ELEMENT, component);
- // TODO - html attributes. lang - from current locale ?
- Locale locale = context.getViewRoot().getLocale();
- out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
- out.startElement(HTML.BODY_ELEMENT, component);
- }
-
- /**
- * End encoding of AJAX response. Render tag with included areas and
- * close </body></html>
- *
- * @param context
- * @param component
- * @throws IOException
- */
- public void encodeAjaxEnd(FacesContext context, UIComponent component)
- throws IOException {
- // AjaxContainer ajax = (AjaxContainer) component;
- ResponseWriter out = context.getResponseWriter();
- // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
- out.endElement(HTML.BODY_ELEMENT);
- out.endElement(HTML.HTML_ELEMENT);
- }
-
- /**
- * @param context
- * @param root
- * @throws FacesException
- */
- public void processHeadResources(FacesContext context)
- throws FacesException {
- ExternalContext externalContext = context.getExternalContext();
- Map requestMap = externalContext.getRequestMap();
- if (!Boolean.TRUE.equals(requestMap.get(RESOURCES_PROCESSED))) {
- if (null != requestMap.get(BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
- if (log.isDebugEnabled()) {
- log
- .debug("Process component tree for collect used scripts and styles");
- }
- UIViewRoot root = context.getViewRoot();
- Set scripts = new LinkedHashSet();
- Set styles = new LinkedHashSet();
- RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
- .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- RenderKit renderKit = rkFactory.getRenderKit(context, context
- .getViewRoot().getRenderKitId());
- processHeadResources(context, root, scripts, styles, renderKit);
- if (scripts.size() > 0) {
- if (log.isDebugEnabled()) {
- StringBuffer buff = new StringBuffer(
- "Scripts for insert into head : \n");
- for (Iterator iter = scripts.iterator(); iter.hasNext();) {
- String script = (String) iter.next();
- buff.append(script).append("\n");
- }
- log.debug(buff.toString());
- }
- requestMap.put(SCRIPTS_PARAMETER, scripts);
- }
- // Set default style sheet for current skin.
- String styleSheetUri = null;
- try {
- styleSheetUri = (String) SkinFactory.getInstance().getSkin(
- context).getParameter(context,
- Skin.generalStyleSheet);
- } catch (SkinNotFoundException e) {
- log.warn("Current Skin is not found", e);
- }
- if (null != styleSheetUri) {
- String resourceURL = context.getApplication()
- .getViewHandler().getResourceURL(context,
- styleSheetUri);
- // TODO - some resources can be non-session aware, we
- // must
- // skip encoding for this case ?
- // But, in common case - static links not need session
- // info,
- // and dynamic resources perform encodings if nessesary
- // resourceURL =
- // context.getExternalContext().encodeResourceURL(resourceURL);
- styles.add(resourceURL);
- }
- if (styles.size() > 0) {
- if (log.isDebugEnabled()) {
- StringBuffer buff = new StringBuffer(
- "Styles for insert into head : \n");
- for (Iterator iter = styles.iterator(); iter.hasNext();) {
- String style = (String) iter.next();
- buff.append(style).append("\n");
- }
- log.debug(buff.toString());
- }
- requestMap.put(STYLES_PARAMETER, styles);
- }
- // Mark as processed.
- requestMap.put(RESOURCES_PROCESSED, Boolean.TRUE);
- }
-
- }
- }
-
- /**
- * Append nessesary scripts and styles from component ( if renderer
- * implements {@link HeaderResourceProducer}) and recursive process all
- * facets and childrens.
- *
- * @param context
- * TODO
- * @param root
- * @param scripts
- * @param styles
- * @param renderKit
- * TODO
- */
- private void processHeadResources(FacesContext context, UIComponent root,
- Set scripts, Set styles, RenderKit renderKit) {
- Renderer renderer = getRenderer(context, root, renderKit);
- if (null != renderer) {
- if (renderer instanceof HeaderResourceProducer) {
- HeaderResourceProducer producer = (HeaderResourceProducer) renderer;
- Set set = producer.getHeaderScripts(context, root);
- if (null != set) {
- scripts.addAll(set);
- }
- set = producer.getHeaderStyles(context, root);
- if (null != set) {
- styles.addAll(set);
- }
- }
- }
- for (Iterator iter = root.getFacets().values().iterator(); iter
- .hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- processHeadResources(context, child, scripts, styles, renderKit);
- }
- for (Iterator iter = root.getChildren().iterator(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- processHeadResources(context, child, scripts, styles, renderKit);
- }
- }
-
- /**
- * Find renderer for given component.
- *
- * @param context
- * @param comp
- * @param renderKit
- * @return
- */
- private Renderer getRenderer(FacesContext context, UIComponent comp,
- RenderKit renderKit) {
-
- String rendererType = comp.getRendererType();
- if (rendererType != null) {
- return (renderKit.getRenderer(comp.getFamily(), rendererType));
- } else {
- return (null);
- }
-
- }
-
- public void saveViewState(FacesContext context) throws IOException {
- // TODO - for facelets environment, we need to remove transient
- // components.
- try {
- Application.class.getMethod("getExpressionFactory", null);
- } catch (NoSuchMethodException e) {
- // JSF 1.1 !
- }
- ResponseWriter writer = context.getResponseWriter();
- StateManager stateManager = context.getApplication().getStateManager();
- SerializedView serializedView = stateManager
- .saveSerializedView(context);
- if (null != serializedView) {
- StringWriter bufWriter = new StringWriter();
- ResponseWriter cloneWithWriter = writer.cloneWithWriter(bufWriter);
- context.setResponseWriter(cloneWithWriter);
- stateManager.writeState(context, serializedView);
- cloneWithWriter.flush();
- if (bufWriter.getBuffer().length() > 0) {
- context.getExternalContext().getRequestMap().put(
- AjaxViewHandler.SERIALIZED_STATE_KEY,
- bufWriter.toString());
- }
- // Restore original writer.
- context.setResponseWriter(writer);
- }
- }
-
- /**
- * @return Returns the ajaxRequest.
- */
- public boolean isAjaxRequest() {
- return isAjaxRequest(FacesContext.getCurrentInstance());
- }
-
- /**
- * @return Returns the ajaxRequest.
- */
- public boolean isAjaxRequest(FacesContext context) {
- if (!this.ajaxRequestSet) {
- ajaxRequest = null != getSubmittedRegionClientId(context);
- ajaxRequestSet = true;
- }
- return ajaxRequest;
- }
-
- /**
- * @param ajaxRequest
- * The ajaxRequest to set.
- */
- public void setAjaxRequest(boolean ajaxRequest) {
- this.ajaxRequest = ajaxRequest;
- this.ajaxRequestSet = true;
- }
-
- /**
- * @return Returns the ajaxAreasToRender.
- */
- public Set getAjaxAreasToRender() {
- return this.ajaxAreasToRender;
- }
-
- /**
- * Add affected regions's ID to ajaxView component.
- *
- * @param component
- */
- public void addRegionsFromComponent(UIComponent component) {
- // First step - find parent ajax view
- Set ajaxRegions = AjaxRendererUtils.getAjaxAreas(component);
- // if (ajaxRegions == null){
- // FacesContext context = FacesContext.getCurrentInstance();
- // ajaxRegions = AjaxRendererUtils.getAbsoluteId(context,component);
- // }
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.INVOKE_AJAX_REGION_LISTENER,
- component.getId()));
- }
- if (ajaxRegions != null) {
- for (Iterator iter = ajaxRegions.iterator(); iter.hasNext();) {
- String id = iter.next().toString();
- ajaxAreasToRender.add(convertId(component, id));
- }
- }
- }
-
- public void addComponentToAjaxRender(UIComponent component) {
- this.ajaxAreasToRender.add(AjaxRendererUtils.getAbsoluteId(component));
- }
-
- public void addComponentToAjaxRender(UIComponent base, String id) {
- this.ajaxAreasToRender.add(convertId(base, id));
- }
-
- /**
- * Test for relative id of target components. Attempt convert to
- * absolute. For use as argument for
- * {@link UIComponent#findComponent(java.lang.String)}
- *
- * @param component
- * @param id
- * @return
- */
- private String convertId(UIComponent component, String id) {
- if (id.charAt(0) == NamingContainer.SEPARATOR_CHAR) {
- return id;
- }
- if (null == component) {
- throw new NullPointerException(
- "Base component for search re-rendered compnnent is null");
- }
- UIComponent target = null;
- UIComponent parent = component;
- UIComponent root = component;
- while (null == target && null != parent) {
- target = parent.findComponent(id);
- root = parent;
- parent = parent.getParent();
- }
- if (null == target) {
- target = findUIComponentBelow(root, id);
- }
- if (null != target) {
- return AjaxRendererUtils.getAbsoluteId(target);
- }
- log.warn("Target component for id "+id+" not found");
- return id;
- }
-
- private UIComponent findUIComponentBelow(UIComponent root,
- String id) {
-
- UIComponent target = null;
- for (Iterator iter = root.getFacetsAndChildren(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- if (child instanceof NamingContainer) {
- try {
- target = child.findComponent(id);
- } catch (IllegalArgumentException iae) {
- continue;
- }
- }
- if (target == null) {
- if (child.getChildCount() > 0) {
- target = findUIComponentBelow(child, id);
- }
- }
-
- if (target != null) {
- break;
- }
-
- }
- return target;
- }
-
- /**
- * @return Returns the ajaxRenderedAreas.
- */
- public Set getAjaxRenderedAreas() {
- return ajaxRenderedAreas;
- }
-
- public void addRenderedArea(String id) {
- ajaxRenderedAreas.add(id);
- }
-
- public boolean removeRenderedArea(String id) {
- return ajaxRenderedAreas.remove(id);
- }
-
- /**
- * @return Returns the submittedClientId.
- */
- public String getSubmittedRegionClientId(FacesContext context) {
- if (!this.submittedRegionSet) {
- this.submittedRegionClientId = (String) context
- .getExternalContext().getRequestParameterMap().get(
- AjaxContainerRenderer.AJAX_PARAMETER_NAME);
- this.submittedRegionSet = true;
- if (!this.ajaxRequestSet) {
- setAjaxRequest(this.submittedRegionClientId != null);
- }
- }
- return this.submittedRegionClientId;
- }
-
- /**
- * @param submittedClientId
- * The submittedClientId to set.
- */
- public void setSubmittedRegionClientId(String submittedClientId) {
- this.submittedRegionClientId = submittedClientId;
- this.submittedRegionSet = true;
- }
-
- /**
- * @return Returns the selfRender.
- */
- public boolean isSelfRender() {
- return selfRender;
- }
-
- /**
- * @param selfRender
- * The selfRender to set.
- */
- public void setSelfRender(boolean selfRender) {
- this.selfRender = selfRender;
- }
-
- /**
- * @return the vievIdHolder
- */
- public ViewIdHolder getViewIdHolder() {
- return viewIdHolder;
- }
-
- /**
- * @param viewIdHolder
- * the vievIdHolder to set
- */
- public void setViewIdHolder(ViewIdHolder viewIdHolder) {
- this.viewIdHolder = viewIdHolder;
- }
-
- /**
- * @return the responseData
- */
- public Object getResponseData() {
- return responseDataMap.get(RESPONSE_DATA_KEY);
- }
-
- /**
- * @param responseData
- * the responseData to set
- */
- public void setResponseData(Object responseData) {
- this.responseDataMap.put(RESPONSE_DATA_KEY, responseData);
- }
-
- /**
- * @return the responseDataMap
- */
- public Map getResponseDataMap() {
- return responseDataMap;
- }
-
- /**
- * Gives back the writer of a Response object.
- *
- * @param extContext
- * The external context.
- * @return The writer of the response.
- * @throws FacesException
- * If the response object has no getWriter() method.
- */
- protected PrintWriter getWriter(ExternalContext extContext)
- throws FacesException {
- PrintWriter writer = null;
- Object response = extContext.getResponse();
- try {
- Method gW = response.getClass()
- .getMethod("getWriter", new Class[0]);
- writer = (PrintWriter) gW.invoke(response, new Object[0]);
- } catch (Exception e) {
- throw new FacesException(e);
- }
- return writer;
- }
-
- public String getAjaxActionURL() {
- return getAjaxActionURL(FacesContext.getCurrentInstance());
- }
-
- public String getAjaxActionURL(FacesContext context) {
- // Check arguments
- if (null == context) {
- throw new NullPointerException(
- "Faces context for build AJAX Action URL is null");
- }
- UIViewRoot viewRoot = context.getViewRoot();
- if (null == viewRoot) {
- throw new NullPointerException(
- "Faces view tree for build AJAX Action URL is null");
- }
- String viewId = viewRoot.getViewId();
- if (null == viewId) {
- throw new NullPointerException(
- "View id for build AJAX Action URL is null");
- }
- if (!viewId.startsWith("/")) {
- throw new IllegalArgumentException(
- "Illegal view Id for build AJAX Action URL: " + viewId);
- }
- ViewHandler viewHandler = context.getApplication().getViewHandler();
- return context.getExternalContext().encodeActionURL(
- viewHandler.getActionURL(context, viewId));
- }
-
- /**
- * @return the commonAjaxParameters
- */
- public Map getCommonAjaxParameters() {
- return commonAjaxParameters;
- }
-
-}
\ No newline at end of file
Copied: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java (from rev 1393, branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContext.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java (rev 0)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxContextImpl.java 2007-06-29 17:10:57 UTC (rev 1415)
@@ -0,0 +1,806 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.ajax;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.StateManager;
+import javax.faces.application.ViewHandler;
+import javax.faces.application.StateManager.SerializedView;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.el.VariableResolver;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.render.RenderKit;
+import javax.faces.render.RenderKitFactory;
+import javax.faces.render.Renderer;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter;
+import org.ajax4jsf.framework.ajax.xmlfilter.FilterServletResponseWrapper;
+import org.ajax4jsf.framework.renderer.AjaxContainerRenderer;
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.renderer.HeaderResourceProducer;
+import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
+import org.ajax4jsf.framework.skin.Skin;
+import org.ajax4jsf.framework.skin.SkinFactory;
+import org.ajax4jsf.framework.skin.SkinNotFoundException;
+import org.ajax4jsf.framework.util.config.WebXml;
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This class incapsulated
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.7 $ $Date: 2007/02/08 19:07:16 $
+ *
+ */
+public class AjaxContext {
+ /**
+ * Key for keep request state information in request-scope attributes.
+ */
+ public static final String AJAX_CONTEXT_KEY = "ajaxContext";
+
+ public static final String SCRIPTS_PARAMETER = "org.ajax4jsf.framework.HEADER_SCRIPTS";
+
+ public static final String STYLES_PARAMETER = "org.ajax4jsf.framework.HEADER_STYLES";
+
+ public static final String RESOURCES_PROCESSED = "org.ajax4jsf.framework.HEADER_PROCESSED";
+
+ public static final String RESPONSE_DATA_KEY = "_ajax:data";
+
+ private static final Log log = LogFactory.getLog(AjaxContext.class);
+
+ private static ComponentInvoker invoker;
+
+ private static Map contextClasses = new HashMap();
+
+ Set ajaxAreasToRender = new HashSet();
+
+ Set ajaxRenderedAreas = new HashSet();
+
+ boolean ajaxRequest = false;
+
+ boolean ajaxRequestSet = false;
+
+ boolean selfRender = false;
+
+ Integer viewSequence = new Integer(1);
+
+ String submittedRegionClientId = null;
+
+ boolean submittedRegionSet = false;
+
+ ViewIdHolder viewIdHolder = null;
+
+ Map responseDataMap = new HashMap();
+
+ Map commonAjaxParameters = new HashMap();
+
+ static {
+ try {
+ // Attempt to create JSF1.2 specific invoker.
+ invoker = new JsfOneOneInvoker();
+ } catch (Exception e) {
+ invoker = new JsfOneOneInvoker();
+ }
+ }
+
+ /**
+ * Get instance of current AJAX Context. Instance get by
+ * {@link VariableResolver#resolveVariable(FacesContext, String)} for
+ * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
+ *
+ * @return memento instance for current request
+ */
+ public static AjaxContext getCurrentInstance() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ return getCurrentInstance(context);
+ }
+
+ /**
+ * Get instance of current AJAX Context. Instance get by
+ * {@link VariableResolver#resolveVariable(FacesContext, String)} for
+ * variable {@link AjaxContext#AJAX_CONTEXT_KEY}
+ *
+ * @param context
+ * current FacesContext
+ * @return instance of AjaxContext.
+ */
+ public static AjaxContext getCurrentInstance(FacesContext context) {
+ if (null == context) {
+ throw new NullPointerException("FacesContext is null");
+ }
+ AjaxContext ajaxContext = (AjaxContext) context.getApplication()
+ .getVariableResolver().resolveVariable(context,
+ AJAX_CONTEXT_KEY);
+ if (null == ajaxContext) {
+ // Create default implementation.
+ ajaxContext = new AjaxContext();
+ context.getExternalContext().getRequestMap().put(AJAX_CONTEXT_KEY,
+ ajaxContext);
+ }
+ return ajaxContext;
+ }
+
+ /**
+ * @param root
+ * @param context
+ * @param callback
+ * @param regionId
+ * @return
+ * @see org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnComponent(javax.faces.component.UIComponent,
+ * javax.faces.context.FacesContext,
+ * org.ajax4jsf.framework.ajax.InvokerCallback, java.lang.String)
+ */
+ public static boolean invokeOnComponent(UIComponent root,
+ FacesContext context, InvokerCallback callback, String regionId) {
+ return invoker.invokeOnComponent(root, context, callback, regionId);
+ }
+
+ /**
+ * @param viewRoot
+ * @param context
+ * @param callback
+ * @see org.ajax4jsf.framework.ajax.JsfOneOneInvoker#invokeOnRegionOrRoot(org.ajax4jsf.framework.ajax.AjaxViewRoot,
+ * javax.faces.context.FacesContext,
+ * org.ajax4jsf.framework.ajax.InvokerCallback)
+ */
+ public static void invokeOnRegionOrRoot(AjaxViewRoot viewRoot,
+ FacesContext context, InvokerCallback callback) {
+ invoker.invokeOnRegionOrRoot(viewRoot, context, callback);
+ }
+
+ private InvokerCallback _ajaxInvoker = new InvokerCallback() {
+
+ public void invoke(FacesContext context, UIComponent component) {
+ if (component instanceof AjaxContainer) {
+ AjaxContainer ajax = (AjaxContainer) component;
+ renderAjaxRegion(context, component, true);
+ } else {
+ // Container not found, use Root for encode.
+ renderAjaxRegion(context, context.getViewRoot(), true);
+ }
+ }
+
+ public void invokeRoot(FacesContext context) {
+ renderAjaxRegion(context, context.getViewRoot(), true);
+ }
+
+ };
+
+ public void renderSubmittedAjaxRegion(FacesContext context) {
+ renderSubmittedAjaxRegion(context, true);
+ }
+
+ public void renderSubmittedAjaxRegion(FacesContext context,
+ final boolean useFilterWriter) {
+ InvokerCallback ajaxInvoker = new InvokerCallback() {
+
+ public void invoke(FacesContext context, UIComponent component) {
+ if (component instanceof AjaxContainer) {
+ renderAjaxRegion(context, component, useFilterWriter);
+ } else {
+ // Container not found, use Root for encode.
+ renderAjaxRegion(context, context.getViewRoot(),
+ useFilterWriter);
+ }
+ }
+
+ public void invokeRoot(FacesContext context) {
+ renderAjaxRegion(context, context.getViewRoot(),
+ useFilterWriter);
+ }
+
+ };
+ if (!invokeOnComponent(context.getViewRoot(), context, ajaxInvoker,
+ getSubmittedRegionClientId(context))) {
+ renderAjaxRegion(context, context.getViewRoot(), useFilterWriter);
+ }
+
+ }
+
+ /**
+ * @param context
+ * @param useFilterWriter
+ * TODO
+ * @throws AbortProcessingException
+ */
+ public void renderAjaxRegion(FacesContext context, UIComponent component,
+ boolean useFilterWriter) throws FacesException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.RENDER_AJAX_REQUEST,
+ component.getId()));
+ }
+ try {
+ setSelfRender(true);
+ // create response writer.
+ ExternalContext extContext = context.getExternalContext();
+ RenderKit renderKit = context.getRenderKit();
+ String encoding;
+ // Depends if we talk about servlets, portlets, ...
+ if (extContext.getRequest() instanceof ServletRequest) {
+ ServletRequest request = (ServletRequest) extContext
+ .getRequest();
+ ServletResponse response = (ServletResponse) extContext
+ .getResponse();
+ // HACK - bypass MyFaces ( and other ) extensions filter.
+
+ // Setup encoding and content type
+ String contentType = "text/xml";
+ // get the encoding - must be setup by faces context or filter.
+ encoding = request.getCharacterEncoding();
+ if (encoding == null) {
+ encoding = "UTF-8";
+ }
+ response.setContentType(contentType + ";charset=" + encoding);
+ } else
+ encoding = "UTF-8";
+
+ PrintWriter servletWriter;
+ if (useFilterWriter
+ && extContext.getRequestMap().containsKey(
+ BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
+ // HACK - Special case for MyFaces, since <f:view don't call
+ // encode methods,
+ // encode response as for self-rendered region directly to
+ // filter response wrpper.
+ // to avoid exceptions, inform wrapper to ignore illegal states
+ // for getWriter/Stream.
+ ServletResponse servletResponse = (ServletResponse) extContext
+ .getRequestMap().get(
+ BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE);
+ servletResponse.resetBuffer();
+ servletWriter = servletResponse.getWriter();
+ ((FilterServletResponseWrapper) servletResponse)
+ .setUseNullStream(true);
+ } else {
+ servletWriter = getWriter(extContext);
+ }
+ ResponseWriter writer = renderKit.createResponseWriter(
+ servletWriter, null, encoding);
+ context.setResponseWriter(writer);
+ // make response
+ writer.startDocument();
+ encodeAjaxBegin(context, component);
+ component.encodeBegin(context);
+ ((AjaxContainer) component).encodeAjax(context);
+ component.encodeEnd(context);
+ saveViewState(context);
+ encodeAjaxEnd(context, component);
+ writer.endDocument();
+ writer.flush();
+ writer.close();
+ servletWriter.close();
+ // Save tree state.
+ } catch (IOException e) {
+ throw new FacesException(Messages.getMessage(
+ Messages.RENDERING_AJAX_REGION_ERROR, component
+ .getClientId(context)), e);
+ } finally {
+ context.responseComplete();
+ // component.setRendererType(defaultRenderer);
+ }
+ }
+
+ /**
+ * Encode declaration for AJAX response. Render <html><body>
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeAjaxBegin(FacesContext context, UIComponent component)
+ throws IOException {
+ // AjaxContainer ajax = (AjaxContainer) component;
+ ResponseWriter out = context.getResponseWriter();
+ // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
+ out.startElement(HTML.HTML_ELEMENT, component);
+ // TODO - html attributes. lang - from current locale ?
+ Locale locale = context.getViewRoot().getLocale();
+ out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
+ out.startElement(HTML.BODY_ELEMENT, component);
+ }
+
+ /**
+ * End encoding of AJAX response. Render tag with included areas and
+ * close </body></html>
+ *
+ * @param context
+ * @param component
+ * @throws IOException
+ */
+ public void encodeAjaxEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ // AjaxContainer ajax = (AjaxContainer) component;
+ ResponseWriter out = context.getResponseWriter();
+ // DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
+ out.endElement(HTML.BODY_ELEMENT);
+ out.endElement(HTML.HTML_ELEMENT);
+ }
+
+ /**
+ * @param context
+ * @param root
+ * @throws FacesException
+ */
+ public void processHeadResources(FacesContext context)
+ throws FacesException {
+ ExternalContext externalContext = context.getExternalContext();
+ Map requestMap = externalContext.getRequestMap();
+ if (!Boolean.TRUE.equals(requestMap.get(RESOURCES_PROCESSED))) {
+ if (null != requestMap.get(BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE)) {
+ if (log.isDebugEnabled()) {
+ log
+ .debug("Process component tree for collect used scripts and styles");
+ }
+ UIViewRoot root = context.getViewRoot();
+ Set scripts = new LinkedHashSet();
+ Set styles = new LinkedHashSet();
+ RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
+ .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ RenderKit renderKit = rkFactory.getRenderKit(context, context
+ .getViewRoot().getRenderKitId());
+ processHeadResources(context, root, scripts, styles, renderKit);
+ if (scripts.size() > 0) {
+ if (log.isDebugEnabled()) {
+ StringBuffer buff = new StringBuffer(
+ "Scripts for insert into head : \n");
+ for (Iterator iter = scripts.iterator(); iter.hasNext();) {
+ String script = (String) iter.next();
+ buff.append(script).append("\n");
+ }
+ log.debug(buff.toString());
+ }
+ requestMap.put(SCRIPTS_PARAMETER, scripts);
+ }
+ // Set default style sheet for current skin.
+ String styleSheetUri = null;
+ try {
+ styleSheetUri = (String) SkinFactory.getInstance().getSkin(
+ context).getParameter(context,
+ Skin.generalStyleSheet);
+ } catch (SkinNotFoundException e) {
+ log.warn("Current Skin is not found", e);
+ }
+ if (null != styleSheetUri) {
+ String resourceURL = context.getApplication()
+ .getViewHandler().getResourceURL(context,
+ styleSheetUri);
+ // TODO - some resources can be non-session aware, we
+ // must
+ // skip encoding for this case ?
+ // But, in common case - static links not need session
+ // info,
+ // and dynamic resources perform encodings if nessesary
+ // resourceURL =
+ // context.getExternalContext().encodeResourceURL(resourceURL);
+ styles.add(resourceURL);
+ }
+ if (styles.size() > 0) {
+ if (log.isDebugEnabled()) {
+ StringBuffer buff = new StringBuffer(
+ "Styles for insert into head : \n");
+ for (Iterator iter = styles.iterator(); iter.hasNext();) {
+ String style = (String) iter.next();
+ buff.append(style).append("\n");
+ }
+ log.debug(buff.toString());
+ }
+ requestMap.put(STYLES_PARAMETER, styles);
+ }
+ // Mark as processed.
+ requestMap.put(RESOURCES_PROCESSED, Boolean.TRUE);
+ }
+
+ }
+ }
+
+ /**
+ * Append nessesary scripts and styles from component ( if renderer
+ * implements {@link HeaderResourceProducer}) and recursive process all
+ * facets and childrens.
+ *
+ * @param context
+ * TODO
+ * @param root
+ * @param scripts
+ * @param styles
+ * @param renderKit
+ * TODO
+ */
+ private void processHeadResources(FacesContext context, UIComponent root,
+ Set scripts, Set styles, RenderKit renderKit) {
+ Renderer renderer = getRenderer(context, root, renderKit);
+ if (null != renderer) {
+ if (renderer instanceof HeaderResourceProducer) {
+ HeaderResourceProducer producer = (HeaderResourceProducer) renderer;
+ Set set = producer.getHeaderScripts(context, root);
+ if (null != set) {
+ scripts.addAll(set);
+ }
+ set = producer.getHeaderStyles(context, root);
+ if (null != set) {
+ styles.addAll(set);
+ }
+ }
+ }
+ for (Iterator iter = root.getFacets().values().iterator(); iter
+ .hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ processHeadResources(context, child, scripts, styles, renderKit);
+ }
+ for (Iterator iter = root.getChildren().iterator(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ processHeadResources(context, child, scripts, styles, renderKit);
+ }
+ }
+
+ /**
+ * Find renderer for given component.
+ *
+ * @param context
+ * @param comp
+ * @param renderKit
+ * @return
+ */
+ private Renderer getRenderer(FacesContext context, UIComponent comp,
+ RenderKit renderKit) {
+
+ String rendererType = comp.getRendererType();
+ if (rendererType != null) {
+ return (renderKit.getRenderer(comp.getFamily(), rendererType));
+ } else {
+ return (null);
+ }
+
+ }
+
+ public void saveViewState(FacesContext context) throws IOException {
+ // TODO - for facelets environment, we need to remove transient
+ // components.
+ try {
+ Application.class.getMethod("getExpressionFactory", null);
+ } catch (NoSuchMethodException e) {
+ // JSF 1.1 !
+ }
+ ResponseWriter writer = context.getResponseWriter();
+ StateManager stateManager = context.getApplication().getStateManager();
+ SerializedView serializedView = stateManager
+ .saveSerializedView(context);
+ if (null != serializedView) {
+ StringWriter bufWriter = new StringWriter();
+ ResponseWriter cloneWithWriter = writer.cloneWithWriter(bufWriter);
+ context.setResponseWriter(cloneWithWriter);
+ stateManager.writeState(context, serializedView);
+ cloneWithWriter.flush();
+ if (bufWriter.getBuffer().length() > 0) {
+ context.getExternalContext().getRequestMap().put(
+ AjaxViewHandler.SERIALIZED_STATE_KEY,
+ bufWriter.toString());
+ }
+ // Restore original writer.
+ context.setResponseWriter(writer);
+ }
+ }
+
+ /**
+ * @return Returns the ajaxRequest.
+ */
+ public boolean isAjaxRequest() {
+ return isAjaxRequest(FacesContext.getCurrentInstance());
+ }
+
+ /**
+ * @return Returns the ajaxRequest.
+ */
+ public boolean isAjaxRequest(FacesContext context) {
+ if (!this.ajaxRequestSet) {
+ ajaxRequest = null != getSubmittedRegionClientId(context);
+ ajaxRequestSet = true;
+ }
+ return ajaxRequest;
+ }
+
+ /**
+ * @param ajaxRequest
+ * The ajaxRequest to set.
+ */
+ public void setAjaxRequest(boolean ajaxRequest) {
+ this.ajaxRequest = ajaxRequest;
+ this.ajaxRequestSet = true;
+ }
+
+ /**
+ * @return Returns the ajaxAreasToRender.
+ */
+ public Set getAjaxAreasToRender() {
+ return this.ajaxAreasToRender;
+ }
+
+ /**
+ * Add affected regions's ID to ajaxView component.
+ *
+ * @param component
+ */
+ public void addRegionsFromComponent(UIComponent component) {
+ // First step - find parent ajax view
+ Set ajaxRegions = AjaxRendererUtils.getAjaxAreas(component);
+ // if (ajaxRegions == null){
+ // FacesContext context = FacesContext.getCurrentInstance();
+ // ajaxRegions = AjaxRendererUtils.getAbsoluteId(context,component);
+ // }
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.INVOKE_AJAX_REGION_LISTENER,
+ component.getId()));
+ }
+ if (ajaxRegions != null) {
+ for (Iterator iter = ajaxRegions.iterator(); iter.hasNext();) {
+ String id = iter.next().toString();
+ ajaxAreasToRender.add(convertId(component, id));
+ }
+ }
+ }
+
+ public void addComponentToAjaxRender(UIComponent component) {
+ this.ajaxAreasToRender.add(AjaxRendererUtils.getAbsoluteId(component));
+ }
+
+ public void addComponentToAjaxRender(UIComponent base, String id) {
+ this.ajaxAreasToRender.add(convertId(base, id));
+ }
+
+ /**
+ * Test for relative id of target components. Attempt convert to
+ * absolute. For use as argument for
+ * {@link UIComponent#findComponent(java.lang.String)}
+ *
+ * @param component
+ * @param id
+ * @return
+ */
+ private String convertId(UIComponent component, String id) {
+ if (id.charAt(0) == NamingContainer.SEPARATOR_CHAR) {
+ return id;
+ }
+ if (null == component) {
+ throw new NullPointerException(
+ "Base component for search re-rendered compnnent is null");
+ }
+ UIComponent target = null;
+ UIComponent parent = component;
+ UIComponent root = component;
+ while (null == target && null != parent) {
+ target = parent.findComponent(id);
+ root = parent;
+ parent = parent.getParent();
+ }
+ if (null == target) {
+ target = findUIComponentBelow(root, id);
+ }
+ if (null != target) {
+ return AjaxRendererUtils.getAbsoluteId(target);
+ }
+ log.warn("Target component for id "+id+" not found");
+ return id;
+ }
+
+ private UIComponent findUIComponentBelow(UIComponent root,
+ String id) {
+
+ UIComponent target = null;
+ for (Iterator iter = root.getFacetsAndChildren(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ if (child instanceof NamingContainer) {
+ try {
+ target = child.findComponent(id);
+ } catch (IllegalArgumentException iae) {
+ continue;
+ }
+ }
+ if (target == null) {
+ if (child.getChildCount() > 0) {
+ target = findUIComponentBelow(child, id);
+ }
+ }
+
+ if (target != null) {
+ break;
+ }
+
+ }
+ return target;
+ }
+
+ /**
+ * @return Returns the ajaxRenderedAreas.
+ */
+ public Set getAjaxRenderedAreas() {
+ return ajaxRenderedAreas;
+ }
+
+ public void addRenderedArea(String id) {
+ ajaxRenderedAreas.add(id);
+ }
+
+ public boolean removeRenderedArea(String id) {
+ return ajaxRenderedAreas.remove(id);
+ }
+
+ /**
+ * @return Returns the submittedClientId.
+ */
+ public String getSubmittedRegionClientId(FacesContext context) {
+ if (!this.submittedRegionSet) {
+ this.submittedRegionClientId = (String) context
+ .getExternalContext().getRequestParameterMap().get(
+ AjaxContainerRenderer.AJAX_PARAMETER_NAME);
+ this.submittedRegionSet = true;
+ if (!this.ajaxRequestSet) {
+ setAjaxRequest(this.submittedRegionClientId != null);
+ }
+ }
+ return this.submittedRegionClientId;
+ }
+
+ /**
+ * @param submittedClientId
+ * The submittedClientId to set.
+ */
+ public void setSubmittedRegionClientId(String submittedClientId) {
+ this.submittedRegionClientId = submittedClientId;
+ this.submittedRegionSet = true;
+ }
+
+ /**
+ * @return Returns the selfRender.
+ */
+ public boolean isSelfRender() {
+ return selfRender;
+ }
+
+ /**
+ * @param selfRender
+ * The selfRender to set.
+ */
+ public void setSelfRender(boolean selfRender) {
+ this.selfRender = selfRender;
+ }
+
+ /**
+ * @return the vievIdHolder
+ */
+ public ViewIdHolder getViewIdHolder() {
+ return viewIdHolder;
+ }
+
+ /**
+ * @param viewIdHolder
+ * the vievIdHolder to set
+ */
+ public void setViewIdHolder(ViewIdHolder viewIdHolder) {
+ this.viewIdHolder = viewIdHolder;
+ }
+
+ /**
+ * @return the responseData
+ */
+ public Object getResponseData() {
+ return responseDataMap.get(RESPONSE_DATA_KEY);
+ }
+
+ /**
+ * @param responseData
+ * the responseData to set
+ */
+ public void setResponseData(Object responseData) {
+ this.responseDataMap.put(RESPONSE_DATA_KEY, responseData);
+ }
+
+ /**
+ * @return the responseDataMap
+ */
+ public Map getResponseDataMap() {
+ return responseDataMap;
+ }
+
+ /**
+ * Gives back the writer of a Response object.
+ *
+ * @param extContext
+ * The external context.
+ * @return The writer of the response.
+ * @throws FacesException
+ * If the response object has no getWriter() method.
+ */
+ protected PrintWriter getWriter(ExternalContext extContext)
+ throws FacesException {
+ PrintWriter writer = null;
+ Object response = extContext.getResponse();
+ try {
+ Method gW = response.getClass()
+ .getMethod("getWriter", new Class[0]);
+ writer = (PrintWriter) gW.invoke(response, new Object[0]);
+ } catch (Exception e) {
+ throw new FacesException(e);
+ }
+ return writer;
+ }
+
+ public String getAjaxActionURL() {
+ return getAjaxActionURL(FacesContext.getCurrentInstance());
+ }
+
+ public String getAjaxActionURL(FacesContext context) {
+ // Check arguments
+ if (null == context) {
+ throw new NullPointerException(
+ "Faces context for build AJAX Action URL is null");
+ }
+ UIViewRoot viewRoot = context.getViewRoot();
+ if (null == viewRoot) {
+ throw new NullPointerException(
+ "Faces view tree for build AJAX Action URL is null");
+ }
+ String viewId = viewRoot.getViewId();
+ if (null == viewId) {
+ throw new NullPointerException(
+ "View id for build AJAX Action URL is null");
+ }
+ if (!viewId.startsWith("/")) {
+ throw new IllegalArgumentException(
+ "Illegal view Id for build AJAX Action URL: " + viewId);
+ }
+ ViewHandler viewHandler = context.getApplication().getViewHandler();
+ return context.getExternalContext().encodeActionURL(
+ viewHandler.getActionURL(context, viewId));
+ }
+
+ /**
+ * @return the commonAjaxParameters
+ */
+ public Map getCommonAjaxParameters() {
+ return commonAjaxParameters;
+ }
+
+}
\ No newline at end of file
Deleted: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java 2007-06-29 17:01:45 UTC (rev 1414)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java 2007-06-29 17:10:57 UTC (rev 1415)
@@ -1,98 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.resource;
-
-import java.awt.Dimension;
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:06 $
- *
- */
-public abstract class ImageRenderer extends BaseResourceRenderer {
-
- private static final String _tag = "img";
- private static final String _hrefAttr = "src";
- private static final String[][] _commonAttrs = {
-
- };
- /**
- * @return Returns the commonAttrs.
- */
- protected String[][] getCommonAttrs() {
- return null ; //_commonAttrs;
- }
-
- /**
- * @return Returns the hrefAttr.
- */
- protected String getHrefAttr() {
- return _hrefAttr;
- }
-
- /**
- * @return Returns the tag.
- */
- protected String getTag() {
- return _tag;
- }
-
- /**
- * Send {@link BufferedImage} to response in concrete format (GIF,Jpeg,PNG)
- * @param context - current faces context.
- * @param image - imaje to send
- */
- public abstract void sendImage(ResourceContext context,RenderedImage image) throws IOException;
-
- /**
- * @return type of image for create {@link BufferedImage}
- */
- public abstract int getImageType();
-
- /**
- * Create blank {@link BufferedImage} for paint.
- * Type of image determined by current renderer.
- * @param width
- * @param height
- * @return new image
- */
- public BufferedImage createImage(int width,int height){
- return new BufferedImage(width,height,getImageType());
- }
-
- protected void customEncode(InternetResource resource, FacesContext context, Object data) throws IOException {
- if (resource instanceof Java2Dresource) {
- Java2Dresource j2d = (Java2Dresource) resource;
- Dimension dim = j2d.getDimensions(context, data);
- ResponseWriter writer = context.getResponseWriter();
- writer.writeAttribute("width", String.valueOf(dim.width), "width");
- writer.writeAttribute("height", String.valueOf(dim.height), "height");
- }
- }
-}
Deleted: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleEvent.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleEvent.java 2007-06-29 17:01:45 UTC (rev 1414)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleEvent.java 2007-06-29 17:10:57 UTC (rev 1415)
@@ -1,40 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.framework.ajax;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-import javax.faces.event.PhaseId;
-
-/**
- * @author asmirnov
- *
- */
-public class AjaxSingleEvent extends FacesEvent {
-
- /**
- * @param arg0
- */
- public AjaxSingleEvent(UIComponent arg0) {
- super(arg0);
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
- */
- public boolean isAppropriateListener(FacesListener arg0) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
- */
- public void processListener(FacesListener arg0) {
- }
-
- public PhaseId getPhaseId() {
- return PhaseId.APPLY_REQUEST_VALUES;
- }
-}
Deleted: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleException.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleException.java 2007-06-29 17:01:45 UTC (rev 1414)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleException.java 2007-06-29 17:10:57 UTC (rev 1415)
@@ -1,31 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.framework.ajax;
-
-import javax.faces.component.UIComponent;
-
-/**
- * @author asmirnov
- *
- */
-public class AjaxSingleException extends RuntimeException {
-
- private UIComponent component;
-
- /**
- * @param component
- */
- public AjaxSingleException(UIComponent componemt) {
-// super();
- this.component = componemt;
- }
-
- /**
- * @return the component
- */
- public UIComponent getComponent() {
- return component;
- }
-
-}
Copied: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java (from rev 1393, branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java)
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java (rev 0)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/resource/ImageRenderer.java 2007-06-29 17:10:57 UTC (rev 1415)
@@ -0,0 +1,98 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.resource;
+
+import java.awt.Dimension;
+import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:57:06 $
+ *
+ */
+public abstract class ImageRenderer extends BaseResourceRenderer {
+
+ private static final String _tag = "img";
+ private static final String _hrefAttr = "src";
+ private static final String[][] _commonAttrs = {
+
+ };
+ /**
+ * @return Returns the commonAttrs.
+ */
+ protected String[][] getCommonAttrs() {
+ return null ; //_commonAttrs;
+ }
+
+ /**
+ * @return Returns the hrefAttr.
+ */
+ protected String getHrefAttr() {
+ return _hrefAttr;
+ }
+
+ /**
+ * @return Returns the tag.
+ */
+ protected String getTag() {
+ return _tag;
+ }
+
+ /**
+ * Send {@link BufferedImage} to response in concrete format (GIF,Jpeg,PNG)
+ * @param context - current faces context.
+ * @param image - imaje to send
+ */
+ public abstract void sendImage(ResourceContext context,RenderedImage image) throws IOException;
+
+ /**
+ * @return type of image for create {@link BufferedImage}
+ */
+ public abstract int getImageType();
+
+ /**
+ * Create blank {@link BufferedImage} for paint.
+ * Type of image determined by current renderer.
+ * @param width
+ * @param height
+ * @return new image
+ */
+ public BufferedImage createImage(int width,int height){
+ return new BufferedImage(width,height,getImageType());
+ }
+
+ protected void customEncode(InternetResource resource, FacesContext context, Object data) throws IOException {
+ if (resource instanceof Java2Dresource) {
+ Java2Dresource j2d = (Java2Dresource) resource;
+ Dimension dim = j2d.getDimensions(context, data);
+ ResponseWriter writer = context.getResponseWriter();
+ writer.writeAttribute("width", String.valueOf(dim.width), "width");
+ writer.writeAttribute("height", String.valueOf(dim.height), "height");
+ }
+ }
+}
17 years, 2 months
JBoss Rich Faces SVN: r1414 - in branches/refactor1/framework/api/src/main/java/org/ajax4jsf: framework/ajax and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-06-29 13:01:45 -0400 (Fri, 29 Jun 2007)
New Revision: 1414
Added:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleEvent.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleException.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/message/
Modified:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/AjaxSubmitFunction.java
Log:
continue refactoring
Modified: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java 2007-06-29 16:49:34 UTC (rev 1413)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java 2007-06-29 17:01:45 UTC (rev 1414)
@@ -362,7 +362,8 @@
AjaxRenderer childrenRenderer = (AjaxRenderer) renderer;
childrenRenderer.encodeAjaxChildren(context, this, path, ids,
renderedAreas);
- } else {
+ }
+ /*else {
// Use simple ajax children encoding for iterate other keys.
final AjaxRenderer childrenRenderer = getChildrenRenderer();
final String childrenPath = path + getId() + NamingContainer.SEPARATOR_CHAR;
@@ -394,7 +395,7 @@
} else {
iterate(context, ajaxVisitor, null);
}
- }
+ }*/
}
/**
@@ -410,21 +411,21 @@
*
* @return
*/
- protected AjaxRenderer getChildrenRenderer() {
- if (_childrenRenderer == null) {
- _childrenRenderer = new AjaxChildrenRenderer() {
+// protected AjaxRenderer getChildrenRenderer() {
+// if (_childrenRenderer == null) {
+// _childrenRenderer = new AjaxChildrenRenderer() {
+//
+// protected Class getComponentClass() {
+// return UIDataAdaptor.class;
+// }
+//
+// };
+//
+// }
+//
+// return _childrenRenderer;
+// }
- protected Class getComponentClass() {
- return UIDataAdaptor.class;
- }
-
- };
-
- }
-
- return _childrenRenderer;
- }
-
/**
* @return Set of values for clientId's of this component, for wich was
* invoked "encode" methods.
Modified: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java 2007-06-29 16:49:34 UTC (rev 1413)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxActionComponent.java 2007-06-29 17:01:45 UTC (rev 1414)
@@ -29,7 +29,6 @@
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
/**
* @author shura (latest modification by $Author: alexsmirnov $)
Copied: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleEvent.java (from rev 1393, branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleEvent.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleEvent.java (rev 0)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleEvent.java 2007-06-29 17:01:45 UTC (rev 1414)
@@ -0,0 +1,40 @@
+/**
+ *
+ */
+package org.ajax4jsf.framework.ajax;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+import javax.faces.event.PhaseId;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class AjaxSingleEvent extends FacesEvent {
+
+ /**
+ * @param arg0
+ */
+ public AjaxSingleEvent(UIComponent arg0) {
+ super(arg0);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ public boolean isAppropriateListener(FacesListener arg0) {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ public void processListener(FacesListener arg0) {
+ }
+
+ public PhaseId getPhaseId() {
+ return PhaseId.APPLY_REQUEST_VALUES;
+ }
+}
Copied: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleException.java (from rev 1393, branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleException.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleException.java (rev 0)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/ajax/AjaxSingleException.java 2007-06-29 17:01:45 UTC (rev 1414)
@@ -0,0 +1,31 @@
+/**
+ *
+ */
+package org.ajax4jsf.framework.ajax;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class AjaxSingleException extends RuntimeException {
+
+ private UIComponent component;
+
+ /**
+ * @param component
+ */
+ public AjaxSingleException(UIComponent componemt) {
+// super();
+ this.component = componemt;
+ }
+
+ /**
+ * @return the component
+ */
+ public UIComponent getComponent() {
+ return component;
+ }
+
+}
Modified: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/AjaxSubmitFunction.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/AjaxSubmitFunction.java 2007-06-29 16:49:34 UTC (rev 1413)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/javascript/AjaxSubmitFunction.java 2007-06-29 17:01:45 UTC (rev 1414)
@@ -26,7 +26,6 @@
import javax.faces.component.UIComponent;
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -57,7 +56,7 @@
*/
public static final String LIMITTOLIST_ATTR_NAME = "limitToList";
- private static Log log = LogFactory.getLog(AjaxRendererUtils.class);
+ private static Log log = LogFactory.getLog(AjaxSubmitFunction.class);
public static final String AJAX_REGIONS_ATTRIBUTE = "reRender";
Copied: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/util/message (from rev 1393, branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/util/message)
17 years, 2 months
JBoss Rich Faces SVN: r1413 - in branches/refactor1/framework: impl/src/main/java/org/ajax4jsf/dnd and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-06-29 12:49:34 -0400 (Fri, 29 Jun 2007)
New Revision: 1413
Added:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java
Removed:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/DnDScript.java
Log:
move DnDScript to implementation
Deleted: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/DnDScript.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/DnDScript.java 2007-06-29 16:41:58 UTC (rev 1412)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/DnDScript.java 2007-06-29 16:49:34 UTC (rev 1413)
@@ -1,46 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.dnd;
-
-import org.ajax4jsf.framework.resource.ClientScript;
-
-/**
- * @author shura
- *
- */
-public class DnDScript extends ClientScript {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.resource.ClientScript#getJavaScript()
- */
- public String getJavaScript() {
- return "/org/ajax4jsf/framework/ajax/scripts/dnd.js";
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.framework.resource.ClientScript#isUsePrototype()
- */
- protected boolean isUsePrototype() {
- return true;
- }
-
-}
Copied: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java (from rev 1393, branches/refactor1/framework/api/src/main/java/org/ajax4jsf/dnd/DnDScript.java)
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java (rev 0)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/dnd/DnDScript.java 2007-06-29 16:49:34 UTC (rev 1413)
@@ -0,0 +1,46 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.dnd;
+
+import org.ajax4jsf.framework.resource.ClientScript;
+
+/**
+ * @author shura
+ *
+ */
+public class DnDScript extends ClientScript {
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.ClientScript#getJavaScript()
+ */
+ public String getJavaScript() {
+ return "/org/ajax4jsf/framework/ajax/scripts/dnd.js";
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.resource.ClientScript#isUsePrototype()
+ */
+ protected boolean isUsePrototype() {
+ return true;
+ }
+
+}
17 years, 2 months
JBoss Rich Faces SVN: r1412 - in branches/refactor1/framework: api/src/main/java/org/ajax4jsf/framework/renderer and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-06-29 12:41:58 -0400 (Fri, 29 Jun 2007)
New Revision: 1412
Added:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/AjaxRenderer.java
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java
Removed:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java
Modified:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
Log:
Exstract AjaxRenderer interface
Modified: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java 2007-06-29 16:37:49 UTC (rev 1411)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java 2007-06-29 16:41:58 UTC (rev 1412)
@@ -48,6 +48,7 @@
import javax.faces.render.Renderer;
import org.ajax4jsf.framework.renderer.AjaxChildrenRenderer;
+import org.ajax4jsf.framework.renderer.AjaxRenderer;
/**
* Base class for iterable components, like dataTable, Tomahawk dataList,
@@ -356,14 +357,14 @@
resetDataModel();
Renderer renderer = getRenderer(context);
- if (null != renderer && renderer instanceof AjaxChildrenRenderer) {
+ if (null != renderer && renderer instanceof AjaxRenderer) {
// If renderer support partial encoding - call them.
- AjaxChildrenRenderer childrenRenderer = (AjaxChildrenRenderer) renderer;
+ AjaxRenderer childrenRenderer = (AjaxRenderer) renderer;
childrenRenderer.encodeAjaxChildren(context, this, path, ids,
renderedAreas);
} else {
// Use simple ajax children encoding for iterate other keys.
- final AjaxChildrenRenderer childrenRenderer = getChildrenRenderer();
+ final AjaxRenderer childrenRenderer = getChildrenRenderer();
final String childrenPath = path + getId() + NamingContainer.SEPARATOR_CHAR;
ComponentVisitor ajaxVisitor = new ComponentVisitor() {
@@ -399,7 +400,7 @@
/**
* Instance of default renderer in ajax responses.
*/
- private AjaxChildrenRenderer _childrenRenderer = null;
+ private AjaxRenderer _childrenRenderer = null;
/**
* getter for simple {@link AjaxChildrenRenderer} instance in case of
@@ -409,7 +410,7 @@
*
* @return
*/
- protected AjaxChildrenRenderer getChildrenRenderer() {
+ protected AjaxRenderer getChildrenRenderer() {
if (_childrenRenderer == null) {
_childrenRenderer = new AjaxChildrenRenderer() {
Deleted: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java 2007-06-29 16:37:49 UTC (rev 1411)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java 2007-06-29 16:41:58 UTC (rev 1412)
@@ -1,205 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.ajax.UILoadBundle;
-import org.ajax4jsf.framework.ajax.AjaxChildrenEncoder;
-import org.ajax4jsf.framework.ajax.AjaxOutput;
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author shura
- *
- */
-public abstract class AjaxChildrenRenderer extends AjaxComponentRendererBase {
-
- public static final Log log = LogFactory.getLog(AjaxChildrenRenderer.class);
-
- public static final String[] SPECIAL_COMPONENTS_TYPES = {
- UILoadBundle.COMPONENT_TYPE, "org.apache.myfaces.AliasBean",
- "org.apache.myfaces.AliasBeansScope" };
- private static final String SPECIAL_TYPES_PARAMETER = "org.ajax4jsf.CONTROL_COMPONENTS";
-
- /**
- * Iterate over all childs of components. If component id contains in list ,
- * or, if list is empty, compotents is submitted form - render it. TODO -
- * Instead of calculate full path for every component, build current Path
- * for componet and send as parameter.
- *
- * @param context -
- * current context
- * @param component -
- * curent faces component.
- * @param ids -
- * list of Id to render.
- * @throws IOException
- * @deprecated Use {@link #encodeAjaxChildren(FacesContext,UIComponent,String,Set,Set)} instead
- */
- public void encodeAjaxChild(FacesContext context, UIComponent component, String path, Set ids, Set renderedAreas) throws IOException {
- encodeAjaxChildren(context, component, path, ids, renderedAreas);
- }
-
- /**
- * Iterate over all childs of components. If component id contains in list ,
- * or, if list is empty, compotents is submitted form - render it. TODO -
- * Instead of calculate full path for every component, build current Path
- * for componet and send as parameter.
- *
- * @param context -
- * current context
- * @param component -
- * curent faces component.
- * @param ids -
- * list of Id to render.
- * @throws IOException
- */
- public void encodeAjaxChildren(FacesContext context, UIComponent component, String path, Set ids, Set renderedAreas) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODE_CHILD_AJAX_INFO,
- path, component.getId()));
- }
- String currentPath = path;
- if (component instanceof NamingContainer) {
- currentPath += component.getId() + NamingContainer.SEPARATOR_CHAR;
- }
- for (Iterator it = component.getFacetsAndChildren(); it.hasNext();) {
- UIComponent element = (UIComponent) it.next();
- encodeAjaxComponent(context, element, currentPath, ids, renderedAreas);
- }
- }
-
- /**
- * @param context
- * @param component
- * @param currentPath
- * @param ids
- * @param renderedAreas
- * @throws IOException
- */
- public void encodeAjaxComponent(FacesContext context, UIComponent component, String currentPath, Set ids, Set renderedAreas) throws IOException {
- if (component.isRendered()) { // skip not-rendered components.
- boolean found = false;
- if (!ids.isEmpty()) {
- // list for rendering may contains absolute id ( best ),
- // component Id or client ID
- String elementId = component.getId();
- String absoluteId = currentPath + elementId;
- // String clientId = element.getClientId(context);
- if (ids.contains(absoluteId) || ids.contains(elementId)) {
- if (log.isDebugEnabled()) {
- log
- .debug(Messages.getMessage(
- Messages.RENDER_AJAX_AREA_INFO,
- absoluteId));
- }
- // renderChild(context, element);
- found = true;
- }
- }
- if (!found && component instanceof AjaxOutput) {
- if (((AjaxOutput) component).isAjaxRendered()) {
- // renderChild(context, element);
- found = true;
- }
-
- }
-
- if (!found) {
- if (component instanceof AjaxChildrenEncoder) {
- ((AjaxChildrenEncoder) component).encodeAjaxChild(
- context, currentPath, ids, renderedAreas);
- } else {
- // Special case - for control components, not produced
- // html code - such as message bundles loaders,
- // MyFaces aliases etc. we call encodeBegin/end methods
- // even if components not in rendered areas.
- boolean special = isSpecialElement(context, component);
- if (special) {
- component.encodeBegin(context);
- }
- encodeAjaxChildren(context, component, currentPath, ids,
- renderedAreas);
- if (special) {
- component.encodeEnd(context);
- }
-
- }
- } else {
- renderedAreas.add(component.getClientId(context));
- renderChild(context, component);
- }
- }
- }
-
- private Set _specialComponentTypes = null;
-
- /**
- * Detect component as special control case - such as messages bundle
- * loader, alias bean components etc. Type of component get by reflection
- * from static field COMPONENT_TYPE
- *
- * @param context
- * @param component
- * @return true if encode methods must be called for this component even in
- * not-rendered parts.
- */
- private boolean isSpecialElement(FacesContext context, UIComponent component) {
- if (_specialComponentTypes == null) {
- _specialComponentTypes = new HashSet(10);
- for (int i = 0; i < SPECIAL_COMPONENTS_TYPES.length; i++) {
- _specialComponentTypes.add(SPECIAL_COMPONENTS_TYPES[i]);
- }
- String special = context.getExternalContext().getInitParameter(
- SPECIAL_TYPES_PARAMETER);
- if (null != special) {
- String[] split = special.split(",");
- for (int i = 0; i < split.length; i++) {
- _specialComponentTypes.add(split[i]);
- }
- }
- }
- boolean result;
- try {
- String componentType = (String) component.getClass().getField(
- "COMPONENT_TYPE").get(null);
- result = _specialComponentTypes.contains(componentType);
- } catch (Exception e) {
- // exception occurs if component not have accesible COMPONENT_TYPE
- // constant
- // we assume that component not in special types.
- result = false;
- }
- return result;
- }
-
-}
Added: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/AjaxRenderer.java
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/AjaxRenderer.java (rev 0)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/AjaxRenderer.java 2007-06-29 16:41:58 UTC (rev 1412)
@@ -0,0 +1,40 @@
+package org.ajax4jsf.framework.renderer;
+
+import java.io.IOException;
+import java.util.Set;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+public interface AjaxRenderer {
+
+ /**
+ * Iterate over all childs of components. If component id contains in list ,
+ * or, if list is empty, compotents is submitted form - render it. TODO -
+ * Instead of calculate full path for every component, build current Path
+ * for componet and send as parameter.
+ *
+ * @param context -
+ * current context
+ * @param component -
+ * curent faces component.
+ * @param ids -
+ * list of Id to render.
+ * @throws IOException
+ */
+ public void encodeAjaxChildren(FacesContext context, UIComponent component,
+ String path, Set ids, Set renderedAreas) throws IOException;
+
+ /**
+ * @param context
+ * @param component
+ * @param currentPath
+ * @param ids
+ * @param renderedAreas
+ * @throws IOException
+ */
+ public void encodeAjaxComponent(FacesContext context,
+ UIComponent component, String currentPath, Set ids,
+ Set renderedAreas) throws IOException;
+
+}
\ No newline at end of file
Copied: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java (from rev 1411, branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java)
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java (rev 0)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java 2007-06-29 16:41:58 UTC (rev 1412)
@@ -0,0 +1,189 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.renderer;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.ajax.UILoadBundle;
+import org.ajax4jsf.framework.ajax.AjaxChildrenEncoder;
+import org.ajax4jsf.framework.ajax.AjaxOutput;
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author shura
+ *
+ */
+public abstract class AjaxChildrenRenderer extends AjaxComponentRendererBase implements AjaxRenderer {
+
+ public static final Log log = LogFactory.getLog(AjaxChildrenRenderer.class);
+
+ public static final String[] SPECIAL_COMPONENTS_TYPES = {
+ UILoadBundle.COMPONENT_TYPE, "org.apache.myfaces.AliasBean",
+ "org.apache.myfaces.AliasBeansScope" };
+ private static final String SPECIAL_TYPES_PARAMETER = "org.ajax4jsf.CONTROL_COMPONENTS";
+
+ /**
+ * Iterate over all childs of components. If component id contains in list ,
+ * or, if list is empty, compotents is submitted form - render it. TODO -
+ * Instead of calculate full path for every component, build current Path
+ * for componet and send as parameter.
+ *
+ * @param context -
+ * current context
+ * @param component -
+ * curent faces component.
+ * @param ids -
+ * list of Id to render.
+ * @throws IOException
+ * @deprecated Use {@link #encodeAjaxChildren(FacesContext,UIComponent,String,Set,Set)} instead
+ */
+ public void encodeAjaxChild(FacesContext context, UIComponent component, String path, Set ids, Set renderedAreas) throws IOException {
+ encodeAjaxChildren(context, component, path, ids, renderedAreas);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.renderer.AjaxRenderer#encodeAjaxChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String, java.util.Set, java.util.Set)
+ */
+ public void encodeAjaxChildren(FacesContext context, UIComponent component, String path, Set ids, Set renderedAreas) throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODE_CHILD_AJAX_INFO,
+ path, component.getId()));
+ }
+ String currentPath = path;
+ if (component instanceof NamingContainer) {
+ currentPath += component.getId() + NamingContainer.SEPARATOR_CHAR;
+ }
+ for (Iterator it = component.getFacetsAndChildren(); it.hasNext();) {
+ UIComponent element = (UIComponent) it.next();
+ encodeAjaxComponent(context, element, currentPath, ids, renderedAreas);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.framework.renderer.AjaxRenderer#encodeAjaxComponent(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String, java.util.Set, java.util.Set)
+ */
+ public void encodeAjaxComponent(FacesContext context, UIComponent component, String currentPath, Set ids, Set renderedAreas) throws IOException {
+ if (component.isRendered()) { // skip not-rendered components.
+ boolean found = false;
+ if (!ids.isEmpty()) {
+ // list for rendering may contains absolute id ( best ),
+ // component Id or client ID
+ String elementId = component.getId();
+ String absoluteId = currentPath + elementId;
+ // String clientId = element.getClientId(context);
+ if (ids.contains(absoluteId) || ids.contains(elementId)) {
+ if (log.isDebugEnabled()) {
+ log
+ .debug(Messages.getMessage(
+ Messages.RENDER_AJAX_AREA_INFO,
+ absoluteId));
+ }
+ // renderChild(context, element);
+ found = true;
+ }
+ }
+ if (!found && component instanceof AjaxOutput) {
+ if (((AjaxOutput) component).isAjaxRendered()) {
+ // renderChild(context, element);
+ found = true;
+ }
+
+ }
+
+ if (!found) {
+ if (component instanceof AjaxChildrenEncoder) {
+ ((AjaxChildrenEncoder) component).encodeAjaxChild(
+ context, currentPath, ids, renderedAreas);
+ } else {
+ // Special case - for control components, not produced
+ // html code - such as message bundles loaders,
+ // MyFaces aliases etc. we call encodeBegin/end methods
+ // even if components not in rendered areas.
+ boolean special = isSpecialElement(context, component);
+ if (special) {
+ component.encodeBegin(context);
+ }
+ encodeAjaxChildren(context, component, currentPath, ids,
+ renderedAreas);
+ if (special) {
+ component.encodeEnd(context);
+ }
+
+ }
+ } else {
+ renderedAreas.add(component.getClientId(context));
+ renderChild(context, component);
+ }
+ }
+ }
+
+ private Set _specialComponentTypes = null;
+
+ /**
+ * Detect component as special control case - such as messages bundle
+ * loader, alias bean components etc. Type of component get by reflection
+ * from static field COMPONENT_TYPE
+ *
+ * @param context
+ * @param component
+ * @return true if encode methods must be called for this component even in
+ * not-rendered parts.
+ */
+ private boolean isSpecialElement(FacesContext context, UIComponent component) {
+ if (_specialComponentTypes == null) {
+ _specialComponentTypes = new HashSet(10);
+ for (int i = 0; i < SPECIAL_COMPONENTS_TYPES.length; i++) {
+ _specialComponentTypes.add(SPECIAL_COMPONENTS_TYPES[i]);
+ }
+ String special = context.getExternalContext().getInitParameter(
+ SPECIAL_TYPES_PARAMETER);
+ if (null != special) {
+ String[] split = special.split(",");
+ for (int i = 0; i < split.length; i++) {
+ _specialComponentTypes.add(split[i]);
+ }
+ }
+ }
+ boolean result;
+ try {
+ String componentType = (String) component.getClass().getField(
+ "COMPONENT_TYPE").get(null);
+ result = _specialComponentTypes.contains(componentType);
+ } catch (Exception e) {
+ // exception occurs if component not have accesible COMPONENT_TYPE
+ // constant
+ // we assume that component not in special types.
+ result = false;
+ }
+ return result;
+ }
+
+}
17 years, 2 months
JBoss Rich Faces SVN: r1411 - in branches/refactor1/framework: impl/src/main/java/org/ajax4jsf/framework/renderer and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-06-29 12:37:49 -0400 (Fri, 29 Jun 2007)
New Revision: 1411
Added:
branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java
Removed:
branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java
Log:
Move AjaxChildrenRenderer to API
Copied: branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java (from rev 1393, branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java)
===================================================================
--- branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java (rev 0)
+++ branches/refactor1/framework/api/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java 2007-06-29 16:37:49 UTC (rev 1411)
@@ -0,0 +1,205 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.framework.renderer;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.ajax.UILoadBundle;
+import org.ajax4jsf.framework.ajax.AjaxChildrenEncoder;
+import org.ajax4jsf.framework.ajax.AjaxOutput;
+import org.ajax4jsf.framework.util.message.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author shura
+ *
+ */
+public abstract class AjaxChildrenRenderer extends AjaxComponentRendererBase {
+
+ public static final Log log = LogFactory.getLog(AjaxChildrenRenderer.class);
+
+ public static final String[] SPECIAL_COMPONENTS_TYPES = {
+ UILoadBundle.COMPONENT_TYPE, "org.apache.myfaces.AliasBean",
+ "org.apache.myfaces.AliasBeansScope" };
+ private static final String SPECIAL_TYPES_PARAMETER = "org.ajax4jsf.CONTROL_COMPONENTS";
+
+ /**
+ * Iterate over all childs of components. If component id contains in list ,
+ * or, if list is empty, compotents is submitted form - render it. TODO -
+ * Instead of calculate full path for every component, build current Path
+ * for componet and send as parameter.
+ *
+ * @param context -
+ * current context
+ * @param component -
+ * curent faces component.
+ * @param ids -
+ * list of Id to render.
+ * @throws IOException
+ * @deprecated Use {@link #encodeAjaxChildren(FacesContext,UIComponent,String,Set,Set)} instead
+ */
+ public void encodeAjaxChild(FacesContext context, UIComponent component, String path, Set ids, Set renderedAreas) throws IOException {
+ encodeAjaxChildren(context, component, path, ids, renderedAreas);
+ }
+
+ /**
+ * Iterate over all childs of components. If component id contains in list ,
+ * or, if list is empty, compotents is submitted form - render it. TODO -
+ * Instead of calculate full path for every component, build current Path
+ * for componet and send as parameter.
+ *
+ * @param context -
+ * current context
+ * @param component -
+ * curent faces component.
+ * @param ids -
+ * list of Id to render.
+ * @throws IOException
+ */
+ public void encodeAjaxChildren(FacesContext context, UIComponent component, String path, Set ids, Set renderedAreas) throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(Messages.ENCODE_CHILD_AJAX_INFO,
+ path, component.getId()));
+ }
+ String currentPath = path;
+ if (component instanceof NamingContainer) {
+ currentPath += component.getId() + NamingContainer.SEPARATOR_CHAR;
+ }
+ for (Iterator it = component.getFacetsAndChildren(); it.hasNext();) {
+ UIComponent element = (UIComponent) it.next();
+ encodeAjaxComponent(context, element, currentPath, ids, renderedAreas);
+ }
+ }
+
+ /**
+ * @param context
+ * @param component
+ * @param currentPath
+ * @param ids
+ * @param renderedAreas
+ * @throws IOException
+ */
+ public void encodeAjaxComponent(FacesContext context, UIComponent component, String currentPath, Set ids, Set renderedAreas) throws IOException {
+ if (component.isRendered()) { // skip not-rendered components.
+ boolean found = false;
+ if (!ids.isEmpty()) {
+ // list for rendering may contains absolute id ( best ),
+ // component Id or client ID
+ String elementId = component.getId();
+ String absoluteId = currentPath + elementId;
+ // String clientId = element.getClientId(context);
+ if (ids.contains(absoluteId) || ids.contains(elementId)) {
+ if (log.isDebugEnabled()) {
+ log
+ .debug(Messages.getMessage(
+ Messages.RENDER_AJAX_AREA_INFO,
+ absoluteId));
+ }
+ // renderChild(context, element);
+ found = true;
+ }
+ }
+ if (!found && component instanceof AjaxOutput) {
+ if (((AjaxOutput) component).isAjaxRendered()) {
+ // renderChild(context, element);
+ found = true;
+ }
+
+ }
+
+ if (!found) {
+ if (component instanceof AjaxChildrenEncoder) {
+ ((AjaxChildrenEncoder) component).encodeAjaxChild(
+ context, currentPath, ids, renderedAreas);
+ } else {
+ // Special case - for control components, not produced
+ // html code - such as message bundles loaders,
+ // MyFaces aliases etc. we call encodeBegin/end methods
+ // even if components not in rendered areas.
+ boolean special = isSpecialElement(context, component);
+ if (special) {
+ component.encodeBegin(context);
+ }
+ encodeAjaxChildren(context, component, currentPath, ids,
+ renderedAreas);
+ if (special) {
+ component.encodeEnd(context);
+ }
+
+ }
+ } else {
+ renderedAreas.add(component.getClientId(context));
+ renderChild(context, component);
+ }
+ }
+ }
+
+ private Set _specialComponentTypes = null;
+
+ /**
+ * Detect component as special control case - such as messages bundle
+ * loader, alias bean components etc. Type of component get by reflection
+ * from static field COMPONENT_TYPE
+ *
+ * @param context
+ * @param component
+ * @return true if encode methods must be called for this component even in
+ * not-rendered parts.
+ */
+ private boolean isSpecialElement(FacesContext context, UIComponent component) {
+ if (_specialComponentTypes == null) {
+ _specialComponentTypes = new HashSet(10);
+ for (int i = 0; i < SPECIAL_COMPONENTS_TYPES.length; i++) {
+ _specialComponentTypes.add(SPECIAL_COMPONENTS_TYPES[i]);
+ }
+ String special = context.getExternalContext().getInitParameter(
+ SPECIAL_TYPES_PARAMETER);
+ if (null != special) {
+ String[] split = special.split(",");
+ for (int i = 0; i < split.length; i++) {
+ _specialComponentTypes.add(split[i]);
+ }
+ }
+ }
+ boolean result;
+ try {
+ String componentType = (String) component.getClass().getField(
+ "COMPONENT_TYPE").get(null);
+ result = _specialComponentTypes.contains(componentType);
+ } catch (Exception e) {
+ // exception occurs if component not have accesible COMPONENT_TYPE
+ // constant
+ // we assume that component not in special types.
+ result = false;
+ }
+ return result;
+ }
+
+}
Deleted: branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java
===================================================================
--- branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java 2007-06-29 16:15:16 UTC (rev 1410)
+++ branches/refactor1/framework/impl/src/main/java/org/ajax4jsf/framework/renderer/AjaxChildrenRenderer.java 2007-06-29 16:37:49 UTC (rev 1411)
@@ -1,205 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.framework.renderer;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.ajax.UILoadBundle;
-import org.ajax4jsf.framework.ajax.AjaxChildrenEncoder;
-import org.ajax4jsf.framework.ajax.AjaxOutput;
-import org.ajax4jsf.framework.util.message.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author shura
- *
- */
-public abstract class AjaxChildrenRenderer extends AjaxComponentRendererBase {
-
- public static final Log log = LogFactory.getLog(AjaxChildrenRenderer.class);
-
- public static final String[] SPECIAL_COMPONENTS_TYPES = {
- UILoadBundle.COMPONENT_TYPE, "org.apache.myfaces.AliasBean",
- "org.apache.myfaces.AliasBeansScope" };
- private static final String SPECIAL_TYPES_PARAMETER = "org.ajax4jsf.CONTROL_COMPONENTS";
-
- /**
- * Iterate over all childs of components. If component id contains in list ,
- * or, if list is empty, compotents is submitted form - render it. TODO -
- * Instead of calculate full path for every component, build current Path
- * for componet and send as parameter.
- *
- * @param context -
- * current context
- * @param component -
- * curent faces component.
- * @param ids -
- * list of Id to render.
- * @throws IOException
- * @deprecated Use {@link #encodeAjaxChildren(FacesContext,UIComponent,String,Set,Set)} instead
- */
- public void encodeAjaxChild(FacesContext context, UIComponent component, String path, Set ids, Set renderedAreas) throws IOException {
- encodeAjaxChildren(context, component, path, ids, renderedAreas);
- }
-
- /**
- * Iterate over all childs of components. If component id contains in list ,
- * or, if list is empty, compotents is submitted form - render it. TODO -
- * Instead of calculate full path for every component, build current Path
- * for componet and send as parameter.
- *
- * @param context -
- * current context
- * @param component -
- * curent faces component.
- * @param ids -
- * list of Id to render.
- * @throws IOException
- */
- public void encodeAjaxChildren(FacesContext context, UIComponent component, String path, Set ids, Set renderedAreas) throws IOException {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(Messages.ENCODE_CHILD_AJAX_INFO,
- path, component.getId()));
- }
- String currentPath = path;
- if (component instanceof NamingContainer) {
- currentPath += component.getId() + NamingContainer.SEPARATOR_CHAR;
- }
- for (Iterator it = component.getFacetsAndChildren(); it.hasNext();) {
- UIComponent element = (UIComponent) it.next();
- encodeAjaxComponent(context, element, currentPath, ids, renderedAreas);
- }
- }
-
- /**
- * @param context
- * @param component
- * @param currentPath
- * @param ids
- * @param renderedAreas
- * @throws IOException
- */
- public void encodeAjaxComponent(FacesContext context, UIComponent component, String currentPath, Set ids, Set renderedAreas) throws IOException {
- if (component.isRendered()) { // skip not-rendered components.
- boolean found = false;
- if (!ids.isEmpty()) {
- // list for rendering may contains absolute id ( best ),
- // component Id or client ID
- String elementId = component.getId();
- String absoluteId = currentPath + elementId;
- // String clientId = element.getClientId(context);
- if (ids.contains(absoluteId) || ids.contains(elementId)) {
- if (log.isDebugEnabled()) {
- log
- .debug(Messages.getMessage(
- Messages.RENDER_AJAX_AREA_INFO,
- absoluteId));
- }
- // renderChild(context, element);
- found = true;
- }
- }
- if (!found && component instanceof AjaxOutput) {
- if (((AjaxOutput) component).isAjaxRendered()) {
- // renderChild(context, element);
- found = true;
- }
-
- }
-
- if (!found) {
- if (component instanceof AjaxChildrenEncoder) {
- ((AjaxChildrenEncoder) component).encodeAjaxChild(
- context, currentPath, ids, renderedAreas);
- } else {
- // Special case - for control components, not produced
- // html code - such as message bundles loaders,
- // MyFaces aliases etc. we call encodeBegin/end methods
- // even if components not in rendered areas.
- boolean special = isSpecialElement(context, component);
- if (special) {
- component.encodeBegin(context);
- }
- encodeAjaxChildren(context, component, currentPath, ids,
- renderedAreas);
- if (special) {
- component.encodeEnd(context);
- }
-
- }
- } else {
- renderedAreas.add(component.getClientId(context));
- renderChild(context, component);
- }
- }
- }
-
- private Set _specialComponentTypes = null;
-
- /**
- * Detect component as special control case - such as messages bundle
- * loader, alias bean components etc. Type of component get by reflection
- * from static field COMPONENT_TYPE
- *
- * @param context
- * @param component
- * @return true if encode methods must be called for this component even in
- * not-rendered parts.
- */
- private boolean isSpecialElement(FacesContext context, UIComponent component) {
- if (_specialComponentTypes == null) {
- _specialComponentTypes = new HashSet(10);
- for (int i = 0; i < SPECIAL_COMPONENTS_TYPES.length; i++) {
- _specialComponentTypes.add(SPECIAL_COMPONENTS_TYPES[i]);
- }
- String special = context.getExternalContext().getInitParameter(
- SPECIAL_TYPES_PARAMETER);
- if (null != special) {
- String[] split = special.split(",");
- for (int i = 0; i < split.length; i++) {
- _specialComponentTypes.add(split[i]);
- }
- }
- }
- boolean result;
- try {
- String componentType = (String) component.getClass().getField(
- "COMPONENT_TYPE").get(null);
- result = _specialComponentTypes.contains(componentType);
- } catch (Exception e) {
- // exception occurs if component not have accesible COMPONENT_TYPE
- // constant
- // we assume that component not in special types.
- result = false;
- }
- return result;
- }
-
-}
17 years, 2 months
JBoss Rich Faces SVN: r1410 - branches.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-06-29 12:15:16 -0400 (Fri, 29 Jun 2007)
New Revision: 1410
Removed:
branches/refactor/
Log:
delete broken branch
17 years, 2 months