You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2008/10/22 10:01:06 UTC

svn commit: r706881 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/ajax/api/ core/src/main/java/org/apache/myfaces/tobago/application/ core/src/main/java/org/apache/myfaces/tobago/lifecycle/ core/src/main/java/org/apache/myfac...

Author: lofwyr
Date: Wed Oct 22 01:01:05 2008
New Revision: 706881

URL: http://svn.apache.org/viewvc?rev=706881&view=rev
Log:
TOBAGO-633: Portlet
* working on Portlet support
* add a simple example woring with Liferay

Added:
    myfaces/tobago/trunk/example/portlet/
    myfaces/tobago/trunk/example/portlet/pom.xml
    myfaces/tobago/trunk/example/portlet/src/
    myfaces/tobago/trunk/example/portlet/src/main/
    myfaces/tobago/trunk/example/portlet/src/main/java/
    myfaces/tobago/trunk/example/portlet/src/main/resources/
    myfaces/tobago/trunk/example/portlet/src/main/webapp/
    myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/
    myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/faces-config.xml
    myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/liferay-portlet.xml
    myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/portlet.xml
    myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/web.xml
    myfaces/tobago/trunk/example/portlet/src/main/webapp/hello.jsp
    myfaces/tobago/trunk/example/portlet/src/main/webapp/index.jsp
    myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/portlet/
    myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/portlet/PortletUtils.java
Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/application/ViewHandlerImpl.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/RestoreViewExecutor.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/TobagoLifecycle.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ResponseUtils.java
    myfaces/tobago/trunk/example/pom.xml
    myfaces/tobago/trunk/tobago-jsf-compat/pom.xml
    myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/RequestUtils.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java?rev=706881&r1=706880&r2=706881&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/ajax/api/AjaxResponseRenderer.java Wed Oct 22 01:01:05 2008
@@ -20,15 +20,15 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_CHARSET;
-import org.apache.myfaces.tobago.util.ComponentUtil;
+import org.apache.myfaces.tobago.compat.FacesUtils;
+import org.apache.myfaces.tobago.context.TobagoFacesContext;
 import static org.apache.myfaces.tobago.lifecycle.TobagoLifecycle.FACES_MESSAGES_KEY;
 import static org.apache.myfaces.tobago.lifecycle.TobagoLifecycle.VIEW_ROOT_KEY;
+import org.apache.myfaces.tobago.util.ComponentUtil;
 import org.apache.myfaces.tobago.util.EncodeAjaxCallback;
 import org.apache.myfaces.tobago.util.RequestUtils;
 import org.apache.myfaces.tobago.util.ResponseUtils;
-import org.apache.myfaces.tobago.compat.FacesUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseJsonWriterImpl;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
 
 import javax.faces.FactoryFinder;
 import javax.faces.application.StateManager;
@@ -104,7 +104,7 @@
 
   private void renderComponent(FacesContext facesContext, RenderKit renderKit, String clientId,
       AjaxComponent component) throws IOException {
-    PrintWriter writer = getPrintWriter(facesContext.getExternalContext());
+    PrintWriter writer = getPrintWriter(facesContext);
     ResponseWriter contentWriter = renderKit.createResponseWriter(writer, contentType, null);
     facesContext.setResponseWriter(contentWriter);
 
@@ -139,7 +139,7 @@
   private void saveState(FacesContext facesContext, RenderKit renderKit)
       throws IOException {
     ResponseWriter stateWriter =
-        renderKit.createResponseWriter(getPrintWriter(facesContext.getExternalContext()), contentType, null);
+        renderKit.createResponseWriter(getPrintWriter(facesContext), contentType, null);
     facesContext.setResponseWriter(stateWriter);
 
     StateManager stateManager = facesContext.getApplication().getStateManager();
@@ -165,9 +165,8 @@
   private void writeResponse(FacesContext facesContext, RenderKit renderKit, boolean reloadRequired)
       throws IOException {
 
-    ExternalContext externalContext = facesContext.getExternalContext();
-    RequestUtils.ensureEncoding(externalContext);
-    ResponseUtils.ensureNoCacheHeader(externalContext);
+    RequestUtils.ensureEncoding(facesContext);
+    ResponseUtils.ensureNoCacheHeader(facesContext);
     UIComponent page = ComponentUtil.findPage(facesContext);
     String charset;
     if (page != null) {  // in case of CODE_RELOAD_REQUIRED page is null
@@ -177,7 +176,7 @@
     }
     ensureContentTypeHeader(facesContext, charset, contentType);
 
-    PrintWriter writer = getPrintWriter(externalContext);
+    PrintWriter writer = getPrintWriter(facesContext);
     writer.write("{\n  tobagoAjaxResponse: true,\n");
     writer.write("  responseCode: ");
     writer.write(reloadRequired ? Integer.toString(CODE_RELOAD_REQUIRED) : Integer.toString(CODE_SUCCESS));
@@ -209,7 +208,8 @@
     writer.close();
   }
 
-  private PrintWriter getPrintWriter(ExternalContext externalContext) throws IOException {
+  private PrintWriter getPrintWriter(FacesContext facesContext) throws IOException {
+    ExternalContext externalContext = facesContext.getExternalContext();
     //TODO: fix this to work in PortletRequest as well
     if (externalContext.getResponse() instanceof HttpServletResponse) {
       final HttpServletResponse httpServletResponse

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/application/ViewHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/application/ViewHandlerImpl.java?rev=706881&r1=706880&r2=706881&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/application/ViewHandlerImpl.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/application/ViewHandlerImpl.java Wed Oct 22 01:01:05 2008
@@ -19,8 +19,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.tobago.util.RequestUtils;
+import org.apache.myfaces.tobago.portlet.PortletUtils;
 import org.apache.myfaces.tobago.util.DebugUtils;
+import org.apache.myfaces.tobago.util.RequestUtils;
 
 import javax.faces.FacesException;
 import javax.faces.application.ViewHandler;
@@ -72,6 +73,11 @@
   }
 
   public String getActionURL(FacesContext facesContext, String viewId) {
+
+    if (PortletUtils.isRenderResponse(facesContext)) {
+      return PortletUtils.setViewIdForUrl(facesContext, viewId);
+    }
+
     return base.getActionURL(facesContext, viewId);
   }
 
@@ -96,7 +102,7 @@
     }
     // this is only needed in the first request, the later will be handled by faces
     // TODO: maybe find a way to make this unneeded
-    RequestUtils.ensureEncoding(facesContext.getExternalContext());
+    RequestUtils.ensureEncoding(facesContext);
     UIViewRoot viewRoot = base.restoreView(facesContext, viewId);
     return viewRoot;
   }

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/RestoreViewExecutor.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/RestoreViewExecutor.java?rev=706881&r1=706880&r2=706881&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/RestoreViewExecutor.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/RestoreViewExecutor.java Wed Oct 22 01:01:05 2008
@@ -17,18 +17,17 @@
  * limitations under the License.
  */
 
-import static org.apache.myfaces.tobago.lifecycle.TobagoLifecycle.FACES_MESSAGES_KEY;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
+import static org.apache.myfaces.tobago.lifecycle.TobagoLifecycle.FACES_MESSAGES_KEY;
 import static org.apache.myfaces.tobago.lifecycle.TobagoLifecycle.VIEW_ROOT_KEY;
+import org.apache.myfaces.tobago.portlet.PortletUtils;
 import org.apache.myfaces.tobago.util.ComponentUtil;
 
 import javax.faces.FacesException;
 import javax.faces.application.Application;
-import javax.faces.application.ViewHandler;
 import javax.faces.application.FacesMessage;
+import javax.faces.application.ViewHandler;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIInput;
 import javax.faces.component.UIViewRoot;
@@ -39,10 +38,8 @@
 import java.io.IOException;
 import java.lang.reflect.Method;
 import java.util.Iterator;
-import java.util.Map;
 import java.util.List;
-//import org.apache.myfaces.portlet.MyFacesGenericPortlet;
-//import org.apache.myfaces.portlet.PortletUtil;
+import java.util.Map;
 
 /**
  * Implements the lifecycle as described in Spec. 1.0 PFD Chapter 2
@@ -134,11 +131,9 @@
   private static String deriveViewId(FacesContext facesContext) {
     ExternalContext externalContext = facesContext.getExternalContext();
 
-    // TODO: Portlet
-//    if (PortletUtil.isPortletRequest(facesContext)) {
-//      PortletRequest request = (PortletRequest) externalContext.getRequest();
-//      return request.getParameter(MyFacesGenericPortlet.VIEW_ID);
-//    }
+    if (PortletUtils.isPortletRequest(facesContext)) {
+      return PortletUtils.getViewId(facesContext);
+    }
 
     String viewId = externalContext.getRequestPathInfo(); // getPathInfo
     if (viewId == null) {

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/TobagoLifecycle.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/TobagoLifecycle.java?rev=706881&r1=706880&r2=706881&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/TobagoLifecycle.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/lifecycle/TobagoLifecycle.java Wed Oct 22 01:01:05 2008
@@ -17,21 +17,19 @@
  * limitations under the License.
  */
 
-import java.util.ArrayList;
-import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.tobago.context.TobagoFacesContext;
+import org.apache.myfaces.tobago.util.DebugUtils;
+import org.apache.myfaces.tobago.util.RequestUtils;
 
 import javax.faces.FacesException;
 import javax.faces.context.FacesContext;
 import javax.faces.event.PhaseId;
 import javax.faces.event.PhaseListener;
 import javax.faces.lifecycle.Lifecycle;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.myfaces.tobago.util.RequestUtils;
-import org.apache.myfaces.tobago.util.DebugUtils;
-import org.apache.myfaces.tobago.context.TobagoFacesContext;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * Implements the lifecycle as described in Spec. 1.0 PFD Chapter 2
@@ -73,7 +71,7 @@
 
     // At very first ensure the requestEncoding, this MUST done before
     // accessing request parameters, wich can occur in custom phaseListeners.
-    RequestUtils.ensureEncoding(context.getExternalContext());
+    RequestUtils.ensureEncoding(context);
 
     for (PhaseExecutor executor : lifecycleExecutors) {
       if (executePhase(context, executor, phaseListenerMgr)) {
@@ -90,7 +88,6 @@
       LOG.trace("entering " + executor.getPhase() + " in " + TobagoLifecycle.class.getName());
     }
 
-
     try {
       phaseListenerMgr.informPhaseListenersBefore(executor.getPhase());
 
@@ -126,7 +123,7 @@
   public void render(FacesContext facesContext) throws FacesException {
     // if the response is complete we should not be invoking the phase listeners
     if (!(facesContext instanceof TobagoFacesContext)) {
-      facesContext = new TobagoFacesContext(facesContext); 
+      facesContext = new TobagoFacesContext(facesContext);
     }
 
     if (isResponseComplete(facesContext, renderExecutor.getPhase(), true)) {

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ResponseUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ResponseUtils.java?rev=706881&r1=706880&r2=706881&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ResponseUtils.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ResponseUtils.java Wed Oct 22 01:01:05 2008
@@ -27,8 +27,9 @@
  */
 public class ResponseUtils {
 
-  public static void ensureNoCacheHeader(ExternalContext externalContext) {
+  public static void ensureNoCacheHeader(FacesContext facesContext) {
     // TODO PortletRequest
+    ExternalContext externalContext = facesContext.getExternalContext();
     if (externalContext.getResponse() instanceof HttpServletResponse) {
       HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();
       response.setHeader("Cache-Control", "no-cache,no-store,max-age=0,must-revalidate");

Modified: myfaces/tobago/trunk/example/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/pom.xml?rev=706881&r1=706880&r2=706881&view=diff
==============================================================================
--- myfaces/tobago/trunk/example/pom.xml (original)
+++ myfaces/tobago/trunk/example/pom.xml Wed Oct 22 01:01:05 2008
@@ -86,6 +86,7 @@
         <module>demo</module>
         <module>foreach</module>
         <module>nonfacesrequest</module>
+        <module>portlet</module>
         <module>sandbox</module>
         <module>security</module>
         <module>test</module>

Added: myfaces/tobago/trunk/example/portlet/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/portlet/pom.xml?rev=706881&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/portlet/pom.xml (added)
+++ myfaces/tobago/trunk/example/portlet/pom.xml Wed Oct 22 01:01:05 2008
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<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>
+  <parent>
+    <groupId>org.apache.myfaces.tobago</groupId>
+    <artifactId>tobago-example</artifactId>
+    <version>1.1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>tobago-example-portlet</artifactId>
+  <packaging>war</packaging>
+  <name>Tobago Example for Portlets</name>
+
+  <!--
+  XXX This is only a test! It's not a functional example. 
+  XXX It was successfully deployed on a Liferay 5.1.2, but the submit doesn't work.
+  XXX JavaScript and CSS is not working
+  -->
+
+  <!--
+    <repositories>
+      <repository>
+        <id>java.net-2</id>
+        <name>java.net Maven 2 Repository</name>
+        <url>http://download.java.net/maven/2/</url>
+      </repository>
+    </repositories>
+  -->
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.myfaces.tobago</groupId>
+      <artifactId>tobago-theme-speyside</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>javax.servlet.jsp</groupId>
+      <artifactId>jsp-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>javax.el</groupId>
+      <artifactId>el-api</artifactId>
+      <version>1.0</version>
+      <!-- in the case of Servlet 2.5 / JSP 2.1
+                 e. g. Tomcat 6 the scope should be "provided"
+            <scope>provided</scope>
+       -->
+    </dependency>
+    <dependency>
+      <groupId>el-impl</groupId>
+      <artifactId>el-impl</artifactId>
+      <version>1.0</version>
+    </dependency>
+    <!--
+        <dependency>
+          <groupId>com.sun.faces.portlet</groupId>
+          <artifactId>jsf-portlet</artifactId>
+          <version>1.1.5</version>
+        </dependency>
+    -->
+    <!--
+    <dependency>
+      <groupId>portlet-api</groupId>
+      <artifactId>portlet-api</artifactId>
+    </dependency>
+    -->
+    <!--
+    <dependency>
+      <groupId>org.apache.myfaces.portlet-bridge</groupId>
+      <artifactId>portlet-bridge-api</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.myfaces.portlet-bridge</groupId>
+      <artifactId>portlet-bridge-impl</artifactId>
+      <version>1.0.0-SNAPSHOT</version>
+    </dependency>
+    -->
+
+    <dependency>
+      <groupId>org.apache.myfaces.core</groupId>
+      <artifactId>myfaces-api</artifactId>
+      <version>${myfaces.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.myfaces.core</groupId>
+      <artifactId>myfaces-impl</artifactId>
+      <version>${myfaces.version}</version>
+    </dependency>
+
+  </dependencies>
+</project>

Added: myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/faces-config.xml?rev=706881&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/faces-config.xml (added)
+++ myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/faces-config.xml Wed Oct 22 01:01:05 2008
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<!DOCTYPE faces-config PUBLIC
+    "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
+    "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+
+<faces-config>
+
+  <application>
+    <locale-config>
+      <default-locale>en</default-locale>
+    </locale-config>
+  </application>
+
+  <navigation-rule>
+    <navigation-case>
+      <from-outcome>helloWorld</from-outcome>
+      <to-view-id>/index.jsp</to-view-id>
+    </navigation-case>
+  </navigation-rule>
+  <navigation-rule>
+    <navigation-case>
+      <from-outcome>sayHello</from-outcome>
+      <to-view-id>/hello.jsp</to-view-id>
+    </navigation-case>
+  </navigation-rule>
+
+  <managed-bean>
+    <managed-bean-name>user</managed-bean-name>
+    <managed-bean-class>org.apache.myfaces.tobago.example.portlet.User</managed-bean-class>
+    <managed-bean-scope>session</managed-bean-scope>
+  </managed-bean>
+</faces-config>

Added: myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/liferay-portlet.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/liferay-portlet.xml?rev=706881&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/liferay-portlet.xml (added)
+++ myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/liferay-portlet.xml Wed Oct 22 01:01:05 2008
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 5.1.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_5_1_0.dtd">
+
+<liferay-portlet-app>
+	<portlet>
+		<portlet-name>tobago-example-portlet</portlet-name>
+		<instanceable>true</instanceable>
+	</portlet>
+</liferay-portlet-app>

Added: myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/portlet.xml?rev=706881&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/portlet.xml (added)
+++ myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/portlet.xml Wed Oct 22 01:01:05 2008
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.	   
+-->
+<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
+
+  <portlet>
+    <portlet-name>tobago-example-portlet</portlet-name>
+    <display-name>Tobago Portlet Example (not functional)</display-name>
+
+    <portlet-class>org.apache.myfaces.portlet.MyFacesGenericPortlet</portlet-class>
+
+    <init-param>
+			<name>default-view</name>
+      <value>/index.jsp</value>
+    </init-param>
+		<supports>
+			<mime-type>text/html</mime-type>
+		</supports>
+    <portlet-info>
+      <title>Tobago Portlet Example (not functional)</title>
+      <short-title>Tobago Portlet Example (not functional)</short-title>
+    </portlet-info>
+  </portlet>
+
+</portlet-app>

Added: myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/web.xml?rev=706881&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/web.xml (added)
+++ myfaces/tobago/trunk/example/portlet/src/main/webapp/WEB-INF/web.xml Wed Oct 22 01:01:05 2008
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+         version="2.4">
+  <servlet>
+    <servlet-name>FacesServlet</servlet-name>
+    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>FacesServlet</servlet-name>
+    <url-pattern>/faces/*</url-pattern>
+  </servlet-mapping>
+</web-app>

Added: myfaces/tobago/trunk/example/portlet/src/main/webapp/hello.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/portlet/src/main/webapp/hello.jsp?rev=706881&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/portlet/src/main/webapp/hello.jsp (added)
+++ myfaces/tobago/trunk/example/portlet/src/main/webapp/hello.jsp Wed Oct 22 01:01:05 2008
@@ -0,0 +1,15 @@
+<%@ taglib uri="http://myfaces.apache.org/tobago/component" prefix="tc" %>
+<%@ taglib uri="http://myfaces.apache.org/tobago/extension" prefix="tx" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<f:view>
+  <tc:page width="300px" height="50px">
+    <f:facet name="layout">
+      <tc:gridLayout columns="*;fixed" rows="fixed;*"/>
+    </f:facet>
+    <tc:out value="Hello #{user.name}!"/>
+    <tc:button action="helloWorld" label="Return"/>
+    <tc:cell/>
+    <tc:cell/>
+  </tc:page>
+</f:view>

Added: myfaces/tobago/trunk/example/portlet/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/example/portlet/src/main/webapp/index.jsp?rev=706881&view=auto
==============================================================================
--- myfaces/tobago/trunk/example/portlet/src/main/webapp/index.jsp (added)
+++ myfaces/tobago/trunk/example/portlet/src/main/webapp/index.jsp Wed Oct 22 01:01:05 2008
@@ -0,0 +1,15 @@
+<%@ taglib uri="http://myfaces.apache.org/tobago/component" prefix="tc" %>
+<%@ taglib uri="http://myfaces.apache.org/tobago/extension" prefix="tx" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<f:view>
+  <tc:page width="300px" height="50px">
+    <f:facet name="layout">
+      <tc:gridLayout columns="*;fixed" rows="fixed;*"/>
+    </f:facet>
+    <tx:in label="Your Name" tip="Please enter your name here!" value="#{user.name}"/>
+    <tc:button action="sayHello" label="Click Here"/>
+    <tc:cell/>
+    <tc:cell/>
+  </tc:page>
+</f:view>

Modified: myfaces/tobago/trunk/tobago-jsf-compat/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/pom.xml?rev=706881&r1=706880&r2=706881&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/pom.xml (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/pom.xml Wed Oct 22 01:01:05 2008
@@ -101,6 +101,12 @@
       <version>1.4.2</version>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>javax.portlet</groupId>
+      <artifactId>portlet-api</artifactId>
+      <version>1.0</version>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
   <profiles>
     <profile>

Added: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/portlet/PortletUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/portlet/PortletUtils.java?rev=706881&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/portlet/PortletUtils.java (added)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/portlet/PortletUtils.java Wed Oct 22 01:01:05 2008
@@ -0,0 +1,101 @@
+package org.apache.myfaces.tobago.portlet;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import javax.faces.context.FacesContext;
+import javax.portlet.ActionRequest;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletURL;
+import javax.portlet.RenderResponse;
+import java.io.UnsupportedEncodingException;
+
+
+/**
+ * Static utility class for portlet-related operations.
+ */
+public final class PortletUtils {
+
+  private static final boolean PORTLET_API_AVAILABLE = portletApiAvailable();
+
+  /**
+   * This flag is imbedded in the request.
+   * It signifies that the request is coming from a portlet.
+   */
+//  public static final String PORTLET_REQUEST = PortletUtils.class.getName() + ".PORTLET_REQUEST";
+  private static final String VIEW_ID = PortletUtils.class.getName() + ".VIEW_ID";
+
+  private static boolean portletApiAvailable() {
+    try {
+      return PortletRequest.class != null; // never false
+    } catch (NoClassDefFoundError e) {
+      return false;
+    }
+  }
+
+  private PortletUtils() {
+    // avoid instantiation
+  }
+
+  /**
+   * Determine if we are processing a portlet RenderResponse.
+   *
+   * @param facesContext The current FacesContext.
+   * @return <code>true</code> if we are processing a RenderResponse,
+   *         <code>false</code> otherwise.
+   */
+  public static boolean isRenderResponse(FacesContext facesContext) {
+    return PORTLET_API_AVAILABLE && facesContext.getExternalContext().getResponse() instanceof RenderResponse;
+  }
+
+  /**
+   * Determine if we are running as a portlet.
+   *
+   * @param facesContext The current FacesContext.
+   * @return <code>true</code> if we are running as a portlet,
+   *         <code>false</code> otherwise.
+   */
+//  public static boolean isPortletRequest(FacesContext facesContext) {
+//    return facesContext.getExternalContext().getSessionMap().get(PORTLET_REQUEST) != null;
+//  }
+  public static boolean isPortletRequest(FacesContext facesContext) {
+    return PORTLET_API_AVAILABLE && facesContext.getExternalContext().getContext() instanceof PortletContext;
+  }
+
+  public static String getViewId(FacesContext facesContext) {
+    PortletRequest request = (PortletRequest) facesContext.getExternalContext().getRequest();
+    return request.getParameter(PortletUtils.VIEW_ID);
+  }
+
+  /**
+   * @return The action url.
+   */
+  public static String setViewIdForUrl(FacesContext facesContext, String viewId) {
+    RenderResponse response = (RenderResponse) facesContext.getExternalContext().getResponse();
+    PortletURL url = response.createActionURL();
+    url.setParameter(VIEW_ID, viewId);
+    return url.toString();
+  }
+
+  public static void ensureEncoding(FacesContext facesContext) throws UnsupportedEncodingException {
+    ActionRequest request = (ActionRequest) facesContext.getExternalContext().getRequest();
+    if (request.getCharacterEncoding() == null) {
+      request.setCharacterEncoding("UTF-8");
+    }
+  }
+}

Modified: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/RequestUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/RequestUtils.java?rev=706881&r1=706880&r2=706881&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/RequestUtils.java (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/RequestUtils.java Wed Oct 22 01:01:05 2008
@@ -19,8 +19,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.tobago.portlet.PortletUtils;
 
-import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
 import javax.servlet.http.HttpServletRequest;
 import java.io.UnsupportedEncodingException;
 
@@ -32,15 +33,16 @@
 
   private static final Log LOG = LogFactory.getLog(RequestUtils.class);
 
-  public static void ensureEncoding(ExternalContext externalContext) {
+  public static void ensureEncoding(FacesContext facesContext) {
+    Object requestObject = facesContext.getExternalContext().getRequest();
     try {
-      // TODO PortletRequest
-      if (externalContext.getRequest() instanceof HttpServletRequest) {
-        HttpServletRequest request =
-            (HttpServletRequest) externalContext.getRequest();
+      if (requestObject instanceof HttpServletRequest) {
+        HttpServletRequest request = (HttpServletRequest) requestObject;
         if (request.getCharacterEncoding() == null) {
           request.setCharacterEncoding("UTF-8");
         }
+      } else if (PortletUtils.isPortletRequest(facesContext)) {
+        PortletUtils.ensureEncoding(facesContext);
       }
 
     } catch (UnsupportedEncodingException e) {