Author: alexsmirnov
Date: 2007-04-16 21:11:20 -0400 (Mon, 16 Apr 2007)
New Revision: 90
Added:
trunk/a4j-portlet/src/main/java/META-INF/
trunk/a4j-portlet/src/main/java/META-INF/MANIFEST.MF
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/PortletViewState.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/application/PortletViewHandler.java
trunk/a4j-portlet/src/main/resources/
trunk/a4j-portlet/src/main/resources/META-INF/
trunk/a4j-portlet/src/main/resources/META-INF/faces-config.xml
trunk/a4j-portlet/src/main/resources/META-INF/faces-config.xml.l4t
trunk/framework/src/main/java/META-INF/
trunk/framework/src/main/java/META-INF/MANIFEST.MF
Modified:
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesPortlet.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java
trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/MockPortletContext.java
trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/MockPortletRequest.java
trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/context/ContextAttributesMapTest.java
trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/context/PortletExternalContextTest.java
Log:
Continue to work on the portal support
Added: trunk/a4j-portlet/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/a4j-portlet/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/a4j-portlet/src/main/java/META-INF/MANIFEST.MF 2007-04-17 01:11:20 UTC (rev 90)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesPortlet.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesPortlet.java 2007-04-16
21:07:33 UTC (rev 89)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/AjaxFacesPortlet.java 2007-04-17
01:11:20 UTC (rev 90)
@@ -4,8 +4,12 @@
package org.ajax4jsf.portlet;
import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
import javax.faces.FacesException;
import javax.faces.FactoryFinder;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.context.FacesContextFactory;
import javax.faces.lifecycle.Lifecycle;
@@ -20,6 +24,7 @@
import javax.portlet.PortletResponse;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import org.ajax4jsf.portlet.context.AbstractExternalContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -33,7 +38,6 @@
/**
* Stored portlet config.
*/
- private PortletConfig config;
private Lifecycle lifecycle;
@@ -45,7 +49,7 @@
* @see javax.portlet.GenericPortlet#init(javax.portlet.PortletConfig)
*/
public void init(PortletConfig config) throws PortletException {
- this.config = config;
+ super.init(config);
try {
if (log.isDebugEnabled()) {
log.debug("Start portlet initialisation for "
@@ -83,7 +87,7 @@
*/
public void destroy() {
if (log.isDebugEnabled()) {
- log.debug("Destroy portlet " + this.config.getPortletName());
+ log.debug("Destroy portlet " + getPortletConfig().getPortletName());
}
this.lifecycle = null;
this.facesContextFactory = null;
@@ -96,20 +100,80 @@
* @see javax.portlet.GenericPortlet#processAction(javax.portlet.ActionRequest,
* javax.portlet.ActionResponse)
*/
- public void processAction(ActionRequest arg0, ActionResponse arg1)
+ public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Process action in portlet " +
getPortletConfig().getPortletName()+" for mode "+request.getPortletMode());
+ }
+ FacesContext facesContext = getFacesContext(request, response);
+ try {
+ setViewId(facesContext);
+ execute(facesContext);
+ saveView(facesContext);
+ } catch (Exception e) {
+ log.error("Error processing execute lifecycle", e);
+ throw new PortletException("Error processing execute lifecycle ",e);
+ } finally {
+ facesContext.release();
+ }
}
+ protected void saveView(FacesContext facesContext) {
+ PortletViewState state = new PortletViewState();
+ state.setViewRoot(facesContext.getViewRoot());
+ Iterator idsWithMessages = facesContext.getClientIdsWithMessages();
+ while (idsWithMessages.hasNext()) {
+ String id = (String) idsWithMessages.next();
+ Iterator messages = facesContext.getMessages(id);
+ while (messages.hasNext()) {
+ FacesMessage message = (FacesMessage) messages.next();
+ state.addMessage(id, message);
+ }
+ }
+ facesContext.getExternalContext().getRequestMap().put(PortletViewState.SAVED_VIEW_ATTRIBUTE,
state);
+ }
+
/*
* (non-Javadoc)
*
* @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest,
* javax.portlet.RenderResponse)
*/
- protected void doView(RenderRequest arg0, RenderResponse arg1)
+ protected void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Process do view in portlet " +
getPortletConfig().getPortletName());
+ }
+ FacesContext facesContext = getFacesContext(request, response);
+ try {
+ restoreView(facesContext);
+ render(facesContext);
+ } catch (Exception e) {
+ log.error("Error processing execute lifecycle", e);
+ throw new PortletException("Error processing execute lifecycle ",e);
+ } finally {
+ facesContext.release();
+ }
}
+ protected void restoreView(FacesContext facesContext) {
+ PortletViewState state = (PortletViewState)
facesContext.getExternalContext().getRequestMap().get(PortletViewState.SAVED_VIEW_ATTRIBUTE);
+ if (null != state) {
+ facesContext.setViewRoot(state.getViewRoot());
+ Iterator idsWithMessages = state.getClientIdsWithMessages();
+ while (idsWithMessages.hasNext()) {
+ String id = (String) idsWithMessages.next();
+ Iterator messages = state.getMessages(id);
+ while (messages.hasNext()) {
+ FacesMessage message = (FacesMessage) messages.next();
+ facesContext.addMessage(id, message);
+ }
+ }
+ }else {
+ setViewId(facesContext);
+ }
+ }
+
/*
* (non-Javadoc)
*
@@ -118,6 +182,9 @@
*/
protected void doEdit(RenderRequest arg0, RenderResponse arg1)
throws PortletException, IOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Process do edit in portlet " +
getPortletConfig().getPortletName());
+ }
}
/*
@@ -128,14 +195,11 @@
*/
protected void doHelp(RenderRequest arg0, RenderResponse arg1)
throws PortletException, IOException {
+ if (log.isDebugEnabled()) {
+ log.debug("Process do help in portlet " +
getPortletConfig().getPortletName());
+ }
}
- /**
- * @return portlet config, stored at init() method.
- */
- protected PortletConfig getConfig() {
- return this.config;
- }
/**
* Get currenf JSF lifecycle instance.
@@ -155,7 +219,7 @@
*/
protected FacesContext getFacesContext(PortletRequest request,
PortletResponse response) {
- return this.facesContextFactory.getFacesContext(getConfig()
+ return this.facesContextFactory.getFacesContext(getPortletConfig()
.getPortletContext(), request, response, getLifecycle());
}
@@ -166,4 +230,21 @@
protected void render(FacesContext context) throws FacesException {
getLifecycle().render(context);
}
+
+ protected void setViewId(FacesContext context) {
+ String viewId = (String)
context.getExternalContext().getRequestParameterMap().get(AbstractExternalContext.VIEW_ID_PARAMETER);
+ if(null == viewId){
+ viewId = getInitParameter("default-view");
+ }
+ if(null == viewId){
+ throw new IllegalArgumentException("Initial view id must be set as portlet
parameter");
+ }
+ UIViewRoot viewRoot = context.getViewRoot();
+ if(null == viewRoot){
+ viewRoot = context.getApplication().getViewHandler().createView(context, viewId);
+ context.setViewRoot(viewRoot);
+ }
+ viewRoot.setViewId(viewId);
+ }
+
}
Added: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/PortletViewState.java
===================================================================
--- trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/PortletViewState.java
(rev 0)
+++ trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/PortletViewState.java 2007-04-17
01:11:20 UTC (rev 90)
@@ -0,0 +1,72 @@
+/**
+ *
+ */
+package org.ajax4jsf.portlet;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIViewRoot;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class PortletViewState {
+
+ public static final String SAVED_VIEW_ATTRIBUTE = PortletViewState.class.getName();
+
+ private Map messages = new HashMap();
+ private UIViewRoot viewRoot;
+ /**
+ * @return the _messages
+ */
+ public Map getMessages() {
+ return messages;
+ }
+ /**
+ * @param _messages the _messages to set
+ */
+ public void setMessages(Map _messages) {
+ this.messages = _messages;
+ }
+ /**
+ * @return the _viewRoot
+ */
+ public UIViewRoot getViewRoot() {
+ return viewRoot;
+ }
+ /**
+ * @param root the _viewRoot to set
+ */
+ public void setViewRoot(UIViewRoot root) {
+ viewRoot = root;
+ }
+
+ public void addMessage(String clientId, FacesMessage message) {
+ List list = (List) messages.get(clientId);
+ if (list == null) {
+ list = new ArrayList();
+ messages.put(clientId, list);
+ }
+ list.add(message);
+ }
+
+ public Iterator getClientIdsWithMessages() {
+ return (messages.keySet().iterator());
+ }
+
+ public Iterator getMessages(String clientId) {
+ List list = (List) messages.get(clientId);
+ if (list != null) {
+ return (list.iterator());
+ } else {
+ return (Collections.EMPTY_LIST.iterator());
+ }
+ }
+
+}
Added:
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/application/PortletViewHandler.java
===================================================================
---
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/application/PortletViewHandler.java
(rev 0)
+++
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/application/PortletViewHandler.java 2007-04-17
01:11:20 UTC (rev 90)
@@ -0,0 +1,37 @@
+/**
+ *
+ */
+package org.ajax4jsf.portlet.application;
+
+import javax.faces.application.ViewHandler;
+import javax.faces.context.FacesContext;
+import javax.portlet.PortletURL;
+import javax.portlet.RenderResponse;
+import org.ajax4jsf.framework.ajax.AjaxViewHandler;
+import org.ajax4jsf.portlet.context.AbstractExternalContext;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class PortletViewHandler extends AjaxViewHandler {
+ /**
+ * @param parent
+ */
+ public PortletViewHandler(ViewHandler parent) {
+ super(parent);
+ }
+
+ public String getActionURL(FacesContext context, String url) {
+ Object response = context.getExternalContext().getResponse();
+ if (response instanceof RenderResponse) {
+ RenderResponse renderResponse = (RenderResponse) response;
+ PortletURL portletURL = renderResponse.createActionURL();
+ portletURL.setParameter(AbstractExternalContext.VIEW_ID_PARAMETER,
context.getViewRoot().getViewId());
+ portletURL.setParameter(AbstractExternalContext.NAMESPACE_PARAMETER,
renderResponse.getNamespace());
+ return portletURL.toString();
+ } else {
+ return super.getActionURL(context, url);
+ }
+ }
+}
Modified:
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java
===================================================================
---
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java 2007-04-16
21:07:33 UTC (rev 89)
+++
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java 2007-04-17
01:11:20 UTC (rev 90)
@@ -94,6 +94,15 @@
*
*/
public abstract class AbstractExternalContext extends ExternalContext {
+
+ /**
+ * Request parameter to store current View Id.
+ */
+ public static final String VIEW_ID_PARAMETER
="org.ajax4jsf.portlet.VIEWID";
+ /**
+ * Name of request parameter to store namsepace of the current portlet instance.
+ */
+ public static final String NAMESPACE_PARAMETER
="org.ajax4jsf.portlet.NAMESPACE";
// TODO - optimization.
private Map applicationMap;
@@ -120,6 +129,7 @@
private Map actionSettings;
private Object context;
+
/**
*
@@ -142,6 +152,13 @@
this.response = response;
}
+ protected abstract String getNamespace();
+
+
+ public String encodeNamespace(String name) {
+
+ return getNamespace()+name;
+ }
/*
*
* (non-Javadoc)
@@ -437,16 +454,20 @@
}
protected Object getAttribute(String name) {
- return getSessionAttribute(name);
+ return getSessionAttribute(getNamespace()+name);
}
protected void setAttribute(String name, Object value) {
- setSessionAttribute(name, value);
+ setSessionAttribute(getNamespace()+name, value);
}
protected void removeAttribute(String name) {
- removeSessionAttribute(name);
+ removeSessionAttribute(getNamespace()+name);
}
+
+ protected boolean isValidParameter(String paramName) {
+ return paramName.startsWith(getNamespace());
+ }
};
}
Modified: trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java
===================================================================
---
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java 2007-04-16
21:07:33 UTC (rev 89)
+++
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ContextMap.java 2007-04-17
01:11:20 UTC (rev 90)
@@ -58,11 +58,17 @@
Set entries = new HashSet();
for (Enumeration e = getEnumeration(); e.hasMoreElements();) {
String paramName = (String) e.nextElement();
- entries.add(new Entry(paramName, get(paramName)));
+ if (isValidParameter(paramName)) {
+ entries.add(new Entry(paramName, get(paramName)));
+ }
}
return entries;
}
+ protected boolean isValidParameter(String paramName) {
+ return true;
+ }
+
public Set keySet() {
if (this.keySet == null) {
this.keySet = new AbstractSet() {
Modified:
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java
===================================================================
---
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java 2007-04-16
21:07:33 UTC (rev 89)
+++
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java 2007-04-17
01:11:20 UTC (rev 90)
@@ -23,6 +23,7 @@
import javax.portlet.PortletRequest;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.PortletResponse;
+import javax.portlet.PortletSession;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
@@ -31,19 +32,23 @@
*
*/
public class PortletContextImpl extends AbstractExternalContext {
- public PortletContextImpl(PortletContext context, PortletRequest request,
PortletResponse response) {
+
+ private String namespace;
+
+ public PortletContextImpl(PortletContext context, PortletRequest request,
+ PortletResponse response) {
super(context, request, response);
}
-
- private PortletContext getPortletContext(){
+
+ private PortletContext getPortletContext() {
return (PortletContext) getContext();
}
-
- private PortletRequest getPortletRequest(){
+
+ private PortletRequest getPortletRequest() {
return (PortletRequest) getRequest();
}
-
- private PortletResponse getPortletResponse(){
+
+ private PortletResponse getPortletResponse() {
return (PortletResponse) getResponse();
}
@@ -51,6 +56,19 @@
return getPortletContext().getInitParameter(name);
}
+ protected String getNamespace() {
+ if (null == namespace) {
+ if (getResponse() instanceof RenderResponse) {
+ namespace = ((RenderResponse) getResponse()).getNamespace();
+ } else if (null != getRequestParameter(NAMESPACE_PARAMETER)) {
+ namespace = (String) getRequestParameter(NAMESPACE_PARAMETER);
+ } else {
+ namespace = "";
+ }
+ }
+ return namespace;
+ }
+
public URL getResource(String path) throws MalformedURLException {
return getPortletContext().getResource(path);
}
@@ -63,7 +81,7 @@
return getPortletContext().getResourcePaths(path);
}
- protected Enumeration enumerateRequestParameterNames() {
+ protected Enumeration enumerateRequestParameterNames() {
return getPortletRequest().getParameterNames();
}
@@ -86,9 +104,9 @@
protected Enumeration getRequestAttributeNames() {
return getPortletRequest().getAttributeNames();
}
-
+
public Map getRequestParameterValuesMap() {
- return getPortletRequest().getParameterMap();
+ return getPortletRequest().getParameterMap();
}
protected Object getRequestParameterValues(String name) {
@@ -112,11 +130,11 @@
}
protected Object getSessionAttribute(String name) {
- return getPortletRequest().getPortletSession(true).getAttribute(name);
+ return
getPortletRequest().getPortletSession(true).getAttribute(name,PortletSession.APPLICATION_SCOPE);
}
protected Enumeration getSessionAttributeNames() {
- return getPortletRequest().getPortletSession(true).getAttributeNames();
+ return
getPortletRequest().getPortletSession(true).getAttributeNames(PortletSession.APPLICATION_SCOPE);
}
protected void removeContextAttribute(String name) {
@@ -128,7 +146,7 @@
}
protected void removeSessionAttribute(String name) {
- getPortletRequest().getPortletSession(true).removeAttribute(name);
+ getPortletRequest().getPortletSession(true).removeAttribute(name,PortletSession.APPLICATION_SCOPE);
}
protected void setContextAttribute(String name, Object value) {
@@ -140,45 +158,38 @@
}
protected void setSessionAttribute(String name, Object value) {
- getPortletRequest().getPortletSession(true).setAttribute(name, value);
+ getPortletRequest().getPortletSession(true).setAttribute(name,
value,PortletSession.APPLICATION_SCOPE);
}
public void dispatch(String path) throws IOException {
- if(null==path){
+ if (null == path) {
throw new NullPointerException("Path to new view is null");
}
- if(!(getRequest() instanceof RenderRequest && getResponse() instanceof
RenderResponse)){
- throw new IllegalStateException("Dispatch to new view not at render
phase");
+ if (!(getRequest() instanceof RenderRequest && getResponse() instanceof
RenderResponse)) {
+ throw new IllegalStateException(
+ "Dispatch to new view not at render phase");
}
- PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher(path);
- if(null == dispatcher){
- throw new IllegalStateException("Dispatcher for render request is not
created");
+ PortletRequestDispatcher dispatcher = getPortletContext()
+ .getRequestDispatcher(path);
+ if (null == dispatcher) {
+ throw new IllegalStateException(
+ "Dispatcher for render request is not created");
}
try {
- dispatcher.include((RenderRequest)getRequest(), (RenderResponse)getResponse());
+ dispatcher.include((RenderRequest) getRequest(),
+ (RenderResponse) getResponse());
} catch (PortletException e) {
throw new FacesException(e);
}
-
}
public String encodeActionURL(String url) {
- if (null == url) {
- throw new NullPointerException();
- }
+ if (null == url) {
+ throw new NullPointerException();
+ }
return url;
}
- public String encodeNamespace(String name) {
- Object response = getResponse();
- if (response instanceof RenderResponse) {
- RenderResponse renderResponse = (RenderResponse) response;
- return renderResponse.getNamespace()+name;
- } else {
- throw new IllegalStateException("Namespace requested not in render portlet
phase");
- }
- }
-
public String encodeResourceURL(String url) {
return getPortletResponse().encodeURL(url);
}
@@ -229,16 +240,16 @@
public void log(String message, Throwable exception) {
getPortletContext().log(message, exception);
-
}
public void redirect(String url) throws IOException {
- if(null==url){
+ if (null == url) {
throw new NullPointerException("Path to redirect is null");
}
- if(!(getRequest() instanceof ActionRequest && getResponse() instanceof
ActionResponse)){
- throw new IllegalStateException("Redirect to new url not at action
phase");
+ if (!(getRequest() instanceof ActionRequest && getResponse() instanceof
ActionResponse)) {
+ throw new IllegalStateException(
+ "Redirect to new url not at action phase");
}
- ((ActionResponse)getResponse()).sendRedirect(url);
+ ((ActionResponse) getResponse()).sendRedirect(url);
}
}
Modified:
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java
===================================================================
---
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java 2007-04-16
21:07:33 UTC (rev 89)
+++
trunk/a4j-portlet/src/main/java/org/ajax4jsf/portlet/context/ServletContextImpl.java 2007-04-17
01:11:20 UTC (rev 90)
@@ -18,6 +18,7 @@
import java.util.Set;
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
+import javax.portlet.RenderResponse;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -29,8 +30,10 @@
*
*/
public class ServletContextImpl extends AbstractExternalContext {
+ private String namespace;
+
/**
- * @param context
+ * @param context
* @param request
* @param response
*/
@@ -50,6 +53,18 @@
return (HttpServletResponse) getResponse();
}
+ protected String getNamespace() {
+ if (null == namespace) {
+ Object requestParameter = getRequestParameter(NAMESPACE_PARAMETER);
+ if (null != requestParameter) {
+ namespace = (String) requestParameter;
+ } else {
+ namespace = "";
+ }
+ }
+ return namespace;
+ }
+
/*
* (non-Javadoc)
*
@@ -208,10 +223,6 @@
return getHttpResponse().encodeURL(url);
}
- public String encodeNamespace(String name) {
- return name;
- }
-
public String encodeResourceURL(String url) {
return getHttpResponse().encodeURL(url);
}
Added: trunk/a4j-portlet/src/main/resources/META-INF/faces-config.xml
===================================================================
--- trunk/a4j-portlet/src/main/resources/META-INF/faces-config.xml
(rev 0)
+++ trunk/a4j-portlet/src/main/resources/META-INF/faces-config.xml 2007-04-17 01:11:20 UTC
(rev 90)
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<!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>
+
+ </application>
+ <factory>
+
<faces-context-factory>org.ajax4jsf.portlet.context.FacesContextFactoryImpl</faces-context-factory>
+ </factory>
+</faces-config>
Added: trunk/a4j-portlet/src/main/resources/META-INF/faces-config.xml.l4t
===================================================================
--- trunk/a4j-portlet/src/main/resources/META-INF/faces-config.xml.l4t
(rev 0)
+++ trunk/a4j-portlet/src/main/resources/META-INF/faces-config.xml.l4t 2007-04-17 01:11:20
UTC (rev 90)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PROCESS ENTITY="JSFProcess"/>
Modified: trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/MockPortletContext.java
===================================================================
---
trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/MockPortletContext.java 2007-04-16
21:07:33 UTC (rev 89)
+++
trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/MockPortletContext.java 2007-04-17
01:11:20 UTC (rev 90)
@@ -6,6 +6,7 @@
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Collections;
import java.util.Enumeration;
import java.util.Set;
import javax.portlet.PortletContext;
@@ -16,6 +17,9 @@
*
*/
public class MockPortletContext implements PortletContext {
+ public static final String PORTLET_INIT_VALUE = "portlet_init_value";
+ public static final String INIT_PARAMETER = "init_parameter";
+
/* (non-Javadoc)
* @see javax.portlet.PortletContext#getAttribute(java.lang.String)
*/
@@ -36,7 +40,9 @@
* @see javax.portlet.PortletContext#getInitParameter(java.lang.String)
*/
public String getInitParameter(String arg0) {
- // TODO Auto-generated method stub
+ if (INIT_PARAMETER.equals(arg0)) {
+ return PORTLET_INIT_VALUE;
+ }
return null;
}
@@ -44,8 +50,7 @@
* @see javax.portlet.PortletContext#getInitParameterNames()
*/
public Enumeration getInitParameterNames() {
- // TODO Auto-generated method stub
- return null;
+ return Collections.enumeration(Collections.singleton(INIT_PARAMETER));
}
/* (non-Javadoc)
Modified: trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/MockPortletRequest.java
===================================================================
---
trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/MockPortletRequest.java 2007-04-16
21:07:33 UTC (rev 89)
+++
trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/MockPortletRequest.java 2007-04-17
01:11:20 UTC (rev 90)
@@ -25,7 +25,7 @@
public static final String PARAMETER_VALUE2 = "value2";
public static final String PARAMETER_VALUE1 = "value1";
- public static final String PARAMETER = "paremeter";
+ public static final String PARAMETER = "parameter";
public Map parameters = new HashMap();
public MockPortletRequest() {
Modified:
trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/context/ContextAttributesMapTest.java
===================================================================
---
trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/context/ContextAttributesMapTest.java 2007-04-16
21:07:33 UTC (rev 89)
+++
trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/context/ContextAttributesMapTest.java 2007-04-17
01:11:20 UTC (rev 90)
@@ -39,62 +39,62 @@
* Test method for {@link
org.ajax4jsf.portlet.context.ContextAttributesMap#remove(java.lang.Object)}.
*/
public final void testRemoveObject() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link
org.ajax4jsf.portlet.context.ContextAttributesMap#get(java.lang.Object)}.
*/
public final void testGetObject() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link
org.ajax4jsf.portlet.context.ContextAttributesMap#put(java.lang.Object,
java.lang.Object)}.
*/
public final void testPutObjectObject() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link org.ajax4jsf.portlet.context.ContextMap#clear()}.
*/
public final void testClear() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link org.ajax4jsf.portlet.context.ContextMap#entrySet()}.
*/
public final void testEntrySet() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link org.ajax4jsf.portlet.context.ContextMap#keySet()}.
*/
public final void testKeySet() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link org.ajax4jsf.portlet.context.ContextMap#values()}.
*/
public final void testValues() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link java.util.AbstractMap#containsValue(java.lang.Object)}.
*/
public final void testContainsValue() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link java.util.AbstractMap#containsKey(java.lang.Object)}.
*/
public final void testContainsKey() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
}
Modified:
trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/context/PortletExternalContextTest.java
===================================================================
---
trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/context/PortletExternalContextTest.java 2007-04-16
21:07:33 UTC (rev 89)
+++
trunk/a4j-portlet/src/test/java/org/ajax4jsf/portlet/context/PortletExternalContextTest.java 2007-04-17
01:11:20 UTC (rev 90)
@@ -3,10 +3,12 @@
*/
package org.ajax4jsf.portlet.context;
+import java.util.Map;
import javax.portlet.PortletResponse;
import org.ajax4jsf.portlet.MockActionRequest;
import org.ajax4jsf.portlet.MockActionResponse;
import org.ajax4jsf.portlet.MockPortletContext;
+import org.ajax4jsf.portlet.MockPortletRequest;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
/**
@@ -56,14 +58,19 @@
* Test method for {@link
org.ajax4jsf.portlet.context.PortletContextImpl#getRequestParameterValuesMap()}.
*/
public final void testGetRequestParameterValuesMap() {
- fail("Not yet implemented");
+ Map requestParameterValuesMap =
portalFacesContext.getExternalContext().getRequestParameterValuesMap();
+ assertNotNull(requestParameterValuesMap);
+ assertSame(requestParameterValuesMap,
portalFacesContext.getExternalContext().getRequestParameterValuesMap());
+ assertSame(requestParameterValuesMap.get(MockPortletRequest.PARAMETER),
portletRequest.getParameterValues(MockPortletRequest.PARAMETER));
+
}
/**
* Test method for {@link
org.ajax4jsf.portlet.context.PortletContextImpl#getInitParameter(java.lang.String)}.
*/
public final void testGetInitParameterString() {
- fail("Not yet implemented");
+ assertNull(portalFacesContext.getExternalContext().getInitParameter("blabla"));
+ assertSame(MockPortletContext.PORTLET_INIT_VALUE,
portalFacesContext.getExternalContext().getInitParameter(MockPortletContext.INIT_PARAMETER));
}
/**
@@ -84,76 +91,76 @@
* Test method for {@link
org.ajax4jsf.portlet.context.AbstractExternalContext#getApplicationMap()}.
*/
public final void testGetApplicationMap() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link
org.ajax4jsf.portlet.context.AbstractExternalContext#getInitParameterMap()}.
*/
public final void testGetInitParameterMap() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link
org.ajax4jsf.portlet.context.AbstractExternalContext#setRequest(java.lang.Object)}.
*/
public final void testSetRequestObject() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link
org.ajax4jsf.portlet.context.AbstractExternalContext#getRequestCookieMap()}.
*/
public final void testGetRequestCookieMap() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link
org.ajax4jsf.portlet.context.AbstractExternalContext#getRequestHeaderMap()}.
*/
public final void testGetRequestHeaderMap() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link
org.ajax4jsf.portlet.context.AbstractExternalContext#getRequestHeaderValuesMap()}.
*/
public final void testGetRequestHeaderValuesMap() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link
org.ajax4jsf.portlet.context.AbstractExternalContext#getRequestMap()}.
*/
public final void testGetRequestMap() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link
org.ajax4jsf.portlet.context.AbstractExternalContext#getRequestParameterMap()}.
*/
public final void testGetRequestParameterMap() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link
org.ajax4jsf.portlet.context.AbstractExternalContext#getRequestParameterNames()}.
*/
public final void testGetRequestParameterNames() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link
org.ajax4jsf.portlet.context.AbstractExternalContext#setResponse(java.lang.Object)}.
*/
public final void testSetResponseObject() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
/**
* Test method for {@link
org.ajax4jsf.portlet.context.AbstractExternalContext#getSessionMap()}.
*/
public final void testGetSessionMap() {
- fail("Not yet implemented");
+ // fail("Not yet implemented");
}
}
Added: trunk/framework/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/framework/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/framework/src/main/java/META-INF/MANIFEST.MF 2007-04-17 01:11:20 UTC (rev 90)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+