Author: alexsmirnov
Date: 2007-11-30 20:26:04 -0500 (Fri, 30 Nov 2007)
New Revision: 4400
Modified:
  
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortalStateManager.java
  
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortletViewHandler.java
  
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortletViewState.java
  
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java
  
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java
  
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java
   trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/portlet.xml
Log:
Fix some issues with Seam portlet sample
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortalStateManager.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortalStateManager.java	2007-11-30
19:40:46 UTC (rev 4399)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortalStateManager.java	2007-12-01
01:26:04 UTC (rev 4400)
@@ -27,7 +27,7 @@
     	PortletViewState windowState =
PortletStateHolder.getInstance(context).getWindowState(context);
     	windowState.setTreeStructure(treeStructure);
     	windowState.setComponentsState(state);
-    	windowState.setViewRoot(context.getViewRoot());
+//    	windowState.setViewRoot(context.getViewRoot());
     	String viewId = context.getViewRoot().getViewId();
 		windowState.setViewId(viewId);
     	return new SerializedView(viewId,null);
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortletViewHandler.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortletViewHandler.java	2007-11-30
19:40:46 UTC (rev 4399)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortletViewHandler.java	2007-12-01
01:26:04 UTC (rev 4400)
@@ -25,6 +25,8 @@
 import org.ajax4jsf.context.AjaxContext;
 import org.ajax4jsf.portlet.component.UIPortletViewRoot;
 import org.ajax4jsf.portlet.context.AbstractExternalContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 
 
@@ -35,6 +37,8 @@
  */
 public class PortletViewHandler extends AjaxViewHandler {
 	public static final String INTERWEAVING_RESPONSE_INTERFACE =
"com.sun.faces.application.InterweavingResponse";
+	
+	private static final Log _log = LogFactory.getLog(PortletViewHandler.class);
 	/**
 	 * @param parent
 	 */
@@ -105,6 +109,9 @@
 	      }
 	      catch (Throwable t)
 	      {
+	    	if(_log.isInfoEnabled()){
+	    		_log.info("Error rendering view by parent ViewHandler, try to render as
portlet JSP page",t);
+	    	}
 	        // catch all throws and swallow -- falling through to our own
 	        // render
 	      }
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortletViewState.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortletViewState.java	2007-11-30
19:40:46 UTC (rev 4399)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortletViewState.java	2007-12-01
01:26:04 UTC (rev 4400)
@@ -55,7 +55,7 @@
 			AjaxContext.class};
 
 	private static final String[] excludedRequestAttributes = {
-			"javax.servlet.include", ResponseStateManager.VIEW_STATE_PARAM };
+			"javax.servlet.include", ResponseStateManager.VIEW_STATE_PARAM,
AbstractExternalContext.EXCLUDED_PARAMETERS_ATTRIBUTE };
 
 	public static final String REQUEST_PARAMETERS_ATTRIBUTE = PortletViewState.class
 			.getName()
@@ -218,17 +218,25 @@
 		beans = null;
 		Map<String, Object> requestMap = facesContext.getExternalContext()
 				.getRequestMap();
+		List existingAttributes = (List)
requestMap.get(AbstractExternalContext.EXCLUDED_PARAMETERS_ATTRIBUTE);
+		if (null == existingAttributes) {
+			existingAttributes = Collections.EMPTY_LIST;
+		}
 		for (Iterator<Entry<String, Object>> iterator = requestMap.entrySet()
 				.iterator(); iterator.hasNext();) {
 			Entry<String, Object> entry = iterator.next();
 			boolean include = true;
+			String attributeName = entry.getKey();
+			if (existingAttributes.contains(attributeName)) {
+				include = false;
+			}
 			for (int i = 0; (i < excludedClasses.length) && include; i++) {
 				if (excludedClasses[i].isInstance(entry.getValue())) {
 					include = false;
 				}
 			}
 			for (int i = 0; (i < excludedRequestAttributes.length) && include; i++) {
-				if (entry.getKey().startsWith(excludedRequestAttributes[i])) {
+				if (attributeName.startsWith(excludedRequestAttributes[i])) {
 					include = false;
 				}
 			}
@@ -236,7 +244,7 @@
 				if (null == beans) {
 					beans = new HashMap<String, Object>();
 				}
-				beans.put(entry.getKey(), entry.getValue());
+				beans.put(attributeName, entry.getValue());
 			}
 		}
 		_requestParameters = new HashMap<String, String[]>(facesContext
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java	2007-11-30
19:40:46 UTC (rev 4399)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java	2007-12-01
01:26:04 UTC (rev 4400)
@@ -104,6 +104,7 @@
 
 	protected static final String[] EMPTY_STRING_ARRAY = new String[0];
 	public static final String PORTLET_CONFIG_ATTRIBUTE =
"org.ajax4jsf.portlet.CONFIG";
+	public static final String EXCLUDED_PARAMETERS_ATTRIBUTE =
"org.ajax4jsf.portlet.REQUEST_PARAMETERS";
 	public static final Object RENDER_POLICY_ATTRIBUTE =
"org.ajax4jsf.portlet.RENDER_POLICY";
 	public static final String PORTAL_USER_PRINCIPAL =
"org.ajax4jsf.portlet.USER_PRINCIPAL";
 	// TODO - optimization.
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java	2007-11-30
19:40:46 UTC (rev 4399)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java	2007-12-01
01:26:04 UTC (rev 4400)
@@ -10,6 +10,7 @@
 import java.net.URL;
 import java.security.Principal;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.List;
@@ -51,6 +52,8 @@
 		if(null != webXml){
 			_servletPath = webXml.getFacesServletPrefix();			
 		}
+		ArrayList excludedAttributes = Collections.list(request.getAttributeNames());
+		request.setAttribute(EXCLUDED_PARAMETERS_ATTRIBUTE, excludedAttributes);
 	}
 
 	public void setResponseCharacterEncoding(String encoding) {
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java	2007-11-30
19:40:46 UTC (rev 4399)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java	2007-12-01
01:26:04 UTC (rev 4400)
@@ -10,6 +10,7 @@
 import java.net.URL;
 import java.security.Principal;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.Locale;
@@ -51,6 +52,8 @@
 	public ServletContextImpl(ServletContext context,
 			HttpServletRequest request, HttpServletResponse response) {
 		super(context, request, response);
+		ArrayList excludedAttributes = Collections.list(request.getAttributeNames());
+		request.setAttribute(EXCLUDED_PARAMETERS_ATTRIBUTE, excludedAttributes);
 	}
 
 	public void setResponseCharacterEncoding(String encoding) {
Modified:
trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/portlet.xml
===================================================================
---
trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/portlet.xml	2007-11-30
19:40:46 UTC (rev 4399)
+++
trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/portlet.xml	2007-12-01
01:26:04 UTC (rev 4400)
@@ -11,12 +11,12 @@
       <name>javax.portlet.faces.defaultViewId.view</name>
       <value>/home.xhtml</value>
     </init-param>
-
+<!-- 
     <init-param>
       <name>javax.portlet.faces.preserveActionParams</name>
       <value>true</value>
     </init-param>
-
+-->
     <expiration-cache>-0</expiration-cache>
     <portlet-info>
        <title>Ajax Portlet</title>