You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bridges-commits@portals.apache.org by ta...@apache.org on 2007/02/23 01:31:28 UTC

svn commit: r510732 - in /portals/bridges/trunk: applications/jsf-demo/src/webapp/WEB-INF/view/ jsf/src/java/org/apache/portals/bridges/jsf/

Author: taylor
Date: Thu Feb 22 16:31:28 2007
New Revision: 510732

URL: http://svn.apache.org/viewvc?view=rev&rev=510732
Log:
https://issues.apache.org/jira/browse/PB-35

Added:
    portals/bridges/trunk/jsf/src/java/org/apache/portals/bridges/jsf/PortletUIViewRoot.java
Modified:
    portals/bridges/trunk/applications/jsf-demo/src/webapp/WEB-INF/view/calendar-notes.jsp
    portals/bridges/trunk/jsf/src/java/org/apache/portals/bridges/jsf/FacesPortlet.java
    portals/bridges/trunk/jsf/src/java/org/apache/portals/bridges/jsf/PortletFacesContextImpl.java

Modified: portals/bridges/trunk/applications/jsf-demo/src/webapp/WEB-INF/view/calendar-notes.jsp
URL: http://svn.apache.org/viewvc/portals/bridges/trunk/applications/jsf-demo/src/webapp/WEB-INF/view/calendar-notes.jsp?view=diff&rev=510732&r1=510731&r2=510732
==============================================================================
--- portals/bridges/trunk/applications/jsf-demo/src/webapp/WEB-INF/view/calendar-notes.jsp (original)
+++ portals/bridges/trunk/applications/jsf-demo/src/webapp/WEB-INF/view/calendar-notes.jsp Thu Feb 22 16:31:28 2007
@@ -9,7 +9,7 @@
 <h:outputText  styleClass='portlet-header' value="#{MESSAGE['calendar.notes']}" />
  <h:outputText value="#{calendar.date}" />
 
-<h:form id="calendarForm">
+<h:form id="calendarForm2">
 	<h:inputTextarea value="#{calendar.notes}" />
 	<h:commandButton id="save" value="Save" action="#{calendar.save}"/>     
  	<h:commandButton id="cancel" value="Cancel" 

Modified: portals/bridges/trunk/jsf/src/java/org/apache/portals/bridges/jsf/FacesPortlet.java
URL: http://svn.apache.org/viewvc/portals/bridges/trunk/jsf/src/java/org/apache/portals/bridges/jsf/FacesPortlet.java?view=diff&rev=510732&r1=510731&r2=510732
==============================================================================
--- portals/bridges/trunk/jsf/src/java/org/apache/portals/bridges/jsf/FacesPortlet.java (original)
+++ portals/bridges/trunk/jsf/src/java/org/apache/portals/bridges/jsf/FacesPortlet.java Thu Feb 22 16:31:28 2007
@@ -27,7 +27,6 @@
 import javax.faces.lifecycle.LifecycleFactory;
 import javax.faces.render.RenderKitFactory;
 import javax.faces.webapp.FacesServlet;
-
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletConfig;
@@ -532,6 +531,18 @@
         {
             key = key + ":" + view;
         }
+        System.out.println("$A$$ name spacin ");
+        PortletResponse response = (PortletResponse)context.getExternalContext().getResponse();
+        if (!(response instanceof RenderResponse))
+        {
+            System.out.println("$A$$ cant modify namespace on action response ");
+        }
+        else
+        {
+            RenderResponse rr = (RenderResponse)response;
+            key = key + rr.getNamespace();
+            System.out.println("$A$$ render response " + key);            
+        }
         return key;
     }
     
@@ -572,7 +583,13 @@
                 facesContext.setViewRoot(viewRoot);
                 defaultView = facesContext.getViewRoot().getViewId();
             }
-            
+            else
+            {
+                facesContext.setViewRoot(new PortletUIViewRoot());
+                facesContext.getViewRoot().setViewId(view);
+                facesContext.getViewRoot().setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
+                portletRequest.getPortletSession().setAttribute(createViewRootKey(facesContext, view, viewId), facesContext.getViewRoot() );
+            }                               
             portletRequest.setAttribute(REQUEST_SERVLET_PATH, defaultView.replaceAll("[.]jsp", ".jsf"));
         }
         else if (portletRequest instanceof RenderRequest)
@@ -596,7 +613,7 @@
                 }
                 else
                 {
-                    facesContext.setViewRoot(new UIViewRoot());
+                    facesContext.setViewRoot(new PortletUIViewRoot());
                     facesContext.getViewRoot().setViewId(view);
                     facesContext.getViewRoot().setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
                     portletRequest.getPortletSession().setAttribute(createViewRootKey(facesContext, view, viewId), facesContext.getViewRoot() );

Modified: portals/bridges/trunk/jsf/src/java/org/apache/portals/bridges/jsf/PortletFacesContextImpl.java
URL: http://svn.apache.org/viewvc/portals/bridges/trunk/jsf/src/java/org/apache/portals/bridges/jsf/PortletFacesContextImpl.java?view=diff&rev=510732&r1=510731&r2=510732
==============================================================================
--- portals/bridges/trunk/jsf/src/java/org/apache/portals/bridges/jsf/PortletFacesContextImpl.java (original)
+++ portals/bridges/trunk/jsf/src/java/org/apache/portals/bridges/jsf/PortletFacesContextImpl.java Thu Feb 22 16:31:28 2007
@@ -154,6 +154,8 @@
             }
             viewRoot = application.getViewHandler().createView(this, viewId);
             //viewRoot = new UIViewRoot();
+            UIViewRoot newViewRoot = new PortletUIViewRoot(viewRoot);
+            viewRoot = newViewRoot;
             viewRoot.setViewId(viewId);
             viewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
             request.getPortletSession().setAttribute(viewId, viewRoot, PortletSession.PORTLET_SCOPE);

Added: portals/bridges/trunk/jsf/src/java/org/apache/portals/bridges/jsf/PortletUIViewRoot.java
URL: http://svn.apache.org/viewvc/portals/bridges/trunk/jsf/src/java/org/apache/portals/bridges/jsf/PortletUIViewRoot.java?view=auto&rev=510732
==============================================================================
--- portals/bridges/trunk/jsf/src/java/org/apache/portals/bridges/jsf/PortletUIViewRoot.java (added)
+++ portals/bridges/trunk/jsf/src/java/org/apache/portals/bridges/jsf/PortletUIViewRoot.java Thu Feb 22 16:31:28 2007
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+package org.apache.portals.bridges.jsf;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+/**
+ * A portlet view root that implements a naming container to creates unique 
+ * client ids.
+ * @author Matthew Bruzek
+ */
+public class PortletUIViewRoot extends UIViewRoot implements NamingContainer
+{
+  /** A portlet view id constant to prepend to the namespace. */
+  public static final String VIEW_PREFIX = "view";
+  
+  /** The default constructor calls the UIViewRoot default constructor.  */
+  public PortletUIViewRoot()
+  {
+    super();
+  }
+
+  /**
+   * The convenience constructor creates a PortletUIViewRoot from a UIViewRoot.
+   * @param viewRoot The UIViewRoot to use when creating this object.
+   */
+  public PortletUIViewRoot( UIViewRoot viewRoot )
+  {
+    setLocale( viewRoot.getLocale() );
+    setRenderKitId( viewRoot.getRenderKitId() );
+    setViewId( viewRoot.getViewId() );
+  }
+
+  /**
+   * Return a string which can be used as output to the response which uniquely 
+   * identifies a component within the current view.
+   * @param context The FacesContext object for the current request.
+   */
+  public String getClientId( FacesContext context )
+  {
+    if ( context == null )
+      throw new NullPointerException( "context can not be null." );
+    
+    String nameSpace = context.getExternalContext().encodeNamespace( "" );
+    return VIEW_PREFIX + nameSpace;
+  }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: bridges-commits-unsubscribe@portals.apache.org
For additional commands, e-mail: bridges-commits-help@portals.apache.org