You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@apache.org on 2006/02/11 02:46:27 UTC

svn commit: r376906 - in /struts/shale/trunk/core-library/src/java/org/apache/shale/remoting: XhtmlHelper.java faces/RemotingPhaseListener.java impl/MappingImpl.java

Author: craigmcc
Date: Fri Feb 10 17:46:26 2006
New Revision: 376906

URL: http://svn.apache.org/viewcvs?rev=376906&view=rev
Log:
Deal with the fact that, in a portlet environment:
* There will be no mapping for FacesServlet in web.xml
* We need to map the resource URLs with ViewHandler.getActionURL() to
  make sure the JSF portlet sees them.

Modified:
    struts/shale/trunk/core-library/src/java/org/apache/shale/remoting/XhtmlHelper.java
    struts/shale/trunk/core-library/src/java/org/apache/shale/remoting/faces/RemotingPhaseListener.java
    struts/shale/trunk/core-library/src/java/org/apache/shale/remoting/impl/MappingImpl.java

Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/remoting/XhtmlHelper.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/remoting/XhtmlHelper.java?rev=376906&r1=376905&r2=376906&view=diff
==============================================================================
--- struts/shale/trunk/core-library/src/java/org/apache/shale/remoting/XhtmlHelper.java (original)
+++ struts/shale/trunk/core-library/src/java/org/apache/shale/remoting/XhtmlHelper.java Fri Feb 10 17:46:26 2006
@@ -213,14 +213,6 @@
                     (resourceBundle(context).getString("xhtml.noMappings"));
         }
 
-        // Acquire the first mapping to be used for FacesServlet
-        String patterns[] = mappings.getPatterns();
-        if ((patterns == null) || (patterns.length < 1)) {
-            throw new IllegalArgumentException
-                    (resourceBundle(context).getString("xhtml.noServletMapping"));
-        }
-        String pattern = patterns[0]; // Arbitrarily choose the first one
-
         // Acquire the Mapping instance to be used for the requesed mechanism
         List list = mappings.getMappings();
         if (list == null) {

Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/remoting/faces/RemotingPhaseListener.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/remoting/faces/RemotingPhaseListener.java?rev=376906&r1=376905&r2=376906&view=diff
==============================================================================
--- struts/shale/trunk/core-library/src/java/org/apache/shale/remoting/faces/RemotingPhaseListener.java (original)
+++ struts/shale/trunk/core-library/src/java/org/apache/shale/remoting/faces/RemotingPhaseListener.java Fri Feb 10 17:46:26 2006
@@ -83,8 +83,8 @@
 
         // Acquire a reference to the FacesContext for this request
         FacesContext context = event.getFacesContext();
-        if (log().isTraceEnabled()) {
-            log().trace("Checking view identifier '" + context.getViewRoot().getViewId() + "'");
+        if (log().isInfoEnabled()) {
+            log().info("Checking view identifier '" + context.getViewRoot().getViewId() + "'");
         }
 
         // Match this view identifier against our configured patterns
@@ -93,8 +93,8 @@
             Mapping mapping = (Mapping) mappings.next();
             String resourceId = mapping.mapViewId(context);
             if (resourceId != null) {
-                if (log().isDebugEnabled()) {
-                    log().debug("View identifier '" + context.getViewRoot().getViewId() +
+                if (log().isInfoEnabled()) {
+                    log().info("View identifier '" + context.getViewRoot().getViewId() +
                                 "' matched pattern '" + mapping.getPattern() +
                                 "' with resource id '" + resourceId + "'");
                 }

Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/remoting/impl/MappingImpl.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/remoting/impl/MappingImpl.java?rev=376906&r1=376905&r2=376906&view=diff
==============================================================================
--- struts/shale/trunk/core-library/src/java/org/apache/shale/remoting/impl/MappingImpl.java (original)
+++ struts/shale/trunk/core-library/src/java/org/apache/shale/remoting/impl/MappingImpl.java Fri Feb 10 17:46:26 2006
@@ -151,13 +151,20 @@
     /** {@inheritDoc} */
     public String mapResourceId(FacesContext context, String resourceId) {
 
-        // Acquire the servlet mapping to be used for FacesServlet
+        // Acquire the servlet mapping to be used for FacesServlet (if any --
+        // there will not be such a mapping in a portlet environment)
         String patterns[] = getMappings().getPatterns();
-        String pattern = patterns[0]; // Arbitrarily choose the first one
+        String pattern = null;
+        if ((patterns != null) && (patterns.length > 0)) {
+            pattern = patterns[0]; // Arbitrarily choose the first one
+        }
 
         // Configure the entire URL we will return
-        StringBuffer sb = new StringBuffer(context.getExternalContext().getRequestContextPath());
-        if (pattern.endsWith("/*")) { // FacesServlet is prefix mapped
+        StringBuffer sb = new StringBuffer();
+        if (pattern != null) {
+            sb.append(context.getExternalContext().getRequestContextPath());
+        }
+        if ((pattern != null) && (pattern.endsWith("/*"))) { // FacesServlet is prefix mapped
             sb.append(pattern.substring(0, pattern.length() - 2));
         }
         if (getPattern().endsWith("*")) { // Processor is prefix mapped
@@ -167,12 +174,20 @@
         if (getPattern().startsWith("*.")) { // Processor is extension mapped
             sb.append(getPattern().substring(1));
         }
-        if (pattern.startsWith("*.")) { // FacesServlet is extension mapped
+        if ((pattern != null) && (pattern.startsWith("*."))) { // FacesServlet is extension mapped
             sb.append(pattern.substring(1));
         }
 
         // Return the completed URL
-        return sb.toString();
+        if (pattern == null) {
+            // In a portlet environment, let the server map our "view identifier"
+            // to something that will be processed through the JSF lifecycle
+            return context.getApplication().getViewHandler().getActionURL(context, sb.toString());
+        } else {
+            // In a web application, our "view identifier" has already been
+            // mapped exactly the way we need it
+            return sb.toString();
+        }
 
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org