You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by so...@apache.org on 2009/12/09 22:47:03 UTC
svn commit: r888995 - in
/myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0: ./ api/
api/src/main/java/javax/portlet/faces/component/ examples/blank/
examples/blank/src/main/webapp/WEB-INF/ examples/demo/
examples/demo/src/main/webapp/W...
Author: sobryan
Date: Wed Dec 9 21:47:02 2009
New Revision: 888995
URL: http://svn.apache.org/viewvc?rev=888995&view=rev
Log:
Initial modifications
* Ported over some of Mike Feedman's changes from his JSF 2.0 Branch
* Deleted the PortletFacesContextImpl
* Deleted the FacesContextFactoryImpl
* Deleted the Services entry for the FacesContextFactoryImpl
* Added an FacesExternalContextFacotryImpl
* Added a Services entry for the FacesExternalContextFactoryImpl
* Modified all the POM's to build against JSF 2.0.1
* Modified all the POM's to reflect Portlet Bridge 3.0-SNAPSHOT
Added:
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesExternalContextFactoryImpl.java
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/resources/META-INF/services/javax.faces.context.ExternalContextFactory
Removed:
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesContextFactoryImpl.java
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletFacesContextImpl.java
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/resources/META-INF/services/javax.faces.context.FacesContextFactory
Modified:
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/api/pom.xml
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/api/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/blank/pom.xml
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/blank/src/main/webapp/WEB-INF/web.xml
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/demo/pom.xml
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/demo/src/main/webapp/WEB-INF/web.xml
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/pom.xml
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletApplicationImpl.java
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/pom.xml
Modified: myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/api/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/api/pom.xml?rev=888995&r1=888994&r2=888995&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/api/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/api/pom.xml Wed Dec 9 21:47:02 2009
@@ -51,7 +51,7 @@
<dependency>
<artifactId>jsf-api</artifactId>
- <groupId>javax.faces</groupId>
+ <groupId>com.sun.faces</groupId>
</dependency>
</dependencies>
Modified: myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/api/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/api/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java?rev=888995&r1=888994&r2=888995&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/api/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java (original)
+++ myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/api/src/main/java/javax/portlet/faces/component/PortletNamingContainerUIViewRoot.java Wed Dec 9 21:47:02 2009
@@ -40,8 +40,6 @@
public PortletNamingContainerUIViewRoot()
{
- super();
-
getAttributes().put(PORTLET_ENCODED_NAMESPACE_ID, Boolean.FALSE);
}
Modified: myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/blank/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/blank/pom.xml?rev=888995&r1=888994&r2=888995&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/blank/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/blank/pom.xml Wed Dec 9 21:47:02 2009
@@ -148,7 +148,7 @@
</activation>
<dependencies>
<dependency>
- <groupId>javax.faces</groupId>
+ <groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
</dependency>
</dependencies>
@@ -176,12 +176,12 @@
</repositories>
<dependencies>
<dependency>
- <groupId>javax.faces</groupId>
+ <groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>javax.faces</groupId>
+ <groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${jsf.version}</version>
<scope>runtime</scope>
Modified: myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/blank/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/blank/src/main/webapp/WEB-INF/web.xml?rev=888995&r1=888994&r2=888995&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/blank/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/blank/src/main/webapp/WEB-INF/web.xml Wed Dec 9 21:47:02 2009
@@ -1,5 +1,4 @@
<?xml version = '1.0' encoding = 'ISO-8859-1'?>
-<!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -20,8 +19,10 @@
-->
<!-- The Jetty Pluto Plugin needs to have a Webapp 2.3 web-xml. Don't know why. -->
-<web-app>
- <context-param>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+ <context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsp</param-value>
</context-param>
Modified: myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/demo/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/demo/pom.xml?rev=888995&r1=888994&r2=888995&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/demo/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/demo/pom.xml Wed Dec 9 21:47:02 2009
@@ -172,7 +172,7 @@
</activation>
<dependencies>
<dependency>
- <groupId>javax.faces</groupId>
+ <groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
</dependency>
</dependencies>
@@ -200,12 +200,12 @@
</repositories>
<dependencies>
<dependency>
- <groupId>javax.faces</groupId>
+ <groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>javax.faces</groupId>
+ <groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${jsf.version}</version>
<scope>runtime</scope>
Modified: myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/demo/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/demo/src/main/webapp/WEB-INF/web.xml?rev=888995&r1=888994&r2=888995&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/demo/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/examples/demo/src/main/webapp/WEB-INF/web.xml Wed Dec 9 21:47:02 2009
@@ -1,5 +1,4 @@
<?xml version = '1.0' encoding = 'ISO-8859-1'?>
-<!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -20,7 +19,9 @@
-->
<!-- The Jetty Pluto Plugin needs to have a Webapp 2.3 web-xml. Don't know why. -->
-<web-app>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsp</param-value>
Modified: myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/pom.xml?rev=888995&r1=888994&r2=888995&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/pom.xml Wed Dec 9 21:47:02 2009
@@ -44,7 +44,7 @@
<dependency>
<artifactId>jsf-api</artifactId>
- <groupId>javax.faces</groupId>
+ <groupId>com.sun.faces</groupId>
</dependency>
<dependency>
Modified: myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletApplicationImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletApplicationImpl.java?rev=888995&r1=888994&r2=888995&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletApplicationImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletApplicationImpl.java Wed Dec 9 21:47:02 2009
@@ -35,10 +35,8 @@
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
-import javax.faces.el.ReferenceSyntaxException;
import javax.portlet.faces.BridgeUtil;
-import javax.portlet.faces.annotation.ExcludeFromManagedRequestScope;
import javax.portlet.faces.annotation.PortletNamingContainer;
import javax.portlet.faces.component.PortletNamingContainerUIViewRoot;
@@ -159,6 +157,7 @@
*
* @deprecated
*/
+ @Deprecated
public javax.faces.el.PropertyResolver getPropertyResolver()
{
return mWrapped.getPropertyResolver();
@@ -167,6 +166,7 @@
/**
* @deprecated
*/
+ @Deprecated
public void setPropertyResolver(javax.faces.el.PropertyResolver resolver)
{
mWrapped.setPropertyResolver(resolver);
@@ -177,6 +177,7 @@
*
* @deprecated
*/
+ @Deprecated
public javax.faces.el.VariableResolver getVariableResolver()
{
return mWrapped.getVariableResolver();
@@ -185,6 +186,7 @@
/**
* @deprecated
*/
+ @Deprecated
public void setVariableResolver(javax.faces.el.VariableResolver resolver)
{
mWrapped.setVariableResolver(resolver);
@@ -265,6 +267,7 @@
*
* @deprecated
*/
+ @Deprecated
public javax.faces.component.UIComponent createComponent(
javax.faces.el.ValueBinding componentBinding,
javax.faces.context.FacesContext context,
@@ -306,7 +309,8 @@
return mWrapped.getConverterIds();
}
- public Iterator<Class> getConverterTypes()
+ @Override
+ public Iterator<Class<?>> getConverterTypes()
{
return mWrapped.getConverterTypes();
}
@@ -322,9 +326,10 @@
*
* @deprecated
*/
+ @Deprecated
public javax.faces.el.MethodBinding createMethodBinding(
String ref, Class[] params)
- throws ReferenceSyntaxException
+ throws javax.faces.el.ReferenceSyntaxException
{
return mWrapped.createMethodBinding(ref, params);
}
@@ -367,8 +372,9 @@
*
* @deprecated
*/
+ @Deprecated
public javax.faces.el.ValueBinding createValueBinding(String ref)
- throws ReferenceSyntaxException
+ throws javax.faces.el.ReferenceSyntaxException
{
return mWrapped.createValueBinding(ref);
}
Modified: myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java?rev=888995&r1=888994&r2=888995&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/application/PortletViewHandlerImpl.java Wed Dec 9 21:47:02 2009
@@ -87,7 +87,7 @@
mDelegate = handler;
}
- protected ViewHandler getWrapped()
+ public ViewHandler getWrapped()
{
return mDelegate;
}
Modified: myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java?rev=888995&r1=888994&r2=888995&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/bridge/BridgeImpl.java Wed Dec 9 21:47:02 2009
@@ -1161,7 +1161,7 @@
{
try
{
- methods[i].invoke(o, null);
+ methods[i].invoke(o);
}
catch (Exception e)
{
@@ -2129,7 +2129,7 @@
{
try
{
- methods[m].invoke(o, null);
+ methods[m].invoke(o);
}
catch (Exception e)
{
Added: myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesExternalContextFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesExternalContextFactoryImpl.java?rev=888995&view=auto
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesExternalContextFactoryImpl.java (added)
+++ myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/context/FacesExternalContextFactoryImpl.java Wed Dec 9 21:47:02 2009
@@ -0,0 +1,128 @@
+package org.apache.myfaces.portlet.faces.context;
+
+import javax.faces.FacesException;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.ExternalContextFactory;
+
+import javax.faces.context.FacesContext;
+
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.faces.Bridge;
+
+import javax.servlet.ServletRequest;
+
+public class FacesExternalContextFactoryImpl
+ extends ExternalContextFactory
+{
+ private ExternalContextFactory mWrapped;
+
+ public FacesExternalContextFactoryImpl(ExternalContextFactory factory)
+ {
+ mWrapped = factory;
+ }
+
+ public ExternalContext getExternalContext(Object context, Object request,
+ Object response)
+ throws FacesException
+ {
+ // if in portlet environment -- do a portlet container neutral test
+ // first in case we are packaged in a web app that isn't deployed
+ // on a portlet container/as a portlet. Note: can't use the BridgeUtil
+ // method as that call requires the facesContext to exist.
+ if (isPortletRequest(request))
+ {
+ // As its possible an in-protocol resource needs to access the FacesContext
+ // hence we could be passed the servlet objects in a portlet request
+ // try converting back to the portlet objects
+ Object pTemp = null;
+ PortletRequest pRequest = null;
+ ServletRequest sRequest = null;
+
+ if (request instanceof PortletRequest)
+ pRequest = (PortletRequest) request;
+ else if (request instanceof ServletRequest)
+ sRequest = (ServletRequest) request;
+
+ if (!(context instanceof PortletContext))
+ {
+ if (pRequest != null)
+ {
+ pTemp = pRequest.getAttribute("javax.portlet.config");
+ }
+ else if (sRequest != null)
+ {
+ pTemp = sRequest.getAttribute("javax.portlet.config");
+ }
+
+ if (pTemp != null) context = ((PortletConfig) pTemp).getPortletContext();
+ }
+ if (!(response instanceof PortletResponse))
+ {
+ if (pRequest != null)
+ {
+ pTemp = pRequest.getAttribute("javax.portlet.response");
+ }
+ else if (sRequest != null)
+ {
+ pTemp = sRequest.getAttribute("javax.portlet.response");
+ }
+
+ if (pTemp != null) response = pTemp;
+ }
+ if (!(request instanceof PortletRequest))
+ {
+ if (sRequest != null)
+ {
+ pTemp = sRequest.getAttribute("javax.portlet.request");
+ }
+
+ if (pTemp != null) request = pTemp;
+ }
+
+ // make sure they passed the right objects
+ if (context instanceof PortletContext && request instanceof PortletRequest
+ && response instanceof PortletResponse)
+ {
+ return new PortletExternalContextImpl((PortletContext) context, (PortletRequest) request, (PortletResponse) response);
+ }
+ else
+ {
+ throw new FacesException("getExternalContext failed: Running in a portlet request but not passed portlet objects");
+ }
+ }
+ else
+ {
+ // otherwise, delegate
+ return getWrapped().getExternalContext(context, request, response);
+ }
+ }
+
+ @Override
+ public ExternalContextFactory getWrapped()
+ {
+ return mWrapped;
+ }
+
+ private boolean isPortletRequest(Object request)
+ {
+ // could be either a servlet or portlet request object (or both)
+ // Check servlet side first in case we are packaged in an application
+ // that is running as a servlet in an environment that doesn't contain
+ // a portlet container.
+ if (request instanceof ServletRequest)
+ {
+ ServletRequest sr = (ServletRequest) request;
+ Bridge.PortletPhase phase = (Bridge.PortletPhase) sr.getAttribute(Bridge.PORTLET_LIFECYCLE_PHASE);
+ return (phase != null);
+ }
+ else if (request instanceof PortletRequest)
+ {
+ return true;
+ }
+
+ return false;
+ }
+}
Modified: myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java?rev=888995&r1=888994&r2=888995&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java (original)
+++ myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/java/org/apache/myfaces/portlet/faces/context/PortletExternalContextImpl.java Wed Dec 9 21:47:02 2009
@@ -21,8 +21,11 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+
import java.net.MalformedURLException;
import java.net.URL;
@@ -43,6 +46,7 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
+import javax.faces.context.Flash;
import javax.faces.render.ResponseStateManager;
import javax.portlet.ActionResponse;
@@ -55,6 +59,7 @@
import javax.portlet.PortletRequest;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.PortletResponse;
+import javax.portlet.PortletSession;
import javax.portlet.PortletURL;
import javax.portlet.RenderResponse;
import javax.portlet.ResourceURL;
@@ -64,6 +69,8 @@
import javax.portlet.faces.BridgeDefaultViewNotSpecifiedException;
import javax.portlet.faces.BridgeInvalidViewPathException;
+import javax.servlet.http.Cookie;
+
import org.apache.myfaces.portlet.faces.bridge.BridgeImpl;
import org.apache.myfaces.portlet.faces.util.FacesVersionUtil;
import org.apache.myfaces.portlet.faces.util.QueryString;
@@ -145,6 +152,13 @@
private String mIncludedPathInfo = null;
private boolean mUseIncludeAttributeServletDependencyWorkaround;
+
+ private enum ALLOWABLE_COOKIE_PROPERTIES {
+ domain,
+ maxAge,
+ path,
+ secure
+ }
@SuppressWarnings("unchecked")
public PortletExternalContextImpl(PortletContext portletContext, PortletRequest portletRequest,
@@ -240,6 +254,66 @@
mViewId = null;
}
+
+ /**
+ * @see ExternalContext#addResponseHeader(String, String)
+ * @param name
+ * @param value
+ */
+ @Override
+ public void addResponseHeader(String name, String value)
+ {
+ mPortletResponse.addProperty(name, value);
+ }
+
+ /**
+ * @see ExternalContext#setResponseHeader(String, String)
+ * @param name
+ * @param value
+ */
+ @Override
+ public void setResponseHeader(String name, String value)
+ {
+ mPortletResponse.setProperty(name, value);
+ }
+
+ /**
+ * @see ExternalContext#addResponseCookie(String, String, java.util.Map)
+ * @param name
+ * @param value
+ * @param properties
+ */
+ @Override
+ public void addResponseCookie(String name,
+ String value,
+ Map<String,Object> properties) {
+
+ Cookie cookie = new Cookie(name, value);
+ if (properties != null && properties.size() != 0) {
+ for (Map.Entry<String,Object> entry : properties.entrySet()) {
+ String key = entry.getKey();
+ ALLOWABLE_COOKIE_PROPERTIES p = ALLOWABLE_COOKIE_PROPERTIES.valueOf(key);
+ Object v = entry.getValue();
+ switch (p) {
+ case domain:
+ cookie.setDomain((String) v);
+ break;
+ case maxAge:
+ cookie.setMaxAge((Integer) v);
+ break;
+ case path:
+ cookie.setPath((String) v);
+ break;
+ case secure:
+ cookie.setSecure((Boolean) v);
+ break;
+ default:
+ throw new IllegalStateException(); // shouldn't happen
+ }
+ }
+ }
+ mPortletResponse.addProperty(cookie);
+ }
/**
* This method is the gatekeeper for managing the viewId across action/render + subsequent
@@ -873,6 +947,14 @@
return mPortletContext;
}
+ /**
+ * @see javax.faces.context.ExternalContext#getContextName()
+ */
+ public String getContextName()
+ {
+ return mPortletContext.getPortletContextName();
+ }
+
@Override
public Object getRequest()
{
@@ -905,6 +987,19 @@
return mSessionMap;
}
+ /**
+ * @see javax.faces.context.ExternalContext#invalidateSession()
+ */
+ @Override
+ public void invalidateSession() {
+
+ PortletSession session = mPortletRequest.getPortletSession(false);
+ if (session != null) {
+ session.invalidate();
+ }
+
+ }
+
@Override
public Map<String, Object> getRequestMap()
{
@@ -998,6 +1093,33 @@
return mPortletRequest.getLocale();
}
+ /**
+ * @see javax.faces.context.ExternalContext#getRequestScheme()
+ */
+ @Override
+ public String getRequestScheme()
+ {
+ return mPortletRequest.getScheme();
+ }
+
+ /**
+ * @see javax.faces.context.ExternalContext#getRequestServerName()
+ */
+ @Override
+ public String getRequestServerName()
+ {
+ return mPortletRequest.getServerName();
+ }
+
+ /**
+ * @see javax.faces.context.ExternalContext#getRequestServerPort()
+ */
+ @Override
+ public int getRequestServerPort()
+ {
+ return mPortletRequest.getServerPort();
+ }
+
@Override
public String getRequestPathInfo()
{
@@ -1032,17 +1154,36 @@
return mInitParameterMap;
}
+ /**
+ * @see ExternalContext#getMimeType(String)
+ */
+ @Override
+ public String getMimeType(String file) {
+ return mPortletContext.getMimeType(file);
+ }
+
+ /**
+ * @see ExternalContext#getRealPath(String)
+ */
+ @Override
+ public String getRealPath(String path) {
+ return mPortletContext.getRealPath(path);
+ }
+
+ @Override
@SuppressWarnings("unchecked")
public Set<String> getResourcePaths(String s)
{
return mPortletContext.getResourcePaths(s);
}
+ @Override
public InputStream getResourceAsStream(String s)
{
return mPortletContext.getResourceAsStream(s);
}
+ @Override
public String encodeNamespace(String s)
{
return ((PortletResponse) mPortletResponse).getNamespace() + s;
@@ -1190,7 +1331,8 @@
try
{
((ClientDataRequest) mPortletRequest).setCharacterEncoding(encoding);
- } catch (IllegalStateException e)
+ }
+ catch (IllegalStateException e)
{
// Swallow this exception and proceed as if a noop.
}
@@ -1204,6 +1346,24 @@
}
/**
+ * @see ExternalContext#setResponseContentType(String)
+ * @param contentType
+ */
+ @Override
+ public void setResponseContentType(String contentType)
+ {
+ if (mPortletResponse instanceof MimeResponse)
+ {
+ ((MimeResponse)mPortletResponse).setContentType(contentType);
+ }
+ else
+ {
+ throw new IllegalStateException("PortletExternalContextImpl.setResponseContentType(): Response must be a MimeResponse");
+ }
+
+ }
+
+ /**
*
* <p>
* Return the character encoding currently being used to interpret this request.
@@ -1242,6 +1402,21 @@
}
/**
+ * @see javax.faces.context.ExternalContext#getRequestContentLength()
+ */
+ @Override
+ public int getRequestContentLength() {
+ if (mPortletRequest instanceof ClientDataRequest)
+ {
+ return (((ClientDataRequest)mPortletRequest).getContentLength());
+ }
+ else
+ {
+ throw new IllegalStateException("PortletExternalContextImpl.getRequestContentLength(): Request must be a ClientDataRequest");
+ }
+ }
+
+ /**
*
* <p>
* Return the MIME Content-Type for this request. If not available, return <code>null</code>.
@@ -1351,6 +1526,23 @@
}
/**
+ * @see javax.faces.context.ExternalContext#getResponseOutputStream()
+ */
+ @Override
+ public OutputStream getResponseOutputStream() throws IOException
+ {
+ if (mPortletResponse instanceof MimeResponse)
+ {
+ return ((MimeResponse)mPortletResponse).getPortletOutputStream();
+ }
+ else
+ {
+ throw new IllegalStateException("PortletExternalContextImpl.getResponseOutputStream(): Response must be a MimeResponse");
+ }
+
+ }
+
+ /**
* <p>
* Set the environment-specific response to be returned by subsequent calls to
* {@link #getResponse}. This may be used to install a wrapper for the response.
@@ -2139,5 +2331,4 @@
return false;
}
-
}
Added: myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/resources/META-INF/services/javax.faces.context.ExternalContextFactory
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/resources/META-INF/services/javax.faces.context.ExternalContextFactory?rev=888995&view=auto
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/resources/META-INF/services/javax.faces.context.ExternalContextFactory (added)
+++ myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/impl/src/main/resources/META-INF/services/javax.faces.context.ExternalContextFactory Wed Dec 9 21:47:02 2009
@@ -0,0 +1 @@
+org.apache.myfaces.portlet.faces.context.FacesExternalContextFactory
Modified: myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/pom.xml?rev=888995&r1=888994&r2=888995&view=diff
==============================================================================
--- myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/pom.xml (original)
+++ myfaces/portlet-bridge/core/branches/sobryan_portlet-bridge-3.0.0/pom.xml Wed Dec 9 21:47:02 2009
@@ -42,15 +42,15 @@
</parent>
<properties>
- <latestRelease>2.0.0-alpha-2</latestRelease>
+ <latestRelease>3.0.0-SNAPSHOT</latestRelease>
<portletSpecVersion>2.0</portletSpecVersion>
- <jsfSpecVersion>1.2</jsfSpecVersion>
+ <jsfSpecVersion>2.0</jsfSpecVersion>
<specVersion>1.0</specVersion>
<jsrNumber>N/A</jsrNumber>
<specLink>http://www.jcp.org/en/jsr/detail?id=${jsrNumber}</specLink>
<specName>Portlet ${portletSpecVersion} Bridge for JavaServer Faces ${jsfSpecVersion}</specName>
<projectSeries>3.x</projectSeries>
- <jsf.version>1.2_03</jsf.version>
+ <jsf.version>2.0.1</jsf.version>
</properties>
<!-- issueManagement is in parent -->
@@ -117,19 +117,19 @@
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
- <version>1.2.2</version>
+ <version>2.0.0-alpha</version>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
- <version>1.2.2</version>
+ <version>2.0.0-alpha</version>
<scope>runtime</scope>
</dependency>
<!-- JSF R.I. API -->
<dependency>
- <groupId>javax.faces</groupId>
+ <groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<!-- As per spec, 1.2_03 is the minimum R.I. for version 1.0 bridge -->
<version>${jsf.version}</version>