You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mf...@apache.org on 2010/08/20 00:43:43 UTC
svn commit: r987340 - in /myfaces/portlet-bridge/core/trunk_2.0.x:
api/src/main/java/javax/portlet/faces/ api/src/main/resources/META-INF/
examples/ examples/guessNumber/
examples/guessNumberMojarraFilter/src/main/webapp/
examples/guessNumberMojarraWra...
Author: mfreedman
Date: Thu Aug 19 22:43:43 2010
New Revision: 987340
URL: http://svn.apache.org/viewvc?rev=987340&view=rev
Log:
PORTLETBRIDGE-166: Bridge header management can generate invalid ContentType (header)
Also fixed a few problems related to fix for PB-163: checked in code worked for iFrame case but not PPR case -- I forgot to add logic to be able to check if the 2 views were the same.
Also fixed a few problems related to fix for PB-162: side effect was a spec change for how to config wrappers and the like -- this checkin contains those changes
Added/updated examples based on changes for PB-162.
Changed faces-config.xml to exclude Trinidad attrs (by default).
Updated .xsd to add description for new syntax to configure wrappers in the faces-config.
Removed:
myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumberMojarraWrapper/
Modified:
myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/BridgeWriteBehindResponse.java
myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/resources/META-INF/portlet2.0-bridge-faces1.2-faces-config-extensions.xsd
myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumber/pom.xml
myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumberMojarraFilter/src/main/webapp/greeting.jspx
myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumberMyFacesFilter/src/main/webapp/greeting.jspx
myfaces/portlet-bridge/core/trunk_2.0.x/examples/pom.xml
myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/BridgeViewHandlerRenderResponseWrapper.java
myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/BridgeViewHandlerResourceResponseWrapper.java
myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/util/config/FacesConfigurationProcessor.java
myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaders.java
myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/resources/META-INF/faces-config.xml
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/BridgeWriteBehindResponse.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/BridgeWriteBehindResponse.java?rev=987340&r1=987339&r2=987340&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/BridgeWriteBehindResponse.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/BridgeWriteBehindResponse.java Thu Aug 19 22:43:43 2010
@@ -81,6 +81,17 @@ public interface BridgeWriteBehindRespon
* wrapped, not further writing to the output would be feasible.
* @throws IOException if content cannot be written
*/
- public void flushContentToWrappedResponse()
+ public void flushMarkupToWrappedResponse()
throws IOException;
+
+ /**
+ * Called by the bridge to detect whether this response actively participated
+ * in the Faces writeBehind support and hence has data that should be written
+ * after the View is rendered. Typically, this method will return <code>true</code>
+ * if the Faces write behind implementation specific flush api has been called
+ * on this response, otherwise <code>false</code>
+ *
+ * @return an indication of whether the response actually particpated in the writeBehind mechanism.
+ */
+ public boolean hasFacesWriteBehindMarkup();
}
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java?rev=987340&r1=987339&r2=987340&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/java/javax/portlet/faces/GenericFacesPortlet.java Thu Aug 19 22:43:43 2010
@@ -101,12 +101,6 @@ public class GenericFacesPortlet extends
*/
public static final String DEFAULT_VIEWID = Bridge.BRIDGE_PACKAGE_PREFIX + "defaultViewId";
- /** Portlet init parameter that defines the class which implements
- * <code>javax.portlet.faces.BridgeWriteBehindResponse</code> and is
- * (to be) used by the bridge when using dispatch() to render JSF views.
- */
- public static final String BRIDGE_WRITE_BEHIND_RESPONSE_CLASS = Bridge.BRIDGE_PACKAGE_PREFIX + "bridgeWriteBehindResponseClassName";
-
/** Portlet init parameter that defines the render response ContentType the bridge
* sets prior to rendering. If not set the bridge uses the request's preferred
@@ -185,11 +179,6 @@ public class GenericFacesPortlet extends
getPortletContext().setAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + getPortletName() + "." +
Bridge.DEFAULT_VIEWID_MAP, defaultViewIdMap);
- Class<? extends BridgeWriteBehindResponse> writeBehindResponse = getWriteBehindResponse();
- if (writeBehindResponse != null)
- getPortletContext().setAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + getPortletName() + "." +
- Bridge.WRITE_BEHIND_RESPONSE, writeBehindResponse);
-
BridgeEventHandler eventHandler = getBridgeEventHandler();
if (eventHandler != null)
{
@@ -530,46 +519,6 @@ public class GenericFacesPortlet extends
}
/**
- * Returns an instantiated class that implements the <code>java.portlet.faces.BridgeWriteBehindResponse>/code>
- * interface the bridge is supposed to use when dispatching render requests. This is provided
- * when a portlet wants the JSP writeBehindBehavior and chooses to get this Faces implementation
- * dependent behavior by using a Portlet 2.0 response wrapper.<br>
- * Subclasses override to
- * alter the default behavior. Default implementation returns value of the portlet init
- * parameter: javax.portlet.faces.BridgeWriteBehindResponseClassName.
- *
- * @return a instantiated class that implements <code>java.portlet.faces.BridgeWriteBehindResponse>/code>
- */
-
- public Class<? extends BridgeWriteBehindResponse> getWriteBehindResponse() throws PortletException
- {
- Class<? extends BridgeWriteBehindResponse> writeBehindResponse = null;
- String bridgeWriteBehindResponseClassName =
- getPortletConfig().getInitParameter(BRIDGE_WRITE_BEHIND_RESPONSE_CLASS);
-
- if (bridgeWriteBehindResponseClassName != null)
- {
- try
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- writeBehindResponse = (Class<? extends BridgeWriteBehindResponse>) loader.loadClass(bridgeWriteBehindResponseClassName);
- }
- catch (ClassNotFoundException cnfe)
- {
- throw new PortletException("Unable to load configured bridge writeBehindResponse: " + bridgeWriteBehindResponseClassName);
- }
- catch (ClassCastException cce)
- {
- this.getPortletContext().log("GenericFacesPortlet: WARNING - configured BridgeWriteBehindResponse isn't an instance of javax.portlet.faces.BridgeWriteBehindResponse.");
- // continue on
- }
-
- }
-
- return writeBehindResponse;
- }
-
- /**
* Returns the value of the portlet initialization parameter
* <code>javax.portlet.faces.autoDispatchEvents</code> if non-null or
* <code>true</code>, otherwise.
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/resources/META-INF/portlet2.0-bridge-faces1.2-faces-config-extensions.xsd
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/resources/META-INF/portlet2.0-bridge-faces1.2-faces-config-extensions.xsd?rev=987340&r1=987339&r2=987340&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/resources/META-INF/portlet2.0-bridge-faces1.2-faces-config-extensions.xsd (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/api/src/main/resources/META-INF/portlet2.0-bridge-faces1.2-faces-config-extensions.xsd Thu Aug 19 22:43:43 2010
@@ -1,24 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- Created with Liquid XML Studio 1.0.8.0 (http://www.liquid-technologies.com) -->
+
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://myfaces.apache.org/portletbridge" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:element name="excluded-attributes">
+ <xs:element name="excluded-attributes" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="excluded-attribute" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="public-parameter-mappings">
+ <xs:element name="public-parameter-mappings" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="public-parameter-mapping" type="parameter-mappingType" />
</xs:sequence>
</xs:complexType>
</xs:element>
+
+ <xs:element name="write-behind-response-wrappers" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="render-response-wrapper-class" type="xs:string" />
+ <xs:element minOccurs="0" name="resource-response-wrapper-class" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+
<xs:complexType name="parameter-mappingType">
<xs:sequence>
<xs:element name="parameter" type="xs:string" />
<xs:element name="model-el" type="xs:string" />
</xs:sequence>
</xs:complexType>
-</xs:schema>
\ No newline at end of file
+</xs:schema>
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumber/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumber/pom.xml?rev=987340&r1=987339&r2=987340&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumber/pom.xml (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumber/pom.xml Thu Aug 19 22:43:43 2010
@@ -1,278 +1,278 @@
-<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">
- <modelVersion>4.0.0</modelVersion>
- <name>MyFaces Portlet Bridge GuessNumber JSP Demo</name>
- <artifactId>portlet-bridge-guessNumber-jsp</artifactId>
- <packaging>war</packaging>
-
- <parent>
- <groupId>org.apache.myfaces.portlet-bridge</groupId>
- <artifactId>portlet-bridge-examples</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
-
- <dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>javax.portlet</groupId>
- <artifactId>portlet-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>portlet-bridge-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>portlet-bridge-impl</artifactId>
- </dependency>
-
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-impl</artifactId>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-jdev-plugin</artifactId>
- <groupId>org.apache.myfaces.trinidadbuild</groupId>
- <configuration>
- <libraries>
- <library>JSP Runtime</library>
- </libraries>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
- <profile>
- <id>pluto-assemble</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <warName>${pom.artifactId}-pluto-${pom.version}</warName>
- <outputDirectory>${project.build.directory}/../../assembly/target/webapp</outputDirectory>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <!-- sets up the webapp for deployment to pluto 2.0 "mvn clean install -Ppluto" -->
- <profile>
- <id>pluto</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.portals.pluto</groupId>
- <artifactId>maven-pluto-plugin</artifactId>
- <version>2.0.0</version>
- <executions>
- <execution>
- <phase>generate-resources</phase>
- <goals>
- <goal>assemble</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
-<!-- sets up the webapp for deployment to pluto 2.0 (this is included as its the command in 1.0 for building to 2 - i.e. backwards compat) "mvn clean install -Ppluto2" -->
- <profile>
- <id>pluto2</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.portals.pluto</groupId>
- <artifactId>maven-pluto-plugin</artifactId>
- <version>2.0.0</version>
- <executions>
- <execution>
- <phase>generate-resources</phase>
- <goals>
- <goal>assemble</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <!-- To run jetty, issue "mvn clean -PjettyConfig jetty:run" -->
- <profile>
- <id>jettyConfig</id>
- <dependencies>
- <dependency>
- <groupId>com.bekk.boss</groupId>
- <artifactId>maven-jetty-pluto-embedded</artifactId>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- <configuration>
- <webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
- <webDefaultXml>src/main/webapp/WEB-INF/jetty-pluto-web-default.xml</webDefaultXml>
- <systemProperties>
- <systemProperty>
- <name>org.apache.pluto.embedded.portletIds</name>
- <value>portlet-bridge-guessNumber-jsp</value>
- </systemProperty>
- </systemProperties>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.pluto</groupId>
- <artifactId>maven-pluto-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
- </profile>
-
- <!-- By default the war examples uses mojarra and packages for a nonjavaee environment (includes the Faces jars)! :) -->
-
- <!-- If you are running in a nonJavaEE environment (i.e. Faces isn't already deployed) and hence need to have Mojarra packaged in the war: -->
- <profile>
- <id>mojarra-nonjavaee</id>
- <activation>
- <property>
- <name>!jsf</name>
- </property>
- </activation>
-
- <dependencies>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-api</artifactId>
- <version>${mojarra.version}</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-impl</artifactId>
- <version>${mojarra.version}</version>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
- <properties>
- <jsf_implementation>JSF-RI</jsf_implementation>
- </properties>
- </profile>
-
- <!-- If you are running in a JavaEE environment (i.e. Faces is already deployed) and hence don't need to have Mojarra packaged in the war: -->
- <!-- mvn install -Djsf=mojarra-javaee -->
- <profile>
- <id>mojarra-javaee</id>
- <activation>
- <property>
- <name>jsf</name>
- <value>mojarra-javaee</value>
- </property>
- </activation>
- <dependencies>
- <dependency>
- <groupId>javax.faces</groupId>
- <artifactId>jsf-api</artifactId>
- </dependency>
- </dependencies>
- <properties>
- <jsf_implementation>JSF-RI</jsf_implementation>
- </properties>
- </profile>
-
-
- <!-- To use this examples using the MyFacesImplementation: mvn clean install -Djsf=myfaces-javaee -->
- <!-- Note: currently carstore doesn't work properly in a myfaces environment -->
- <profile>
- <id>myfaces-javaee</id>
- <activation>
- <property>
- <name>jsf</name>
- <value>myfaces-javaee</value>
- </property>
- </activation>
- <dependencies>
- <dependency>
- <groupId>org.apache.myfaces.core</groupId>
- <artifactId>myfaces-api</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.myfaces.core</groupId>
- <artifactId>myfaces-impl</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
- </profile>
-
-
-
- <!-- If you are running in a nonJavaEE environment (i.e. Faces isn't already deployed) and hence need to have MyFaces packaged in the war: -->
- <!-- mvn install -Djsf=myfaces-nonjavaee -->
- <!-- Note: currently carstore doesn't work properly in a myfaces environment -->
- <profile>
- <id>myfaces-nonjavaee</id>
- <activation>
- <property>
- <name>jsf</name>
- <value>myfaces-nonjavaee</value>
- </property>
- </activation>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.myfaces.core</groupId>
- <artifactId>myfaces-api</artifactId>
- <version>${myfaces.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.myfaces.core</groupId>
- <artifactId>myfaces-impl</artifactId>
- <version>${myfaces.version}</version>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
-</project>
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <name>MyFaces Portlet Bridge GuessNumber JSP Demo</name>
+ <artifactId>portlet-bridge-guessNumber-jsp</artifactId>
+ <packaging>war</packaging>
+
+ <parent>
+ <groupId>org.apache.myfaces.portlet-bridge</groupId>
+ <artifactId>portlet-bridge-examples</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.portlet</groupId>
+ <artifactId>portlet-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>portlet-bridge-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>portlet-bridge-impl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jdev-plugin</artifactId>
+ <groupId>org.apache.myfaces.trinidadbuild</groupId>
+ <configuration>
+ <libraries>
+ <library>JSP Runtime</library>
+ </libraries>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>pluto-assemble</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <warName>${pom.artifactId}-pluto-${pom.version}</warName>
+ <outputDirectory>${project.build.directory}/../../assembly/target/webapp</outputDirectory>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!-- sets up the webapp for deployment to pluto 2.0 "mvn clean install -Ppluto" -->
+ <profile>
+ <id>pluto</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.portals.pluto</groupId>
+ <artifactId>maven-pluto-plugin</artifactId>
+ <version>2.0.0</version>
+ <executions>
+ <execution>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>assemble</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+<!-- sets up the webapp for deployment to pluto 2.0 (this is included as its the command in 1.0 for building to 2 - i.e. backwards compat) "mvn clean install -Ppluto2" -->
+ <profile>
+ <id>pluto2</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.portals.pluto</groupId>
+ <artifactId>maven-pluto-plugin</artifactId>
+ <version>2.0.0</version>
+ <executions>
+ <execution>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>assemble</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!-- To run jetty, issue "mvn clean -PjettyConfig jetty:run" -->
+ <profile>
+ <id>jettyConfig</id>
+ <dependencies>
+ <dependency>
+ <groupId>com.bekk.boss</groupId>
+ <artifactId>maven-jetty-pluto-embedded</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <configuration>
+ <webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
+ <webDefaultXml>src/main/webapp/WEB-INF/jetty-pluto-web-default.xml</webDefaultXml>
+ <systemProperties>
+ <systemProperty>
+ <name>org.apache.pluto.embedded.portletIds</name>
+ <value>portlet-bridge-guessNumber-jsp</value>
+ </systemProperty>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.pluto</groupId>
+ <artifactId>maven-pluto-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!-- By default the war examples uses mojarra and packages for a nonjavaee environment (includes the Faces jars)! :) -->
+
+ <!-- If you are running in a nonJavaEE environment (i.e. Faces isn't already deployed) and hence need to have Mojarra packaged in the war: -->
+ <profile>
+ <id>mojarra-nonjavaee</id>
+ <activation>
+ <property>
+ <name>!jsf</name>
+ </property>
+ </activation>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ <version>${mojarra.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-impl</artifactId>
+ <version>${mojarra.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+ <properties>
+ <jsf_implementation>JSF-RI</jsf_implementation>
+ </properties>
+ </profile>
+
+ <!-- If you are running in a JavaEE environment (i.e. Faces is already deployed) and hence don't need to have Mojarra packaged in the war: -->
+ <!-- mvn install -Djsf=mojarra-javaee -->
+ <profile>
+ <id>mojarra-javaee</id>
+ <activation>
+ <property>
+ <name>jsf</name>
+ <value>mojarra-javaee</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>javax.faces</groupId>
+ <artifactId>jsf-api</artifactId>
+ </dependency>
+ </dependencies>
+ <properties>
+ <jsf_implementation>JSF-RI</jsf_implementation>
+ </properties>
+ </profile>
+
+
+ <!-- To use this examples using the MyFacesImplementation: mvn clean install -Djsf=myfaces-javaee -->
+ <!-- Note: currently carstore doesn't work properly in a myfaces environment -->
+ <profile>
+ <id>myfaces-javaee</id>
+ <activation>
+ <property>
+ <name>jsf</name>
+ <value>myfaces-javaee</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-impl</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+
+
+
+ <!-- If you are running in a nonJavaEE environment (i.e. Faces isn't already deployed) and hence need to have MyFaces packaged in the war: -->
+ <!-- mvn install -Djsf=myfaces-nonjavaee -->
+ <!-- Note: currently carstore doesn't work properly in a myfaces environment -->
+ <profile>
+ <id>myfaces-nonjavaee</id>
+ <activation>
+ <property>
+ <name>jsf</name>
+ <value>myfaces-nonjavaee</value>
+ </property>
+ </activation>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-api</artifactId>
+ <version>${myfaces.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-impl</artifactId>
+ <version>${myfaces.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+</project>
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumberMojarraFilter/src/main/webapp/greeting.jspx
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumberMojarraFilter/src/main/webapp/greeting.jspx?rev=987340&r1=987339&r2=987340&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumberMojarraFilter/src/main/webapp/greeting.jspx (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumberMojarraFilter/src/main/webapp/greeting.jspx Thu Aug 19 22:43:43 2010
@@ -32,6 +32,7 @@
<title>Hello</title>
</head>
<body bgcolor="white">
+JSP before view content<br/>
<f:view>
<h:form id="helloForm">
<h2>Hi. My name is Duke. I'm thinking of a number from
@@ -54,7 +55,7 @@
</h:form>
</f:view>
-
+JSP after view content<br/>
<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10"
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumberMyFacesFilter/src/main/webapp/greeting.jspx
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumberMyFacesFilter/src/main/webapp/greeting.jspx?rev=987340&r1=987339&r2=987340&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumberMyFacesFilter/src/main/webapp/greeting.jspx (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/examples/guessNumberMyFacesFilter/src/main/webapp/greeting.jspx Thu Aug 19 22:43:43 2010
@@ -32,6 +32,7 @@
<title>Hello</title>
</head>
<body bgcolor="white">
+JSP before view content<br/>
<f:view>
<h:form id="helloForm">
<h2>Hi. My name is Duke. I'm thinking of a number from
@@ -54,7 +55,7 @@
</h:form>
</f:view>
-
+JSP after view content<br/>
<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10"
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/examples/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/examples/pom.xml?rev=987340&r1=987339&r2=987340&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/examples/pom.xml (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/examples/pom.xml Thu Aug 19 22:43:43 2010
@@ -1,64 +1,64 @@
-<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">
- <modelVersion>4.0.0</modelVersion>
- <name>MyFaces Portlet Bridge Examples</name>
- <artifactId>portlet-bridge-examples</artifactId>
- <packaging>pom</packaging>
-
- <parent>
- <groupId>org.apache.myfaces.portlet-bridge</groupId>
- <artifactId>portlet-bridge</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- </parent>
-
- <repositories>
- <repository>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- <id>apache-maven-snapshots</id>
- <url>http://people.apache.org/repo/m2-snapshot-repository/</url>
- </repository>
- </repositories>
-
- <modules>
- <module>blank</module>
- <module>carstore</module>
- <module>facelets-guess</module>
- <module>guessNumber</module>
- <module>guessNumberMojarraFilter</module>
- <module>guessNumberMojarraWrapper</module>
- <module>guessNumberMyFacesFilter</module>
- <module>helloDuke</module>
- <module>helloDukeCoordination</module>
- </modules>
-
- <profiles>
- <profile>
- <id>prepare-release</id>
- <activation>
- <property>
- <name>prepareRelease</name>
- </property>
- </activation>
- <modules>
- <module>assembly</module>
- </modules>
- </profile>
-
- <profile>
- <id>perform-release</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
- <modules>
- <module>assembly</module>
- </modules>
- </profile>
- </profiles>
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <name>MyFaces Portlet Bridge Examples</name>
+ <artifactId>portlet-bridge-examples</artifactId>
+ <packaging>pom</packaging>
+
+ <parent>
+ <groupId>org.apache.myfaces.portlet-bridge</groupId>
+ <artifactId>portlet-bridge</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <repositories>
+ <repository>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>apache-maven-snapshots</id>
+ <url>http://people.apache.org/repo/m2-snapshot-repository/</url>
+ </repository>
+ </repositories>
+
+ <modules>
+ <module>blank</module>
+ <module>carstore</module>
+ <module>facelets-guess</module>
+ <module>guessNumber</module>
+ <module>guessNumberMojarraFilter</module>
+ <module>guessNumberMojarra_v04_to_v07_Wrapper</module>
+ <module>guessNumberMyFacesFilter</module>
+ <module>helloDuke</module>
+ <module>helloDukeCoordination</module>
+ </modules>
+
+ <profiles>
+ <profile>
+ <id>prepare-release</id>
+ <activation>
+ <property>
+ <name>prepareRelease</name>
+ </property>
+ </activation>
+ <modules>
+ <module>assembly</module>
+ </modules>
+ </profile>
+
+ <profile>
+ <id>perform-release</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <modules>
+ <module>assembly</module>
+ </modules>
+ </profile>
+ </profiles>
</project>
\ No newline at end of file
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/BridgeViewHandlerRenderResponseWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/BridgeViewHandlerRenderResponseWrapper.java?rev=987340&r1=987339&r2=987340&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/BridgeViewHandlerRenderResponseWrapper.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/BridgeViewHandlerRenderResponseWrapper.java Thu Aug 19 22:43:43 2010
@@ -48,6 +48,7 @@ public class BridgeViewHandlerRenderResp
private CharArrayWriter mCharWriter;
private PrintWriter mPrintWriter;
private int mStatus = HttpServletResponse.SC_OK;
+ private boolean mHasWriteBehindMarkup = false;
public BridgeViewHandlerRenderResponseWrapper()
{
@@ -208,11 +209,11 @@ public class BridgeViewHandlerRenderResp
* response (this could be a Servlet or Portlet response)
* @throws IOException if content cannot be written
*/
- public void flushContentToWrappedResponse()
+ public void flushMarkupToWrappedResponse()
throws IOException
{
RenderResponse response = getResponse();
-
+
flushBuffer();
if (isBytes())
@@ -227,6 +228,36 @@ public class BridgeViewHandlerRenderResp
}
}
+
+ /**
+ * This is the Mojarra specific API used by its tags to flush the pre-view content
+ * to the wrapped response. Works automatically in newer Mojarra -- one's that use
+ * inspection to determine if the API is supported.
+ * @throws IOException if content cannot be written
+ */
+ public void flushContentToWrappedResponse()
+ throws IOException
+ {
+ mHasWriteBehindMarkup = true;
+
+ flushMarkupToWrappedResponse();
+
+ }
+
+ /**
+ * This is the MyFaces specific API used by its tags to flush the pre-view content
+ * to the wrapped response. MyFaces doesn't yet use reflection so this will only work if you
+ * subclass with a class that claims it implements the MyFaces interface.
+ * @throws IOException if content cannot be written
+ */
+ public void flushToWrappedResponse()
+ throws IOException
+ {
+ mHasWriteBehindMarkup = true;
+
+ flushMarkupToWrappedResponse();
+
+ }
/**
* Flush the current buffered content to the provided <code>Writer</code>
@@ -267,6 +298,20 @@ public class BridgeViewHandlerRenderResp
mCharWriter.reset();
}
}
+
+ /**
+ * Called by the bridge to detect whether this response actively participated
+ * in the Faces writeBehind support and hence has data that should be written
+ * after the View is rendered. Typically, this method will return <code>true</code>
+ * if the Faces write behind implementation specific flush api has been called
+ * on this response, otherwise <code>false</code>
+ *
+ * @return an indication of whether the response actually particpated in the writeBehind mechanism.
+ */
+ public boolean hasFacesWriteBehindMarkup()
+ {
+ return mHasWriteBehindMarkup;
+ }
// ----------------------------------------------------------- Inner Classes
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/BridgeViewHandlerResourceResponseWrapper.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/BridgeViewHandlerResourceResponseWrapper.java?rev=987340&r1=987339&r2=987340&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/BridgeViewHandlerResourceResponseWrapper.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/BridgeViewHandlerResourceResponseWrapper.java Thu Aug 19 22:43:43 2010
@@ -30,6 +30,7 @@ import java.nio.ByteBuffer;
import javax.faces.context.FacesContext;
+import javax.portlet.RenderResponse;
import javax.portlet.ResourceResponse;
import javax.portlet.filter.ResourceResponseWrapper;
@@ -48,6 +49,7 @@ public class BridgeViewHandlerResourceRe
private CharArrayWriter mCharWriter;
private PrintWriter mPrintWriter;
private int mStatus = HttpServletResponse.SC_OK;
+ private boolean mHasWriteBehindMarkup = false;
public BridgeViewHandlerResourceResponseWrapper()
{
@@ -208,11 +210,11 @@ public class BridgeViewHandlerResourceRe
* response (this could be a Servlet or Portlet response)
* @throws IOException if content cannot be written
*/
- public void flushContentToWrappedResponse()
+ public void flushMarkupToWrappedResponse()
throws IOException
{
ResourceResponse response = getResponse();
-
+
flushBuffer();
if (isBytes())
@@ -227,6 +229,36 @@ public class BridgeViewHandlerResourceRe
}
}
+
+ /**
+ * This is the Mojarra specific API used by its tags to flush the pre-view content
+ * to the wrapped response. Works automatically in newer Mojarra -- one's that use
+ * inspection to determine if the API is supported.
+ * @throws IOException if content cannot be written
+ */
+ public void flushContentToWrappedResponse()
+ throws IOException
+ {
+ mHasWriteBehindMarkup = true;
+
+ flushMarkupToWrappedResponse();
+
+ }
+
+ /**
+ * This is the MyFaces specific API used by its tags to flush the pre-view content
+ * to the wrapped response. MyFaces doesn't yet use reflection so this will only work if you
+ * subclass with a class that claims it implements the MyFaces interface.
+ * @throws IOException if content cannot be written
+ */
+ public void flushToWrappedResponse()
+ throws IOException
+ {
+ mHasWriteBehindMarkup = true;
+
+ flushMarkupToWrappedResponse();
+
+ }
/**
* Flush the current buffered content to the provided <code>Writer</code>
@@ -267,6 +299,20 @@ public class BridgeViewHandlerResourceRe
mCharWriter.reset();
}
}
+
+ /**
+ * Called by the bridge to detect whether this response actively participated
+ * in the Faces writeBehind support and hence has data that should be written
+ * after the View is rendered. Typically, this method will return <code>true</code>
+ * if the Faces write behind implementation specific flush api has been called
+ * on this response, otherwise <code>false</code>
+ *
+ * @return an indication of whether the response actually particpated in the writeBehind mechanism.
+ */
+ public boolean hasFacesWriteBehindMarkup()
+ {
+ return mHasWriteBehindMarkup;
+ }
// ----------------------------------------------------------- Inner Classes
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java?rev=987340&r1=987339&r2=987340&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java Thu Aug 19 22:43:43 2010
@@ -52,8 +52,8 @@ import javax.portlet.faces.BridgeWriteBe
import javax.portlet.faces.annotation.PortletNamingContainer;
import javax.portlet.faces.component.PortletNamingContainerUIViewRoot;
-import javax.portlet.filter.PortletResponseWrapper;
-
+import org.apache.myfaces.portlet.faces.application.BridgeViewHandlerRenderResponseWrapper;
+import org.apache.myfaces.portlet.faces.application.BridgeViewHandlerResourceResponseWrapper;
import org.apache.myfaces.portlet.faces.bridge.BridgeImpl;
import org.apache.myfaces.portlet.faces.util.QueryString;
@@ -437,9 +437,7 @@ public class PortletViewHandlerImpl exte
ExternalContext extContext,
UIViewRoot viewToRender)
throws IOException
- {
- boolean writeBehind = false;
-
+ {
String viewURI = viewToRender.getViewId();
// update the JSTL locale attribute in request scope so that JSTL
@@ -459,16 +457,17 @@ public class PortletViewHandlerImpl exte
try
{
wrapped = writeBehindResponseWrapperClass.newInstance();
- if (wrapped instanceof PortletResponseWrapper)
+ if ((BridgeUtil.getPortletRequestPhase() == Bridge.PortletPhase.RENDER_PHASE && wrapped instanceof RenderResponse) ||
+ (BridgeUtil.getPortletRequestPhase() == Bridge.PortletPhase.RESOURCE_PHASE && wrapped instanceof ResourceResponse))
{
+
extContext.setResponse(wrapped);
- writeBehind = true;
}
else
{
// warn and don't use
wrapped = null;
- ((PortletContext)extContext.getContext()).log("Unable to use configured BridgeWriteBehindResponse instance because its not a PortletResponseWrapper.");
+ ((PortletContext)extContext.getContext()).log("Unable to use configured BridgeWriteBehindResponse instance because its not the appropriate PortletResponseWrapper for the associated phase.");
}
} catch (Exception e)
@@ -504,14 +503,15 @@ public class PortletViewHandlerImpl exte
// replace the original response
extContext.setResponse(originalResponse);
- if (writeBehind)
+ // Check whether our wrapper participated in the the writeBehind mechanism and/or
+ // something else already did (servlet filter)
+ if (wrapped.hasFacesWriteBehindMarkup() && extContext.getRequestMap().get(Bridge.AFTER_VIEW_CONTENT) == null)
{
// Put the AFTER_VIEW_CONTENT into request scope
// temporarily
Object o = (wrapped.isChars()) ? (Object) wrapped.getChars() : (Object) wrapped.getBytes();
- // only write if a filter hasn't already written
- if (o != null && extContext.getRequestMap().get(Bridge.AFTER_VIEW_CONTENT) == null)
+ if (o != null)
{
extContext.getRequestMap().put(Bridge.AFTER_VIEW_CONTENT, o);
}
@@ -519,7 +519,7 @@ public class PortletViewHandlerImpl exte
else
{
// write ahead -- just write this to the restored response
- wrapped.flushContentToWrappedResponse();
+ wrapped.flushMarkupToWrappedResponse();
}
}
}
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java?rev=987340&r1=987339&r2=987340&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java Thu Aug 19 22:43:43 2010
@@ -65,13 +65,13 @@ import javax.faces.render.ResponseStateM
import javax.faces.webapp.FacesServlet;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
-import javax.portlet.ClientDataRequest;
import javax.portlet.EventRequest;
import javax.portlet.EventResponse;
import javax.portlet.MimeResponse;
import javax.portlet.PortalContext;
import javax.portlet.PortletConfig;
import javax.portlet.PortletContext;
+import javax.portlet.PortletException;
import javax.portlet.PortletPreferences;
import javax.portlet.PortletRequest;
import javax.portlet.PortletRequestDispatcher;
@@ -82,6 +82,7 @@ import javax.portlet.RenderResponse;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import javax.portlet.StateAwareResponse;
+import javax.portlet.filter.PortletResponseWrapper;
import javax.portlet.faces.Bridge;
import javax.portlet.faces.BridgeDefaultViewNotSpecifiedException;
import javax.portlet.faces.BridgeEventHandler;
@@ -97,6 +98,11 @@ import javax.portlet.faces.annotation.Ex
import javax.portlet.faces.event.EventNavigationResult;
+import javax.portlet.filter.PortletResponseWrapper;
+import javax.portlet.filter.RenderResponseWrapper;
+
+import javax.portlet.filter.ResourceResponseWrapper;
+
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
@@ -134,6 +140,7 @@ public class BridgeImpl
private static final String REQUEST_SCOPE_LOCK = "org.apache.myfaces.portlet.faces.requestScopeLock";
private static final String REQUEST_SCOPE_MAP = "org.apache.myfaces.portlet.faces.requestScopeMap";
+ private static final String SCOPE_VIEW_KEY = "org.apache.myfaces.portlet.faces.includeInScope.scopeViewKey";
private static final String CHILD_RESOURCE_REQUEST_SCOPE_MAP = "org.apache.myfaces.portlet.faces.includeInScope.childResourceRequestScopeMap";
private static final String REQUEST_SCOPE_LISTENER = "org.apache.myfaces.portlet.faces.requestScopeWatch";
public static final String FACES_VIEWROOT = "org.apache.myfaces.portlet.faces.includeInScope.facesViewRoot";
@@ -160,7 +167,8 @@ public class BridgeImpl
private Map<String,String> mDefaultViewIdMap = null;
- private Class<? extends BridgeWriteBehindResponse> mBridgeWriteBehindResponse = null;
+ private Class<? extends BridgeWriteBehindResponse> mWriteBehindRenderResponseWrapper = null;
+ private Class<? extends BridgeWriteBehindResponse> mWriteBehindResourceResponseWrapper = null;
public BridgeImpl()
{
@@ -177,9 +185,6 @@ public class BridgeImpl
mPortletConfig = config;
PortletContext portletContext = mPortletConfig.getPortletContext();
- // acquire any config information in faces-config.xml
- FacesConfigurationProcessor processor = new FacesConfigurationProcessor(portletContext);
- mPublicParameterMappings = processor.getPublicParameterMappings();
// get bridgeEventHandler, processPublicRenderParameterHandler, preserveActionParams, excludedAttributes configuration settings.
mEventHandler = (BridgeEventHandler) portletContext.getAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + mPortletConfig.getPortletName() +
@@ -191,9 +196,6 @@ public class BridgeImpl
(Boolean) portletContext.getAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + mPortletConfig.getPortletName() +
"." + Bridge.PRESERVE_ACTION_PARAMS);
- mBridgeWriteBehindResponse = (Class<? extends BridgeWriteBehindResponse>) portletContext.getAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + mPortletConfig.getPortletName() +
- "." + Bridge.WRITE_BEHIND_RESPONSE);
-
mExcludedRequestAttributes = (List<String>) portletContext.getAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + mPortletConfig.getPortletName() +
"." + Bridge.EXCLUDED_REQUEST_ATTRIBUTES);
if (mExcludedRequestAttributes != null)
@@ -206,9 +208,9 @@ public class BridgeImpl
// Otherwise create an empty list
mExcludedRequestAttributes = new ArrayList(5);
}
-
- // Read excludedAttributes that may be defined in any face-config.xml
- readExcludedAttributesFromFacesConfig(portletContext, mExcludedRequestAttributes);
+
+ // acquire any config information in faces-config.xml
+ processFacesConfiguration(portletContext);
// Set up the synchronziation object for the RequestScopeMap as we don't
// want to sync on the PortletContext because its too broad. Note:
@@ -724,9 +726,9 @@ public class BridgeImpl
request.setAttribute(PORTLET_NAME_ATTRIBUTE, mPortletConfig.getPortletName());
// Set the WriteBehindResponse the ViewHandler should use
- if (mBridgeWriteBehindResponse != null)
+ if (mWriteBehindRenderResponseWrapper != null)
{
- request.setAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + Bridge.WRITE_BEHIND_RESPONSE, mBridgeWriteBehindResponse);
+ request.setAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + Bridge.WRITE_BEHIND_RESPONSE, mWriteBehindRenderResponseWrapper);
}
// Set the FacesServletMapping attribute so the ExternalContext can
@@ -982,19 +984,25 @@ public class BridgeImpl
// At a minimum we need to update the VIEW_STATE_PARAM being maintained
// However, if this is a resource request then we also update the full scope
- if (scopeId != null)
+
+ // Don't update if we have redirected during this render instead remove the scope
+ if (scopeId != null && !redirectedDuringRender)
{
- // Don't update if we have redirected during this render instead remove the scope
- if (!redirectedDuringRender)
- {
- saveFacesMessageState(context);
- saveBridgeRequestScopeData(context, scopeId, preExistingAttributes);
- updateViewInfo(context, scopeId);
- }
- else
- {
- removeRequestScopes(scopeId);
- }
+ context.getExternalContext().getRequestMap().put(SCOPE_VIEW_KEY, getScopeViewKey(context.getExternalContext()));
+ saveFacesMessageState(context);
+ saveBridgeRequestScopeData(context, scopeId, preExistingAttributes);
+ updateViewInfo(context, scopeId);
+ }
+ else
+ {
+ if (scopeId != null) removeRequestScopes(scopeId);
+ // start a new/empty in session scope -- merely add the key used to discriminate whether
+ // a follow-on resource request targets the same view as the render (PPR) or a different view (iFrame)
+ scopeId = initBridgeRequestScope(request, null);
+ HashMap<String, Object> m = (HashMap<String, Object>) new HashMap();
+ m.put(SCOPE_VIEW_KEY, getScopeViewKey(context.getExternalContext()));
+ putBridgeRequestScopeData(scopeId, m);
+ updateViewInfo(context, scopeId);
}
}
@@ -1052,9 +1060,9 @@ public class BridgeImpl
request.setAttribute(PORTLET_NAME_ATTRIBUTE, mPortletConfig.getPortletName());
// Set the WriteBehindResponse the ViewHandler should use
- if (mBridgeWriteBehindResponse != null)
+ if (mWriteBehindResourceResponseWrapper != null)
{
- request.setAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + Bridge.WRITE_BEHIND_RESPONSE, mBridgeWriteBehindResponse);
+ request.setAttribute(Bridge.BRIDGE_PACKAGE_PREFIX + Bridge.WRITE_BEHIND_RESPONSE, mWriteBehindResourceResponseWrapper);
}
@@ -1092,12 +1100,6 @@ public class BridgeImpl
// scope but the correct one contained within it
scopeId = getResourceRequestScopeId(extCtx, request);
- // ensure that isPostback attribute set if VIEW_STATE param exists
- if (extCtx.getRequestParameterValuesMap().containsKey(ResponseStateManager.VIEW_STATE_PARAM))
- {
- extCtx.getRequestMap().put(Bridge.IS_POSTBACK_ATTRIBUTE, Boolean.TRUE);
- }
-
doFacesRender(request, response, context, lifecycle, scopeId, preExistingAttributes);
}
catch (Exception e)
@@ -1784,34 +1786,53 @@ public class BridgeImpl
// Check to see if this resource request is targeting the same view or a different one
Map<String, Object> m = getScopeMap(scopeId);
Map<String, String> childResourceScopeMap = (Map<String, String>) m.get(CHILD_RESOURCE_REQUEST_SCOPE_MAP);
+ String scopeIdKey = (String) m.get(SCOPE_VIEW_KEY);
+ String childIdKey = getScopeViewKey(extCtx);
+
+ // If the resource is a PPR it will target the same view as the render/parent
+ // In which case use the same scope
+ if (scopeIdKey != null && scopeIdKey.equalsIgnoreCase(childIdKey))
+ {
+ return scopeId;
+ }
+ else
+ {
+ String childScopeId = null;
+
+ if (childResourceScopeMap != null)
+ {
+ childScopeId = childResourceScopeMap.get(childIdKey);
+ }
+
+ if (childScopeId == null)
+ {
+ childScopeId = createBridgeRequestScope(request);
+
+ if (childResourceScopeMap == null)
+ {
+ childResourceScopeMap = (Map<String, String>) new HashMap(3);
+ m.put(CHILD_RESOURCE_REQUEST_SCOPE_MAP, childResourceScopeMap);
+ }
+ childResourceScopeMap.put(childIdKey, childScopeId);
+ }
+
+ return childScopeId;
+ }
+ }
+
+ private String getScopeViewKey(ExternalContext extCtx)
+ {
String scopeIdKey = null;
- String childScopeId = null;
String pathInfo = extCtx.getRequestPathInfo();
String servletPath = extCtx.getRequestServletPath();
if (pathInfo == null) scopeIdKey = servletPath;
else if (servletPath == null) scopeIdKey = pathInfo;
else scopeIdKey = servletPath + pathInfo;
-
- if (childResourceScopeMap != null)
- {
- childScopeId = childResourceScopeMap.get(scopeIdKey);
- }
- if (childScopeId == null)
- {
- childScopeId = createBridgeRequestScope(request);
-
- if (childResourceScopeMap == null)
- {
- childResourceScopeMap = (Map<String, String>) new HashMap(3);
- m.put(CHILD_RESOURCE_REQUEST_SCOPE_MAP, childResourceScopeMap);
- }
- childResourceScopeMap.put(scopeIdKey, childScopeId);
- }
-
- return childScopeId;
- }
+ return scopeIdKey;
+
+ }
private String getRequestScopeId(PortletRequest request)
@@ -2447,25 +2468,50 @@ public class BridgeImpl
}
}
- private void readExcludedAttributesFromFacesConfig(PortletContext context,
- List<String> excludedAttributes)
+ private void processFacesConfiguration(PortletContext context)
{
FacesConfigurationProcessor processor = new FacesConfigurationProcessor(context);
+
+ // Get the public render parameter mappings
+ mPublicParameterMappings = processor.getPublicParameterMappings();
+
+ // Get the write-behind response wrapper mappings
+ mWriteBehindRenderResponseWrapper = validateWrapperClass(processor.getWriteBehindRenderResponseWrapperClassName());
+ mWriteBehindResourceResponseWrapper = validateWrapperClass(processor.getWriteBehindResourceResponseWrapperClassName());
+
+ // Update the excluded attributes list
List<String> list = processor.getExcludedAttributes();
- if (list == null)
+ if (list != null)
{
- return;
+ ListIterator<String> i = (ListIterator<String>) list.listIterator();
+ while (i.hasNext())
+ {
+ String attr = i.next();
+ if (!mExcludedRequestAttributes.contains(attr))
+ {
+ mExcludedRequestAttributes.add(attr);
+ }
+ }
+ }
+
+ }
+
+ private Class<? extends BridgeWriteBehindResponse> validateWrapperClass(String className)
+ {
+ if (className == null)
+ {
+ return null;
}
- ListIterator<String> i = (ListIterator<String>) list.listIterator();
- while (i.hasNext())
+ try
{
- String attr = i.next();
- if (!excludedAttributes.contains(attr))
- {
- excludedAttributes.add(attr);
- }
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ return (Class<? extends BridgeWriteBehindResponse>) loader.loadClass(className);
+ }
+ catch (Exception e)
+ {
+ return null;
}
}
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/util/config/FacesConfigurationProcessor.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/util/config/FacesConfigurationProcessor.java?rev=987340&r1=987339&r2=987340&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/util/config/FacesConfigurationProcessor.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/util/config/FacesConfigurationProcessor.java Thu Aug 19 22:43:43 2010
@@ -50,6 +50,8 @@ public class FacesConfigurationProcessor
private static final String FACES_CONFIG_WEBINF_PATH = "/WEB-INF/faces-config.xml";
private List<String> mExcludedAttributes = null;
private Map<String, String> mPublicParameterMappings = null;
+ private String mWriteBehindRenderResponseWrapper = null;
+ private String mWriteBehindResourceResponseWrapper = null;
/**
* <p>
@@ -78,6 +80,16 @@ public class FacesConfigurationProcessor
{
return mPublicParameterMappings;
}
+
+ public String getWriteBehindRenderResponseWrapperClassName()
+ {
+ return mWriteBehindRenderResponseWrapper;
+ }
+
+ public String getWriteBehindResourceResponseWrapperClassName()
+ {
+ return mWriteBehindResourceResponseWrapper;
+ }
/**
* <p>
@@ -176,6 +188,10 @@ public class FacesConfigurationProcessor
private static final String PUBLIC_PARAMETER_MAPPING_ELEMENT = "public-parameter-mapping";
private static final String PARAMETER_ELEMENT = "parameter";
private static final String MODEL_EL_ELEMENT = "model-el";
+ private static final String WRITE_BEHIND_RESPONSE_WRAPPERS_ELEMENT = "write-behind-response-wrappers";
+ private static final String RENDER_RESPONSE_WRAPPER_CLASS_ELEMENT = "render-response-wrapper-class";
+ private static final String RESOURCE_RESPONSE_WRAPPER_CLASS_ELEMENT = "resource-response-wrapper-class";
+
private boolean mInApplicationElement = false;
@@ -185,6 +201,8 @@ public class FacesConfigurationProcessor
private boolean mInPublicParameterMapping = false;
private boolean mInParameter = false;
private boolean mInModelEL = false;
+ private boolean mInWriteBehindResponseWrappers = false;
+
private StringBuilder mContent;
@@ -249,6 +267,19 @@ public class FacesConfigurationProcessor
mContent = new StringBuilder();
}
}
+ else if (WRITE_BEHIND_RESPONSE_WRAPPERS_ELEMENT.equals(localName))
+ {
+ mInWriteBehindResponseWrappers = true;
+ }
+ else if (RENDER_RESPONSE_WRAPPER_CLASS_ELEMENT.equals(localName) || RESOURCE_RESPONSE_WRAPPER_CLASS_ELEMENT.equals(localName))
+ {
+ if (mInApplicationElement && mInApplicationExtensionElement &&
+ mInWriteBehindResponseWrappers)
+ {
+ mContent = new StringBuilder();
+ }
+ }
+
} // END startElement
@Override
@@ -328,6 +359,22 @@ public class FacesConfigurationProcessor
// hold mContent to add as pair later
mContent2 = mContent.toString().trim();
}
+ else if (WRITE_BEHIND_RESPONSE_WRAPPERS_ELEMENT.equals(localName))
+ {
+ mInWriteBehindResponseWrappers = false;
+ }
+ else if (RENDER_RESPONSE_WRAPPER_CLASS_ELEMENT.equals(localName) && mContent != null
+ && mContent.length() > 0)
+ {
+ // hold mContent to add as pair later
+ mWriteBehindRenderResponseWrapper = mContent.toString().trim();
+ }
+ else if (RESOURCE_RESPONSE_WRAPPER_CLASS_ELEMENT.equals(localName) && mContent != null
+ && mContent.length() > 0)
+ {
+ // hold mContent to add as pair later
+ mWriteBehindResourceResponseWrapper = mContent.toString().trim();
+ }
mContent = null;
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaders.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaders.java?rev=987340&r1=987339&r2=987340&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaders.java (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/java/org/apache/myfaces/portlet/faces/util/map/PortletRequestHeaders.java Thu Aug 19 22:43:43 2010
@@ -235,9 +235,18 @@ public class PortletRequestHeaders
if (contentType != null)
{
- property = property.append(contentType);
if (charset != null)
{
+ // remove existing charset if its there -- it might be incorrect in a wsrp world
+ int index = contentType.indexOf(";");
+ if (index < 0)
+ {
+ property = property.append(contentType);
+ }
+ else
+ {
+ property = property.append(contentType, 0, index);
+ }
property = property.append("; charset=");
property = property.append(charset);
}
Modified: myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/resources/META-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/resources/META-INF/faces-config.xml?rev=987340&r1=987339&r2=987340&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/resources/META-INF/faces-config.xml (original)
+++ myfaces/portlet-bridge/core/trunk_2.0.x/impl/src/main/resources/META-INF/faces-config.xml Thu Aug 19 22:43:43 2010
@@ -34,7 +34,21 @@
<bridge:excluded-attribute>org.apache.myfaces.el.unified.resolver.managedbean.*</bridge:excluded-attribute>
<bridge:excluded-attribute>org.apache.myfaces.shared_impl.renderkit.RendererUtils.*</bridge:excluded-attribute>
<bridge:excluded-attribute>org.apache.myfaces.application.DefaultViewHandlerSupport.*</bridge:excluded-attribute>
+ <bridge:excluded-attribute>javax.servlet.jsp.*</bridge:excluded-attribute>
+ <bridge:excluded-attribute>javax.servlet.jsp.jstl.*</bridge:excluded-attribute>
+ <bridge:excluded-attribute>javax.servlet.jsp.jstl.font.*</bridge:excluded-attribute>
+ <bridge:excluded-attribute>javax.faces.webapp.*</bridge:excluded-attribute>
<bridge:excluded-attribute>jsf_sequence</bridge:excluded-attribute>
+ <bridge:excluded-attribute>org.apache.myfaces.trinidadinternal.*</bridge:excluded-attribute>
+ <bridge:excluded-attribute>org.apache.myfaces.trinidadinternal.application.*</bridge:excluded-attribute>
+ <bridge:excluded-attribute>org.apache.myfaces.trinidadinternal.config.*</bridge:excluded-attribute>
+ <bridge:excluded-attribute>org.apache.myfaces.trinidadinternal.config.dispatch.DispatchResponseConfiguratorImpl.*</bridge:excluded-attribute>
+ <bridge:excluded-attribute>org.apache.myfaces.trinidadinternal.context.*</bridge:excluded-attribute>
+ <bridge:excluded-attribute>org.apache.myfaces.trinidadinternal.context.AdfFacesPhaseListener.*</bridge:excluded-attribute>
+ <bridge:excluded-attribute>org.apache.myfaces.trinidadinternal.context.FacesContxtFactoryImpl.*</bridge:excluded-attribute>
+ <bridge:excluded-attribute>org.apache.myfaces.trinidadinternal.dispatch.*</bridge:excluded-attribute>
+ <bridge:excluded-attribute>org.apache.myfaces.trinidadinternal.renderkit.*</bridge:excluded-attribute>
+ <bridge:excluded-attribute>org.apache.myfaces.trinidadinternal.uinode.*</bridge:excluded-attribute>
</bridge:excluded-attributes>
</application-extension>
</application>