[richfaces-svn-commits] JBoss Rich Faces SVN: r5548 - in trunk: extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application and 6 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Tue Jan 22 20:31:22 EST 2008


Author: alexsmirnov
Date: 2008-01-22 20:31:21 -0500 (Tue, 22 Jan 2008)
New Revision: 5548

Modified:
   trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/AjaxPortletBridge.java
   trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletStateHolder.java
   trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletViewState.java
   trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortalActionURL.java
   trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortletExternalContextImpl.java
   trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/ServletExternalContextImpl.java
   trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/lifecycle/PortalPhaseListener.java
   trunk/samples/seamPortletEar/seamBooking/src/main/java/org/jboss/seam/example/booking/Booking.java
   trunk/samples/seamPortletEar/seamBooking/src/main/java/org/jboss/seam/example/booking/User.java
   trunk/samples/seamPortletEar/seamBookingPortlet/src/main/java/org/ajax4jsf/portlet/seam/PortalIdentity.java
   trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/faces-config.xml
   trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/pages.xml
   trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/portlet.xml
   trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/seamBookingPortlet-object.xml
   trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/web.xml
   trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/home.xhtml
Log:
Run SeamBooking demo in the portal

Modified: trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/AjaxPortletBridge.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/AjaxPortletBridge.java	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/AjaxPortletBridge.java	2008-01-23 01:31:21 UTC (rev 5548)
@@ -5,6 +5,10 @@
 
 import java.io.PrintWriter;
 import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
 import java.util.Map;
 import java.util.ResourceBundle;
 
@@ -18,6 +22,7 @@
 import javax.portlet.PortletRequest;
 import javax.portlet.PortletResponse;
 import javax.portlet.PortletSession;
+import javax.portlet.PortletURL;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.faces.Bridge;
@@ -27,7 +32,9 @@
 import org.ajax4jsf.context.AjaxContext;
 import org.ajax4jsf.portlet.application.PortletStateHolder;
 import org.ajax4jsf.portlet.application.PortletViewState;
+import org.ajax4jsf.portlet.application.PortletStateHolder.WindowIDRetriver;
 import org.ajax4jsf.portlet.context.AbstractExternalContext;
+import org.ajax4jsf.portlet.context.PortalActionURL;
 import org.ajax4jsf.portlet.context.PortletExternalContextImpl;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -62,13 +69,13 @@
 	 * @see javax.portlet.faces.Bridge#init(javax.portlet.PortletConfig)
 	 */
 	public void init(PortletConfig config) throws PortletException {
+		this.portletConfig = config;
+		PortletContext portletContext = config.getPortletContext();
 		try {
 			if (log.isDebugEnabled()) {
 				log.debug("Start portlet initialisation for "
 						+ config.getPortletName());
 			}
-			this.portletConfig = config;
-			PortletContext portletContext = config.getPortletContext();
 			synchronized (portletContext) {
 				init();
 				PortletStateHolder.init(portletContext);
@@ -76,7 +83,7 @@
 		} catch (FacesException e) {
 			throw new PortletException("Initialization error", e);
 		}
-		exceptionHandler = createExceptionHandler(config);
+		exceptionHandler = createExceptionHandler(portletContext);
 		if (log.isDebugEnabled()) {
 			log.debug("Done portlet initialisation for "
 					+ config.getPortletName());
@@ -84,8 +91,8 @@
 		// getPortletContext().setAttribute(PORTLET_CONFIG, config);
 	}
 
-	protected ExceptionHandler createExceptionHandler(PortletConfig config) {
-		String exceptionHandlerClassName = config.getInitParameter(EXCEPTION_HANDLER_CLASS_PARAMETER);
+	protected ExceptionHandler createExceptionHandler(PortletContext portletContext) {
+		String exceptionHandlerClassName = portletContext.getInitParameter(EXCEPTION_HANDLER_CLASS_PARAMETER);
 		ExceptionHandler handler = null;
 		if(null != exceptionHandlerClassName){
 			ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
@@ -119,12 +126,12 @@
 		// Boolean.valueOf(null != windowState.getViewId()));
 		try {
 			execute(facesContext);
+			// Save view state for a render phases.
 			facesContext.getApplication().getStateManager().saveSerializedView(
 					facesContext);
 			// save request scope variables and Faces Messages.
 			if (!facesContext.getResponseComplete()) {
 				windowState.saveRequest(facesContext);
-
 			} else {
 				String redirectViewId = (String) facesContext.getExternalContext().getRequestMap().get(AbstractExternalContext.REDIRECT_VIEW_ID);
 				if(null != redirectViewId){
@@ -173,30 +180,40 @@
 			}
 			String namespace = response.getNamespace();
 			windowState.restoreRequest(facesContext, true);
-			if (null == facesContext.getViewRoot()) {
-				execute(facesContext);
-				// TODO - detect redirect case.
-			}
-			//
-			AjaxContext ajaxContext = AjaxContext
-					.getCurrentInstance(facesContext);
-			Map commonAjaxParameters = ajaxContext.getCommonAjaxParameters();
-			String actionURL = facesContext.getApplication().getViewHandler().getActionURL(facesContext, facesContext.getViewRoot().getViewId());
-			commonAjaxParameters.put(AbstractExternalContext.ACTION__PARAMETER,
-					facesContext.getExternalContext().encodeActionURL(actionURL));
-			commonAjaxParameters.put(
-					PortletStateHolder.STATE_ID_PARAMETER, windowState.getStateId());
-			commonAjaxParameters.put(
-					AbstractExternalContext.NAMESPACE_PARAMETER, namespace);
-			render(facesContext);
+			renderResponse(facesContext, windowState);
 			// TODO - detect redirect case. Reset response, clear request variables as far as Seam state.
 			// Perform new render phase with a new ViewId.
 			String redirectViewId = (String) facesContext.getExternalContext().getRequestMap().get(AbstractExternalContext.REDIRECT_VIEW_ID);
 			if(null != redirectViewId){
+				windowState.reset();
 				windowState.setViewId(redirectViewId);
+				// Reset attributes to initial state
+				ArrayList initialAttributes = (ArrayList) request.getAttribute(AbstractExternalContext.EXCLUDED_PARAMETERS_ATTRIBUTE);
+				ArrayList currentAttributes = Collections.list(request.getAttributeNames());
+				currentAttributes.removeAll(initialAttributes);
+				for (Object newAttribute : currentAttributes) {
+					request.removeAttribute((String) newAttribute);
+				}
+				// Re-create FacesContext.
+				facesContext.release();
+				facesContext = getFacesContext(request, response);
+				renderResponse(facesContext, windowState);
 			}
+			// Set important Portal parameters to window state.
+			String actionURL = facesContext.getApplication().getViewHandler().getActionURL(facesContext, facesContext.getViewRoot().getViewId());
+			actionURL = facesContext.getExternalContext().encodeActionURL(actionURL);
+			windowState.setPortalActionURL(new PortalActionURL(actionURL));
+			PortletURL portletURL = response.createRenderURL();
+			portletURL.setParameter(PortletStateHolder.STATE_ID_PARAMETER, windowState.getStateId());
+			String renderUrl = portletURL.toString();
+			windowState.setPortalRenderURL(new PortalActionURL(renderUrl));
+			windowState.setNamespace(namespace);
 			// writer.println("</div>");
 			PortletSession portletSession = request.getPortletSession(true);
+			WindowIDRetriver idRetriver = (WindowIDRetriver) portletSession.getAttribute(PortletStateHolder.WINDOW_ID_RETRIVER);
+			if(null != idRetriver){
+				windowState.setWindowId(idRetriver.getWindowID());
+			}
 			Principal userPrincipal = request.getUserPrincipal();
 			// TODO - get user roles, defined in the portlet.xml ( ??? parse it ??? ), and store all values for a "isUserInRole(roleName)" calls
 			portletSession.setAttribute(AbstractExternalContext.PORTAL_USER_PRINCIPAL, userPrincipal, PortletSession.APPLICATION_SCOPE);
@@ -220,6 +237,26 @@
 	}
 
 	/**
+	 * @param facesContext
+	 * @param windowState
+	 * @throws FacesException
+	 */
+	private void renderResponse(FacesContext facesContext,
+			PortletViewState windowState) throws FacesException {
+		if (null == facesContext.getViewRoot()) {
+			execute(facesContext);
+			// TODO - detect redirect case.
+		}
+		//
+		AjaxContext ajaxContext = AjaxContext
+				.getCurrentInstance(facesContext);
+		Map commonAjaxParameters = ajaxContext.getCommonAjaxParameters();
+		commonAjaxParameters.put(
+				PortletStateHolder.STATE_ID_PARAMETER, windowState.getStateId());
+		render(facesContext);
+	}
+
+	/**
 	 * @param request
 	 * @param response
 	 * @param actionPhase
@@ -234,7 +271,6 @@
 		request.setAttribute(Bridge.PORTLET_LIFECYCLE_PHASE, actionPhase);
 		request.setAttribute(AbstractExternalContext.PORTLET_CONFIG_ATTRIBUTE,
 				getPortletConfig());
-		PortletSession session = request.getPortletSession();
 	}
 
 	/**

Modified: trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletStateHolder.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletStateHolder.java	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletStateHolder.java	2008-01-23 01:31:21 UTC (rev 5548)
@@ -4,8 +4,12 @@
 package org.ajax4jsf.portlet.application;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.UUID;
+import java.util.Map.Entry;
 
 import javax.faces.FacesException;
 import javax.faces.context.ExternalContext;
@@ -43,7 +47,7 @@
 	 */
 	private static final long serialVersionUID = 3040262189850562853L;
 
-	private static final String STATE_HOLDER = PortletStateHolder.class
+	public static final String STATE_HOLDER = PortletStateHolder.class
 			.getName();
 
 	private static final String DEFAULT = "default-";
@@ -146,7 +150,7 @@
 		String stateId = getStateId(context);
 		PortletViewState state;
 		synchronized (states) {
-			state = (PortletViewState) states.get(stateId);
+			state = getWindowState(stateId);
 			if (null == state) {
 				state = new PortletViewState(stateId);
 				states.put(stateId, state);
@@ -155,11 +159,23 @@
 		return state;
 	}
 
+	/**
+	 * @param stateId
+	 * @return
+	 */
+	public PortletViewState getWindowState(String stateId) {
+		PortletViewState state;
+			state = (PortletViewState) states.get(stateId);
+		return state;
+	}
+
 	private void removeSessionStates(String scoprId) {
 		synchronized (states) {
-			for (String key : states.keySet()) {
+			// Iterate over copy of the keys, so LinkedHashSet do not support concurrent modifications.
+			for (Iterator<String> keysIterator = states.keySet().iterator();keysIterator.hasNext();) {
+				String key = keysIterator.next();
 				if (key.startsWith(scoprId)) {
-					states.remove(key);
+					keysIterator.remove();
 				}
 			}
 
@@ -215,7 +231,7 @@
 			} else {
 				throw new FacesException();
 			}
-			WindowIDRetriver idRetriver = (org.ajax4jsf.portlet.application.PortletStateHolder.WindowIDRetriver) portletSession
+			WindowIDRetriver idRetriver = (WindowIDRetriver) portletSession
 					.getAttribute(WINDOW_ID_RETRIVER);
 			if (null == idRetriver) {
 				idRetriver = new WindowIDRetriver(scopeId);

Modified: trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletViewState.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletViewState.java	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletViewState.java	2008-01-23 01:31:21 UTC (rev 5548)
@@ -22,6 +22,7 @@
 
 import org.ajax4jsf.context.AjaxContext;
 import org.ajax4jsf.portlet.context.AbstractExternalContext;
+import org.ajax4jsf.portlet.context.PortalActionURL;
 
 /**
  * @author asmirnov
@@ -73,15 +74,41 @@
 
 	private String viewId;
 
-	private Map<String, String[]> _requestParameters;
+	private Map<String, String[]> requestParameters;
+	
+	private String namespace;
+	
+	private PortalActionURL portalActionURL;
+	
+	private PortalActionURL portalRenderURL;
 
 	private final String stateId;
+	
+	private String windowId;
 
+	/**
+	 * @param stateId
+	 */
 	public PortletViewState(String stateId) {
 		this.stateId = stateId;
 	}
 
 	/**
+	 * @return the windowId
+	 */
+	public String getWindowId() {
+		return windowId;
+	}
+
+	/**
+	 * @param windowId the windowId to set
+	 */
+	public void setWindowId(String windowId) {
+		this.windowId = windowId;
+	}
+
+
+	/**
 	 * @return the stateId
 	 */
 	public String getStateId() {
@@ -258,7 +285,7 @@
 				beans.put(attributeName, entry.getValue());
 			}
 		}
-		_requestParameters = new HashMap<String, String[]>(facesContext
+		requestParameters = new HashMap<String, String[]>(facesContext
 				.getExternalContext().getRequestParameterValuesMap());
 		// Seam hack - save conversation Id for a request parameter.
 		try {
@@ -266,7 +293,7 @@
 					.evaluateExpressionGet(facesContext, "#{conversation.id}",
 							Object.class);
 			if(null != conversationId){
-				_requestParameters.put(AbstractExternalContext.CONVERSATION_ID_PARAMETER, new String[]{conversationId.toString()});
+				requestParameters.put(AbstractExternalContext.CONVERSATION_ID_PARAMETER, new String[]{conversationId.toString()});
 			}
 		} catch (Exception e) {
 			// Do nothing - no seam conversation found !
@@ -279,7 +306,9 @@
 		if (null != beans) {
 			requestMap.putAll(beans);
 		}
-		requestMap.put(REQUEST_PARAMETERS_ATTRIBUTE, _requestParameters);
+		if (null != requestParameters) {
+			requestMap.put(REQUEST_PARAMETERS_ATTRIBUTE, requestParameters);
+		}
 	}
 
 	public void restoreRequest(FacesContext facesContext, boolean b) {
@@ -322,4 +351,58 @@
 		saveMessages(facesContext);
 	}
 
+	/**
+	 * @return the namespace
+	 */
+	public String getNamespace() {
+		return namespace;
+	}
+
+	/**
+	 * @param namespace the namespace to set
+	 */
+	public void setNamespace(String namespace) {
+		this.namespace = namespace;
+	}
+
+	/**
+	 * @return the portalActionURL
+	 */
+	public PortalActionURL getPortalActionURL() {
+		return portalActionURL;
+	}
+
+	/**
+	 * @param portalActionURL the portalActionURL to set
+	 */
+	public void setPortalActionURL(PortalActionURL actionURL) {
+		this.portalActionURL = actionURL;
+	}
+
+	/**
+	 * @return the portalRenderURL
+	 */
+	public PortalActionURL getPortalRenderURL() {
+		return portalRenderURL;
+	}
+
+	/**
+	 * @param portalRenderURL the portalRenderURL to set
+	 */
+	public void setPortalRenderURL(PortalActionURL portalURL) {
+		this.portalRenderURL = portalURL;
+	}
+
+	public void reset() {
+		this.requestParameters=null;
+		this.beans = null;
+		this.componentsState = null;
+		this.messages = null;
+		this.portalActionURL=null;
+		this.portalRenderURL=null;
+		this.treeStructure=null;
+		this.viewRoot=null;
+		this.viewId=null;
+	}
+
 }

Modified: trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortalActionURL.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortalActionURL.java	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortalActionURL.java	2008-01-23 01:31:21 UTC (rev 5548)
@@ -7,6 +7,7 @@
 import java.net.URL;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.regex.Matcher;
@@ -71,7 +72,7 @@
 		}
 		this.path = urlMatcher.group(5);
 		queryString = urlMatcher.group(7);
-		parameters = new LinkedMap(30);
+		parameters = new LinkedHashMap<String, String>(30);
 		if (null != queryString) {
 			String[] queryParams = queryString.split("&");
 			for (int i = 0; i < queryParams.length; i++) {
@@ -87,6 +88,24 @@
 	}
 
 	/**
+	 * Clone constructor
+	 * @param src
+	 */
+	public PortalActionURL(PortalActionURL src){
+		if(null == src){
+			throw new NullPointerException("Source URL is null");
+		}
+		this._length = src._length;
+		this.protocol = src.protocol;
+		this.host = src.host;
+		this.port = src.port;
+		this.path = src.path;
+		this.queryString = src.queryString;
+		this.parameters = new LinkedHashMap<String, String>(src.parameters);
+		this.authority = src.authority;
+		this.userInfo = src.userInfo;
+	}
+	/**
 	 * @return the protocol
 	 */
 	public String getProtocol() {

Modified: trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortletExternalContextImpl.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortletExternalContextImpl.java	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortletExternalContextImpl.java	2008-01-23 01:31:21 UTC (rev 5548)
@@ -60,7 +60,7 @@
 		if (null != webXml) {
 			_servletPath = webXml.getFacesServletPrefix();
 		}
-		ArrayList excludedAttributes = Collections.list(request
+		List excludedAttributes = Collections.list(request
 				.getAttributeNames());
 		request.setAttribute(EXCLUDED_PARAMETERS_ATTRIBUTE, excludedAttributes);
 	}

Modified: trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/ServletExternalContextImpl.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/ServletExternalContextImpl.java	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/ServletExternalContextImpl.java	2008-01-23 01:31:21 UTC (rev 5548)
@@ -32,6 +32,7 @@
 import org.ajax4jsf.context.AjaxContext;
 import org.ajax4jsf.portlet.AjaxPortletBridge;
 import org.ajax4jsf.portlet.application.PortletStateHolder;
+import org.ajax4jsf.portlet.application.PortletViewState;
 import org.ajax4jsf.portlet.application.PortletStateHolder.WindowIDRetriver;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -54,8 +55,26 @@
 	public ServletExternalContextImpl(ServletContext context,
 			HttpServletRequest request, HttpServletResponse response) {
 		super(context, request, response);
-		ArrayList excludedAttributes = Collections.list(request.getAttributeNames());
+		ArrayList excludedAttributes = Collections.list(request
+				.getAttributeNames());
 		request.setAttribute(EXCLUDED_PARAMETERS_ATTRIBUTE, excludedAttributes);
+		PortletStateHolder portletStateHolder = (PortletStateHolder) context
+				.getAttribute(PortletStateHolder.STATE_HOLDER);
+		if (null != portletStateHolder) {
+			String stateId = request
+					.getParameter(PortletStateHolder.STATE_ID_PARAMETER);
+			if (null != stateId) {
+				PortletViewState windowState = portletStateHolder
+						.getWindowState(stateId);
+				namespace = windowState.getNamespace();
+				sessionPrefix = WindowIDRetriver.PORTLET_SCOPE_PREFIX
+						+ windowState.getWindowId() + '?';
+				portalActionUrl = windowState.getPortalActionURL();
+			}
+		} else {
+			namespace="";
+			sessionPrefix="";
+		}
 	}
 
 	public void setResponseCharacterEncoding(String encoding) {
@@ -97,19 +116,6 @@
 	}
 
 	protected String getNamespace() {
-		if (null == namespace) {
-			Object requestParameter = getRequestParameter(NAMESPACE_PARAMETER);
-			if (null != requestParameter) {
-				namespace = (String) requestParameter;
-				if (_log.isDebugEnabled()) {
-					_log.debug("Namespace for a portlet instance is "
-							+ namespace);
-				}
-			} else {
-				throw new FacesException(
-						"AJAX call to portlet without namespace parameter");
-			}
-		}
 		return namespace;
 	}
 
@@ -228,36 +234,9 @@
 
 	private String sessionPrefix;
 
-	private String getSessionPrefix() {
-		if (sessionPrefix == null) {
-			HttpSession session = getHttpRequest().getSession(false);
-			String scopeId = getHttpRequest().getParameter(PortletStateHolder.STATE_ID_PARAMETER);
-			if (null == scopeId || null == session) {
-				throw new FacesException(
-						"JSF request called without portlet state parameter");
-			}
-			Enumeration attributeNames = session.getAttributeNames();
-			while (attributeNames.hasMoreElements() && null == sessionPrefix) {
-				String name = (String) attributeNames.nextElement();
-				if (PortletSessionUtil.decodeScope(name) == PortletSession.PORTLET_SCOPE
-						&& PortletSessionUtil.decodeAttributeName(name).equals(
-								PortletStateHolder.WINDOW_ID_RETRIVER)) {
-					PortletStateHolder.WindowIDRetriver attribute = (WindowIDRetriver) session.getAttribute(name);
-					if (scopeId.startsWith(attribute.getScopeId())) {
-											sessionPrefix = WindowIDRetriver.PORTLET_SCOPE_PREFIX+attribute.getWindowID()+'?';
-					if (_log.isDebugEnabled()) {
-						_log
-								.debug("Prefix for a PORTLET_SCOPE session attributes: "
-										+ sessionPrefix);
-					}
+	private PortalActionURL portalActionUrl;
 
-					}				}
-			}
-			if (null == sessionPrefix) {
-				throw new FacesException(
-						"Prefix for attributes in portlet session scope not found");
-			}
-		}
+	private String getSessionPrefix() {
 		return sessionPrefix;
 	}
 
@@ -312,20 +291,11 @@
 
 	@Override
 	protected String createActionUrl(Map<String, String> parameters) {
-		String url = getHttpRequest().getParameter(ACTION__PARAMETER);
-		if(null == url){
-			throw new FacesException("No portal action url availible");
-		}
-		PortalActionURL portalUrl;
-		try {
-			portalUrl = new PortalActionURL(url);
-		} catch (MalformedURLException e) {
-			throw new FacesException("Malformed Portal Action URL "+url);
-		}
+		PortalActionURL actionUrl = new PortalActionURL(portalActionUrl);
 		for (Entry<String, String> parameterEntry : parameters.entrySet()) {
-			portalUrl.addParameter(parameterEntry.getKey(), parameterEntry.getValue());
+			actionUrl.addParameter(parameterEntry.getKey(), parameterEntry.getValue());
 		}
-		return portalUrl.toString();
+		return actionUrl.toString();
 	}
 
 	/**

Modified: trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/lifecycle/PortalPhaseListener.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/lifecycle/PortalPhaseListener.java	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/lifecycle/PortalPhaseListener.java	2008-01-23 01:31:21 UTC (rev 5548)
@@ -37,16 +37,16 @@
 	public void afterPhase(PhaseEvent event) {
 		PhaseId phaseId = event.getPhaseId();
 		FacesContext context = event.getFacesContext();
+		Object portletPhase = context.getExternalContext().getRequestMap()
+		.get(Bridge.PORTLET_LIFECYCLE_PHASE);
 		if (phaseId.equals(PhaseId.RESTORE_VIEW)) {
-			Object portletPhase = context.getExternalContext().getRequestMap()
-					.get(Bridge.PORTLET_LIFECYCLE_PHASE);
 			if (Bridge.PortletPhase.RenderPhase.equals(portletPhase)) {
 				context.renderResponse();
 			}
-		} else if (phaseId.equals(PhaseId.INVOKE_APPLICATION)
+		} else if (null == portletPhase && (phaseId.equals(PhaseId.INVOKE_APPLICATION)
 				|| (!phaseId.equals(PhaseId.RENDER_RESPONSE) && context
-						.getRenderResponse())) {
-			// save request scope variables and Faces Messages.
+						.getRenderResponse()))) {
+			// save request scope variables and Faces Messages for a Servlet request.
 			PortletViewState windowState = PortletStateHolder.getInstance(
 					context).getWindowState(context);
 			windowState.saveRequest(context);
@@ -73,29 +73,20 @@
 
 			AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
 			Map commonAjaxParameters = ajaxContext.getCommonAjaxParameters();
-			String portalActionUrl = requestParameters
-					.get(AbstractExternalContext.ACTION__PARAMETER);
-			if (null != portalActionUrl) {
-				try {
-					PortalActionURL pal = new PortalActionURL(portalActionUrl);
+			PortletStateHolder portletStateHolder = PortletStateHolder.getInstance(context);
+			String stateId = requestParameters.get(PortletStateHolder.STATE_ID_PARAMETER);
+			// Change viewId parameter in the portal action URL.
+			PortletViewState windowState = portletStateHolder
+					.getWindowState(stateId);
+			if (null != windowState) {
+				PortalActionURL pal = windowState.getPortalActionURL();
+				if (null != pal) {
 					pal.addParameter(AbstractExternalContext.VIEW_ID_PARAMETER,
 							context.getViewRoot().getViewId());
-					commonAjaxParameters.put(
-							AbstractExternalContext.ACTION__PARAMETER, pal
-									.toString());
-
-				} catch (MalformedURLException e) {
-					// TODO: log exception ?
 				}
 			}
-			commonAjaxParameters.put(
-					AbstractExternalContext.NAMESPACE_PARAMETER,
-					requestParameters
-							.get(AbstractExternalContext.NAMESPACE_PARAMETER));
-
 			commonAjaxParameters.put(PortletStateHolder.STATE_ID_PARAMETER,
-					requestParameters
-							.get(PortletStateHolder.STATE_ID_PARAMETER));
+					stateId);
 		}
 	}
 

Modified: trunk/samples/seamPortletEar/seamBooking/src/main/java/org/jboss/seam/example/booking/Booking.java
===================================================================
--- trunk/samples/seamPortletEar/seamBooking/src/main/java/org/jboss/seam/example/booking/Booking.java	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/samples/seamPortletEar/seamBooking/src/main/java/org/jboss/seam/example/booking/Booking.java	2008-01-23 01:31:21 UTC (rev 5548)
@@ -87,7 +87,7 @@
       this.hotel = hotel;
    }
    
-//   @ManyToOne @NotNull
+   @ManyToOne @NotNull
    public User getUser()
    {
       return user;

Modified: trunk/samples/seamPortletEar/seamBooking/src/main/java/org/jboss/seam/example/booking/User.java
===================================================================
--- trunk/samples/seamPortletEar/seamBooking/src/main/java/org/jboss/seam/example/booking/User.java	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/samples/seamPortletEar/seamBooking/src/main/java/org/jboss/seam/example/booking/User.java	2008-01-23 01:31:21 UTC (rev 5548)
@@ -4,10 +4,7 @@
 import static org.jboss.seam.ScopeType.SESSION;
 
 import java.io.Serializable;
-import java.security.Principal;
 
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
 import javax.persistence.Entity;
 import javax.persistence.Id;
 import javax.persistence.Table;
@@ -18,8 +15,10 @@
 import org.jboss.seam.annotations.Name;
 import org.jboss.seam.annotations.Scope;
 
+ at Entity
 @Name("user")
 @Scope(SESSION)
+ at Table(name="Customer")
 public class User implements Serializable
 {
    private String username;
@@ -35,23 +34,19 @@
    
    public User() {}
 
+   @NotNull
+   @Length(max=100)
    public String getName()
    {
-      if (name == null) {
-		ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
-		Principal userPrincipal = externalContext.getUserPrincipal();
-		if(null != userPrincipal){
-			name = userPrincipal.getName();
-			username = userPrincipal.toString();
-		}
-	}
-	return name;
+      return name;
    }
    public void setName(String name)
    {
       this.name = name;
    }
    
+   @NotNull
+   @Length(min=5, max=15)
    public String getPassword()
    {
       return password;
@@ -61,6 +56,9 @@
       this.password = password;
    }
    
+   @Id
+   @Length(min=4, max=15)
+   @Pattern(regex="^\\w*$", message="not a valid username")
    public String getUsername()
    {
       return username;

Modified: trunk/samples/seamPortletEar/seamBookingPortlet/src/main/java/org/ajax4jsf/portlet/seam/PortalIdentity.java
===================================================================
--- trunk/samples/seamPortletEar/seamBookingPortlet/src/main/java/org/ajax4jsf/portlet/seam/PortalIdentity.java	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/samples/seamPortletEar/seamBookingPortlet/src/main/java/org/ajax4jsf/portlet/seam/PortalIdentity.java	2008-01-23 01:31:21 UTC (rev 5548)
@@ -23,11 +23,11 @@
  * @author asmirnov
  * 
  */
- at Name("org.jboss.seam.security.identity")
- at Scope(SESSION)
- at BypassInterceptors
- at Install(precedence = APPLICATION, classDependencies = "javax.portlet.Portlet")
- at Startup
+//@Name("org.jboss.seam.security.identity")
+//@Scope(SESSION)
+//@BypassInterceptors
+//@Install(precedence = APPLICATION, classDependencies = "javax.portlet.Portlet")
+//@Startup
 public class PortalIdentity extends Identity {
 
 	public PortalIdentity() {

Modified: trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/faces-config.xml	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/faces-config.xml	2008-01-23 01:31:21 UTC (rev 5548)
@@ -8,12 +8,6 @@
 		<view-handler>
 			org.ajax4jsf.portlet.application.PortletViewHandler
 		</view-handler>
-		<state-manager>
-			org.ajax4jsf.portlet.application.PortalStateManager
-		</state-manager>
-		<!-- 
-			<view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler>
-		-->
 	</application>
 	<factory>
 		<faces-context-factory>

Modified: trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/pages.xml
===================================================================
--- trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/pages.xml	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/pages.xml	2008-01-23 01:31:21 UTC (rev 5548)
@@ -2,10 +2,12 @@
 <pages xmlns="http://jboss.com/products/seam/pages"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd"
-
-                 login-view-id="/home.xhtml"><!--
+	   no-conversation-view-id="/main.xhtml"
+       login-view-id="/home.xhtml">
+       <!--
 no-conversation-view-id="/main.xhtml"
-    --><page view-id="/register.xhtml">
+    -->
+    <page view-id="/register.xhtml">
     
         <action if="#{validation.failed}"
            execute="#{register.invalid}"/>

Modified: trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/portlet.xml	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/portlet.xml	2008-01-23 01:31:21 UTC (rev 5548)
@@ -11,12 +11,10 @@
       <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>Seam Booking Example Portlet</title>

Modified: trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/seamBookingPortlet-object.xml
===================================================================
--- trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/seamBookingPortlet-object.xml	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/seamBookingPortlet-object.xml	2008-01-23 01:31:21 UTC (rev 5548)
@@ -8,32 +8,11 @@
       <component-ref>seamBookingPortletApp.seamBookingPortlet</component-ref>
     </instance>
   </deployment>
-  <!--
   	<deployment>
   	<parent-ref>default</parent-ref>
   	<if-exists>overwrite</if-exists>
   	<page>
   	<page-name>seamBookingPortlet</page-name>
-  	<window>
-  	<window-name>ajaxportletWindow</window-name>
-  	<instance-ref>SeamBookingPortletInstance</instance-ref>
-  	<default>true</default>
-  	<region>center</region>
-  	<height>0</height>
-  	</window>
-  	<window>
-  	<window-name>ajaxportletSecondWindow</window-name>
-  	<instance-ref>SeamBookingPortletSecondInstance</instance-ref>
-  	<default>true</default>
-  	<region>center</region>
-  	<height>0</height>
-  	</window>
-  	</page>
-  	</deployment>
-  -->
-  <deployment>
-      <if-exists>overwrite</if-exists>
-      <parent-ref>default.default</parent-ref>
 	    <window>
 		    <window-name>seamBookingPortletWindow</window-name>
 		    <instance-ref>SeamBookingPortletInstance</instance-ref>
@@ -41,7 +20,9 @@
 		    <region>center</region>
 		    <height>0</height>
 	    </window>
-  </deployment><!--
+  	</page>
+  	</deployment>
+<!--
   <deployment>
     <parent-ref>default</parent-ref>
     <if-exists>overwrite</if-exists>

Modified: trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/web.xml	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/WEB-INF/web.xml	2008-01-23 01:31:21 UTC (rev 5548)
@@ -11,6 +11,12 @@
 			org.ajax4jsf.portlet.application.FaceletPortletViewHandler
 		</param-value>
 	</context-param>
+	<context-param>
+		<param-name>org.ajax4jsf.portlet.ExceptionHandler</param-name>
+		<param-value>
+			org.ajax4jsf.portlet.SeamExceptionHandlerImpl
+		</param-value>
+	</context-param>
 	<!-- Seam -->
 
 	<listener>

Modified: trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/home.xhtml
===================================================================
--- trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/home.xhtml	2008-01-23 01:30:55 UTC (rev 5547)
+++ trunk/samples/seamPortletEar/seamBookingPortlet/src/main/webapp/home.xhtml	2008-01-23 01:31:21 UTC (rev 5548)
@@ -9,7 +9,6 @@
 	</div>
 	<div id="container">
 		<div id="sidebar">
-		   <ui:remove>
             <h:form id="login">
 			<fieldset>
 				<div>
@@ -26,8 +25,6 @@
 				<div class="notes"><s:link id="register" view="/register.xhtml" value="Register New User"/></div>
 			</fieldset>
             </h:form>
-            </ui:remove>
-            <p>In the portal environment, this application use portal authentication. Please, login into portal to access hotels pages</p>
 		</div>
 		<div id="content">
 			<div class="section">




More information about the richfaces-svn-commits mailing list