Author: alexsmirnov
Date: 2007-10-23 20:15:41 -0400 (Tue, 23 Oct 2007)
New Revision: 3492
Added:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AbstractAjaxBridge.java
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesServlet.java
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AjaxPortletBridge.java
trunk/extensions/portlet/src/main/resources/META-INF/services/
trunk/extensions/portlet/src/main/resources/META-INF/services/javax.faces.context.FacesContextFactory
Modified:
trunk/extensions/portlet/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
trunk/extensions/portlet/src/main/java/javax/portlet/faces/el/PortletELResolver.java
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesPortlet.java
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/PortletRequestWrapper.java
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/FaceletPortletViewHandler.java
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortalStateManager.java
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortletStateHolder.java
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortletViewState.java
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/component/UIPortletViewRoot.java
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ELContextImpl.java
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextImpl.java
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextWrapper.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/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ServletSessionWrapper.java
trunk/extensions/portlet/src/test/java/javax/portlet/faces/GenericPortletTest.java
Log:
Continue to implement JSR-301 bridge.
Modified:
trunk/extensions/portlet/src/main/java/javax/portlet/faces/GenericFacesPortlet.java
===================================================================
---
trunk/extensions/portlet/src/main/java/javax/portlet/faces/GenericFacesPortlet.java 2007-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/javax/portlet/faces/GenericFacesPortlet.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -20,7 +20,7 @@
import javax.portlet.RenderResponse;
import javax.portlet.WindowState;
-import org.ajax4jsf.portlet.AjaxFacesPortlet;
+import org.ajax4jsf.portlet.AjaxPortletBridge;
/**
* JSR 301 generic faces pottlet implementation.
@@ -33,7 +33,7 @@
private static final String BRIDGE_SERVICE_CLASSPATH =
"META-INF/services/javax.portlet.faces.Bridge";
public static final String BRIDGE_CLASS =
"javax.portlet.faces.BridgeClassName";
- private static final String DEFAULT_BRIDGE_CLASS = AjaxFacesPortlet.class
+ private static final String DEFAULT_BRIDGE_CLASS = AjaxPortletBridge.class
.getName();
private volatile String bridgeClassName = null;
private volatile Bridge facesPortletBrige = null;
Modified:
trunk/extensions/portlet/src/main/java/javax/portlet/faces/el/PortletELResolver.java
===================================================================
---
trunk/extensions/portlet/src/main/java/javax/portlet/faces/el/PortletELResolver.java 2007-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/javax/portlet/faces/el/PortletELResolver.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -18,13 +18,10 @@
import javax.el.ELResolver;
import javax.el.PropertyNotFoundException;
import javax.el.PropertyNotWritableException;
-
-import javax.faces.context.FacesContext;
import javax.faces.context.ExternalContext;
-
+import javax.faces.context.FacesContext;
import javax.portlet.PortletConfig;
import javax.portlet.PortletRequest;
-
import javax.portlet.faces.Bridge;
Added:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AbstractAjaxBridge.java
===================================================================
--- trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AbstractAjaxBridge.java
(rev 0)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AbstractAjaxBridge.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -0,0 +1,163 @@
+/**
+ *
+ */
+package org.ajax4jsf.portlet;
+
+import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.FacesContextFactory;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.webapp.FacesServlet;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletRequest;
+import javax.portlet.RenderResponse;
+import javax.servlet.ServletResponse;
+
+import org.ajax4jsf.portlet.context.AbstractExternalContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author asmirnov
+ *
+ */
+public abstract class AbstractAjaxBridge {
+ protected static final Log log = LogFactory.getLog(AbstractAjaxBridge.class);
+
+ /**
+ * <p>
+ * The key used to store/retrive the PortletConfig object.
+ * </p>
+ */
+ public static final String PORTLET_CONFIG = "javax.portlet.PortletConfig";
+
+ private Lifecycle lifecycle;
+
+ private FacesContextFactory facesContextFactory;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.portlet.GenericPortlet#init(javax.portlet.PortletConfig)
+ */
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.portlet.Brige#init(javax.portlet.PortletConfig)
+ */
+ public void init() throws FacesException {
+ // get faces lifecycle instance. Name of the Lifecycle can be
+ // changed by the init parameter, as described in the JSR 301 PLT
+ // 3.2
+ LifecycleFactory factory = (LifecycleFactory) FactoryFinder
+ .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+ String lifecycleId = getInitParameter(FacesServlet.LIFECYCLE_ID_ATTR);
+ if (null == lifecycleId) {
+ lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Create instance of a JSF lifecycle " + lifecycleId);
+ }
+ this.lifecycle = factory.getLifecycle(lifecycleId);
+ // get faces context factory instance
+ this.facesContextFactory = (FacesContextFactory) FactoryFinder
+ .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+ }
+
+ protected abstract String getInitParameter(String lifecycleIdAttr);
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.portlet.GenericPortlet#destroy()
+ */
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.portlet.Brige#destroy()
+ */
+ public void destroy() {
+ this.lifecycle = null;
+ this.facesContextFactory = null;
+ }
+
+ /**
+ * Get currenf JSF lifecycle instance.
+ *
+ * @return
+ */
+ protected Lifecycle getLifecycle() {
+ return this.lifecycle;
+ }
+
+ /**
+ * Create new faces context instance.
+ *
+ * @param request
+ * @param response
+ * @return new instance of faces context.
+ */
+ protected FacesContext getFacesContext(Object request,
+ Object response) {
+ FacesContext facesContext = this.facesContextFactory.getFacesContext(
+ getContext(), request, response,
+ getLifecycle());
+ return facesContext;
+ }
+
+ protected abstract Object getContext();
+
+ protected void execute(FacesContext context) throws FacesException {
+ getLifecycle().execute(context);
+ }
+
+ protected void render(FacesContext context) throws FacesException {
+ getLifecycle().render(context);
+ }
+
+
+ /**
+ * @param facesContext
+ * @return
+ */
+ public static String getPortletNamespace(FacesContext facesContext) {
+ ExternalContext externalContext = facesContext.getExternalContext();
+ Object response = externalContext.getResponse();
+ String namespace = null;
+ if (response instanceof RenderResponse) {
+ namespace = ((RenderResponse) response).getNamespace();
+ } else if (response instanceof ServletResponse) {
+ namespace = (String) externalContext.getRequestParameterMap().get(
+ AbstractExternalContext.NAMESPACE_PARAMETER);
+ } else {
+ throw new IllegalStateException(
+ "portlet Namespace not availible at this phase");
+ }
+ return namespace;
+ }
+
+ /**
+ * @param facesContext
+ * @return
+ */
+ public static PortletMode getPortletMode(FacesContext facesContext) {
+ ExternalContext externalContext = facesContext.getExternalContext();
+ Object request = externalContext.getRequest();
+ PortletMode mode = null;
+ if (request instanceof PortletRequest) {
+ mode = ((PortletRequest) request).getPortletMode();
+ } else if (null != externalContext.getRequestParameterMap().get(
+ AbstractExternalContext.PORTLET_MODE_PARAMETER)) {
+ String modeName = (String) externalContext.getRequestParameterMap()
+ .get(AbstractExternalContext.PORTLET_MODE_PARAMETER);
+ if (null != modeName) {
+ mode = new PortletMode(modeName);
+ }
+ }
+ return mode;
+ }
+
+}
Property changes on:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AbstractAjaxBridge.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesPortlet.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesPortlet.java 2007-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesPortlet.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -28,12 +28,9 @@
import javax.portlet.RenderResponse;
import javax.portlet.faces.Bridge;
import javax.portlet.faces.BridgeException;
-import javax.portlet.faces.Bridge.PortletPhase;
import javax.servlet.ServletResponse;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.portlet.application.ComponentsLoader;
-import org.ajax4jsf.portlet.application.ComponentsLoaderImpl;
import org.ajax4jsf.portlet.application.PortletStateHolder;
import org.ajax4jsf.portlet.context.AbstractExternalContext;
import org.apache.commons.logging.Log;
Added: trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesServlet.java
===================================================================
--- trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesServlet.java
(rev 0)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesServlet.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -0,0 +1,89 @@
+package org.ajax4jsf.portlet;
+
+import java.io.IOException;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class AjaxFacesServlet extends AbstractAjaxBridge implements Servlet {
+
+ private ServletConfig config;
+
+ @Override
+ protected Object getContext() {
+ return config.getServletContext();
+ }
+
+ @Override
+ protected String getInitParameter(String name) {
+ // TODO Auto-generated method stub
+ return config.getServletContext().getInitParameter(name);
+ }
+
+ public ServletConfig getServletConfig() {
+ return config;
+ }
+
+ public String getServletInfo() {
+ return (this.getClass().getName());
+ }
+
+ public void init(ServletConfig config) throws ServletException {
+ this.config = config;
+ try {
+ init();
+ } catch (FacesException e) {
+ throw new ServletException(e);
+ }
+ }
+
+ public void service(ServletRequest req, ServletResponse res)
+ throws ServletException, IOException {
+ HttpServletRequest httpRequest = (HttpServletRequest) req;
+ String pathInfo = httpRequest.getPathInfo();
+ // Protect hidden directories
+ if (pathInfo != null) {
+ pathInfo = pathInfo.toUpperCase();
+ if (pathInfo.startsWith("/WEB-INF/")
+ || pathInfo.equals("/WEB-INF")
+ || pathInfo.startsWith("/META-INF/")
+ || pathInfo.equals("/META-INF")) {
+ ((HttpServletResponse) res).
+ sendError(HttpServletResponse.SC_NOT_FOUND);
+ return;
+ }
+ }
+ FacesContext context = getFacesContext(req, res);
+ // Execute the request processing lifecycle for this request
+ try {
+ execute(context);
+ // Save request - scope information for a portlet render phase.
+ render(context);
+ } catch (FacesException e) {
+ Throwable t = e.getCause();
+ if (t == null) {
+ throw new ServletException(e.getMessage(), e);
+ } else {
+ if (t instanceof ServletException) {
+ throw ((ServletException) t);
+ } else if (t instanceof IOException) {
+ throw ((IOException) t);
+ } else {
+ throw new ServletException(t.getMessage(), t);
+ }
+ }
+ }
+ finally {
+ // Release the FacesContext instance for this request
+ context.release();
+ }
+ }
+
+}
Property changes on:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesServlet.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Added: trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AjaxPortletBridge.java
===================================================================
--- trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AjaxPortletBridge.java
(rev 0)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AjaxPortletBridge.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -0,0 +1,182 @@
+/**
+ *
+ */
+package org.ajax4jsf.portlet;
+
+import java.io.PrintWriter;
+
+import javax.faces.FacesException;
+import javax.faces.context.FacesContext;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import javax.portlet.PortletSession;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.faces.Bridge;
+import javax.portlet.faces.BridgeDefaultViewNotSpecifiedException;
+import javax.portlet.faces.BridgeException;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.portlet.context.AbstractExternalContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class AjaxPortletBridge extends AbstractAjaxBridge implements Bridge {
+
+ private static final Log log = LogFactory.getLog(AjaxPortletBridge.class);
+ private PortletConfig portletConfig;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.portlet.faces.Bridge#destroy()
+ */
+ public void destroy() {
+ if (log.isDebugEnabled()) {
+ log.debug("Destroy portlet " + getPortletConfig().getPortletName());
+ }
+ super.destroy();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.portlet.faces.Bridge#init(javax.portlet.PortletConfig)
+ */
+ public void init(PortletConfig config) throws PortletException {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Start portlet initialisation for "
+ + config.getPortletName());
+ }
+ this.portletConfig = config;
+ init();
+ } catch (FacesException e) {
+ throw new PortletException("Initialization error", e);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Done portlet initialisation for "
+ + config.getPortletName());
+ }
+ // getPortletContext().setAttribute(PORTLET_CONFIG, config);
+ }
+
+ public void doFacesRequest(ActionRequest request, ActionResponse response)
+ throws BridgeException {
+ initRequest(request, response, Bridge.PortletPhase.ActionPhase);
+ FacesContext facesContext = getFacesContext(request, response);
+ try {
+ execute(facesContext);
+ // saveView(facesContext);
+ } catch (Exception e) {
+ log.error("Error processing execute lifecycle", e);
+ throw new BridgeException("Error processing execute lifecycle ", e);
+ } finally {
+ facesContext.release();
+ }
+ }
+
+ public void doFacesRequest(RenderRequest request, RenderResponse response)
+ throws BridgeException {
+ initRequest(request, response, Bridge.PortletPhase.RenderPhase);
+ FacesContext facesContext = getFacesContext(request, response);
+ try {
+ if (null == response.getContentType()) {
+ String contenttype = request.getResponseContentType();
+ if (contenttype == null) {
+ contenttype = "text/html";
+ }
+ String encoding = response.getCharacterEncoding();
+ if (encoding == null) {
+ encoding = "UTF-8";
+ }
+ response.setContentType(contenttype);
+
+ }
+ PrintWriter writer = response.getWriter();
+ String namespace = response.getNamespace();
+ // Write anchor for update portlet pages by ajax.
+ // TODO - configure html element and style/class.
+ writer.println("<div id='" + namespace + "'>");
+ // writer.flush();
+ AjaxContext ajaxContext = AjaxContext
+ .getCurrentInstance(facesContext);
+ ajaxContext.getCommonAjaxParameters().put(
+ AbstractExternalContext.ACTION__PARAMETER,
+ response.createActionURL().toString());
+ ajaxContext.getCommonAjaxParameters().put(
+ AbstractExternalContext.PORTLET_MODE_PARAMETER,
+ request.getPortletMode().toString());
+ ajaxContext.getCommonAjaxParameters().put(
+ AbstractExternalContext.NAMESPACE_PARAMETER, namespace);
+ render(facesContext);
+ writer.println("</div>");
+ PortletSession portletSession = request.getPortletSession(true);
+ // Store namespace value in portlet scope session.
+ // ServletContext, in case of ajax requests,
+ // will restore session prefiv by it's value.
+ portletSession.setAttribute(
+ AbstractExternalContext.NAMESPACE_PARAMETER, namespace);
+ if (log.isDebugEnabled()) {
+ log
+ .debug("Finish rendering portlet for namespace "
+ + namespace);
+ }
+ // Disable portlet caching.
+ // TODO - detect ajax components on page, static views can be
+ // cached.
+ response.setProperty(RenderResponse.EXPIRATION_CACHE, "0");
+ } catch (Exception e) {
+ log.error("Error processing execute lifecycle", e);
+ throw new BridgeException("Error processing execute lifecycle ", e);
+ } finally {
+ facesContext.release();
+ }
+ }
+
+ /**
+ * @param request
+ * @param response
+ * @param actionPhase
+ * @throws BridgeException
+ */
+ protected void initRequest(PortletRequest request,
+ PortletResponse response, PortletPhase actionPhase)
+ throws BridgeException {
+ if( null == request.getAttribute(Bridge.DEFAULT_VIEWID)){
+ throw new BridgeDefaultViewNotSpecifiedException();
+ }
+ request.setAttribute(Bridge.PORTLET_LIFECYCLE_PHASE, actionPhase);
+ }
+
+ /**
+ * @return the portletConfig
+ */
+ protected PortletConfig getPortletConfig() {
+ return portletConfig;
+ }
+
+ @Override
+ protected Object getContext() {
+ // TODO Auto-generated method stub
+ return portletConfig.getPortletContext();
+ }
+
+ @Override
+ protected String getInitParameter(String name) {
+ String initParameter = portletConfig.getInitParameter(name);
+ if(null == initParameter){
+ initParameter = portletConfig.getPortletContext().getInitParameter(name);
+ }
+ return initParameter;
+ }
+
+}
Property changes on:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/AjaxPortletBridge.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/PortletRequestWrapper.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/PortletRequestWrapper.java 2007-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/PortletRequestWrapper.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -11,6 +11,7 @@
import java.util.Enumeration;
import java.util.Locale;
import java.util.Map;
+
import javax.portlet.PortletRequest;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletInputStream;
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/FaceletPortletViewHandler.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/FaceletPortletViewHandler.java 2007-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/FaceletPortletViewHandler.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -1,8 +1,8 @@
package org.ajax4jsf.portlet.application;
import java.io.IOException;
-import java.io.PrintWriter;
import java.io.Writer;
+
import javax.faces.FacesException;
import javax.faces.application.ViewHandler;
import javax.faces.context.ExternalContext;
@@ -11,6 +11,7 @@
import javax.faces.render.RenderKit;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+
import com.sun.facelets.FaceletViewHandler;
/**
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-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortalStateManager.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -4,8 +4,6 @@
package org.ajax4jsf.portlet.application;
import javax.faces.application.StateManager;
-import javax.faces.application.StateManager.SerializedView;
-import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import org.ajax4jsf.application.AjaxStateManager;
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortletStateHolder.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortletStateHolder.java 2007-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortletStateHolder.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -4,20 +4,16 @@
package org.ajax4jsf.portlet.application;
import java.io.Serializable;
-import java.util.HashMap;
import java.util.Map;
-import javax.faces.FacesException;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-import javax.portlet.PortletConfig;
import javax.portlet.PortletMode;
import javax.portlet.PortletRequest;
import javax.portlet.faces.Bridge;
import javax.portlet.faces.BridgeDefaultViewNotSpecifiedException;
import org.ajax4jsf.portlet.AjaxFacesPortlet;
-import org.ajax4jsf.portlet.context.AbstractExternalContext;
import org.apache.commons.collections.map.LRUMap;
/**
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-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/application/PortletViewState.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -10,15 +10,10 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
-import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
-import javax.portlet.ActionRequest;
-import javax.portlet.RenderRequest;
/**
* @author asmirnov
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/component/UIPortletViewRoot.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/component/UIPortletViewRoot.java 2007-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/component/UIPortletViewRoot.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -19,6 +19,11 @@
public class UIPortletViewRoot extends AjaxViewRoot implements
PortletNamingContainer, Serializable {
+
+ public UIPortletViewRoot() {
+ super();
+ }
+
/**
*
*/
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-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -53,24 +53,12 @@
*/
package org.ajax4jsf.portlet.context;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.Principal;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
-import java.util.Locale;
import java.util.Map;
-import java.util.Set;
-import javax.faces.FacesException;
+
import javax.faces.context.ExternalContext;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.Servlet;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletResponse;
/**
*
@@ -105,6 +93,7 @@
public static final String NAMESPACE_PARAMETER
="org.ajax4jsf.portlet.NAMESPACE";
public static final String ACTION__PARAMETER =
"org.ajax4jsf.portlet.ACTION_URL";
public static final Object PORTLET_MODE_PARAMETER =
"org.ajax4jsf.portlet.MODE";
+ public static final Object PORTLET_NAME_PARAMETER =
"org.ajax4jsf.portlet.NAME";
protected static final String[] EMPTY_STRING_ARRAY = new String[0];
// TODO - optimization.
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java 2007-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -23,9 +23,9 @@
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Collection;
-import java.util.Iterator;
import java.util.Enumeration;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Map;
import java.util.Set;
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ELContextImpl.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ELContextImpl.java 2007-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ELContextImpl.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -6,6 +6,7 @@
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
+
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.el.FunctionMapper;
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextImpl.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextImpl.java 2007-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextImpl.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -54,11 +54,12 @@
package org.ajax4jsf.portlet.context;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+
import javax.el.ELContext;
import javax.faces.FactoryFinder;
import javax.faces.application.Application;
@@ -73,6 +74,8 @@
import javax.faces.lifecycle.Lifecycle;
import javax.faces.render.RenderKit;
import javax.faces.render.RenderKitFactory;
+import javax.portlet.PortletResponse;
+import javax.portlet.faces.component.PortletNamingContainer;
/**
*
@@ -338,6 +341,14 @@
public void setViewRoot(UIViewRoot viewRoot) {
checkReleased();
this.viewRoot = viewRoot;
+ // JSR-301 PLT 6.1.2 FacesContext
+ if( viewRoot instanceof PortletNamingContainer ){
+ Object response = getExternalContext().getResponse();
+ if (response instanceof PortletResponse) {
+ PortletResponse portletResponse = (PortletResponse) response;
+ portletResponse.setProperty("X-JAVAX-PORTLET-IS-NAMESPACED" ,
"true");
+ }
+ }
}
public void addMessage(String clientID, FacesMessage message) {
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextWrapper.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextWrapper.java 2007-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/FacesContextWrapper.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -4,6 +4,7 @@
package org.ajax4jsf.portlet.context;
import java.util.Iterator;
+
import javax.el.ELContext;
import javax.faces.application.Application;
import javax.faces.application.FacesMessage;
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-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -10,14 +10,13 @@
import java.net.URL;
import java.security.Principal;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
+
import javax.faces.FacesException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
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-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -10,24 +10,22 @@
import java.net.URL;
import java.security.Principal;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Locale;
-import java.util.Map;
import java.util.Set;
+
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
import javax.portlet.PortletSession;
import javax.portlet.PortletSessionUtil;
-import javax.portlet.RenderResponse;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified:
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ServletSessionWrapper.java
===================================================================
---
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ServletSessionWrapper.java 2007-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/main/java/org/ajax4jsf/portlet/context/ServletSessionWrapper.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -4,6 +4,7 @@
package org.ajax4jsf.portlet.context;
import java.util.Enumeration;
+
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionContext;
Added:
trunk/extensions/portlet/src/main/resources/META-INF/services/javax.faces.context.FacesContextFactory
===================================================================
---
trunk/extensions/portlet/src/main/resources/META-INF/services/javax.faces.context.FacesContextFactory
(rev 0)
+++
trunk/extensions/portlet/src/main/resources/META-INF/services/javax.faces.context.FacesContextFactory 2007-10-24
00:15:41 UTC (rev 3492)
@@ -0,0 +1 @@
+org.ajax4jsf.portlet.context.FacesContextFactoryImpl
Modified:
trunk/extensions/portlet/src/test/java/javax/portlet/faces/GenericPortletTest.java
===================================================================
---
trunk/extensions/portlet/src/test/java/javax/portlet/faces/GenericPortletTest.java 2007-10-23
19:18:11 UTC (rev 3491)
+++
trunk/extensions/portlet/src/test/java/javax/portlet/faces/GenericPortletTest.java 2007-10-24
00:15:41 UTC (rev 3492)
@@ -15,6 +15,7 @@
import org.ajax4jsf.portlet.AbstractAjax4jsfPortletTestCase;
import org.ajax4jsf.portlet.AjaxFacesPortlet;
+import org.ajax4jsf.portlet.AjaxPortletBridge;
import junit.framework.TestCase;
@@ -277,7 +278,7 @@
setupActionRequest();
GenericFacesPortlet portlet = new GenericFacesPortlet();
portlet.init(portletConfig);
- assertEquals(AjaxFacesPortlet.class.getName(), portlet
+ assertEquals(AjaxPortletBridge.class.getName(), portlet
.getBrigeClassName());
}