[richfaces-svn-commits] JBoss Rich Faces SVN: r4835 - in branches/3.1.x: cdk/generator/src/main/java/org/ajax4jsf/builder/xml and 11 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Thu Dec 13 19:00:16 EST 2007


Author: alexsmirnov
Date: 2007-12-13 19:00:16 -0500 (Thu, 13 Dec 2007)
New Revision: 4835

Added:
   branches/3.1.x/cdk/maven-cdk-plugin/src/main/resources/templates/xcss.vm
   branches/3.1.x/cdk/maven-cdk-plugin/src/main/resources/templates12/xcss.vm
   branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/ExceptionHandler.java
   branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/ExceptionHandlerImpl.java
Modified:
   branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java
   branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java
   branches/3.1.x/cdk/maven-javascript-plugin/pom.xml
   branches/3.1.x/cdk/pom.xml
   branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/AjaxPortletBridge.java
   branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletViewState.java
   branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java
   branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/FacesContextFactoryImpl.java
   branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/FacesContextImpl.java
   branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java
   branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortletRenderContextImpl.java
   branches/3.1.x/framework/impl/pom.xml
   branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java
   branches/3.1.x/samples/richfaces-demo/src/main/webapp/WEB-INF/web.xml
   branches/3.1.x/ui/assembly/pom.xml
Log:
Merge JavaScript and CSS aggregation from trunk.

Modified: branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java
===================================================================
--- branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java	2007-12-13 22:50:43 UTC (rev 4834)
+++ branches/3.1.x/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java	2007-12-14 00:00:16 UTC (rev 4835)
@@ -31,7 +31,9 @@
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.ErrorListener;
 import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
@@ -70,12 +72,24 @@
 	 * @throws ParsingException
 	 */
 	public void loadXML(InputStream input) throws ParsingException {
+		loadXML(input,false);
+	}
+
+	
+	/**
+	 * Load XML document and parse it into DOM.
+	 * 
+	 * @param input
+	 * @throws ParsingException
+	 */
+	public void loadXML(InputStream input, boolean namespaceAware) throws ParsingException {
 		try {
 			// Create Document Builder Factory
 			DocumentBuilderFactory docFactory = DocumentBuilderFactory
 					.newInstance();
 
 			docFactory.setValidating(false);
+			docFactory.setNamespaceAware(namespaceAware);
 			// Create Document Builder
 			DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
 			
@@ -146,6 +160,27 @@
 			TransformerFactory transformerFactory = TransformerFactory
 					.newInstance();
 			Transformer transformer = transformerFactory.newTransformer();
+			transformer.setErrorListener(new ErrorListener(){
+
+				public void error(TransformerException exception)
+						throws TransformerException {
+					// TODO Auto-generated method stub
+					
+				}
+
+				public void fatalError(TransformerException exception)
+						throws TransformerException {
+					// TODO Auto-generated method stub
+					
+				}
+
+				public void warning(TransformerException exception)
+						throws TransformerException {
+					// TODO Auto-generated method stub
+					
+				}
+				
+			});
 			transformer.setOutputProperty("omit-xml-declaration", "yes");
 			StringWriter out = new StringWriter();
 			StreamResult result = new StreamResult(out);

Modified: branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java
===================================================================
--- branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java	2007-12-13 22:50:43 UTC (rev 4834)
+++ branches/3.1.x/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java	2007-12-14 00:00:16 UTC (rev 4835)
@@ -90,6 +90,8 @@
 
 	private static final String RESOURCES_CONFIG_TEMPLATE = "resources-config.vm";
 
+	private static final String XCSS_TEMPLATE = "xcss.vm";
+
 	private static final String TLD_TEMPLATE = "tld.vm";
 
 	private static final String TAGLIB_TEMPLATE = "taglib.vm";
@@ -156,6 +158,11 @@
 	private File buildDirectory;
 
 	/**
+	 * @parameter default-value="${project.build.directory}/modules"
+	 */
+	private File modulesDirectory;
+
+	/**
 	 * The directory for compiled classes.
 	 * 
 	 * @parameter expression="${project.build.directory}/pom.xml"
@@ -188,8 +195,21 @@
 	 */
 	private String includeTaglib = "META-INF/*.taglib.xml";
 
+	/**
+	 * @parameter
+	 */
+	private String includeXcss = "**/*.xcss";
 
 	/**
+	 * @parameter
+	 */
+	private String commonStyle;
+
+	/**
+	 * @parameter
+	 */
+	private  String templateXpath;
+	/**
 	 * 
 	 */
 	public AssemblyLibraryMojo() {
@@ -214,7 +234,13 @@
 				"META-INF/resources-config.xml");
 		mergeXML(models, "META-INF/resources-config.xml",
 				RESOURCES_CONFIG_TEMPLATE, "/resource-config/resource",
-				"name/text()", new VelocityContext(), resourcesConfig);
+				"name/text()", new VelocityContext(), resourcesConfig, false);
+		if (null != commonStyle) {
+			File commonXcss = new File(outputDirectory, commonStyle);
+			mergeXML(models, includeXcss, XCSS_TEMPLATE, templateXpath, null,
+					new VelocityContext(), commonXcss, true);
+
+		}
 		if (null != library.getTaglibs() && library.getTaglibs().length > 0) {
 			for (int i = 0; i < library.getTaglibs().length; i++) {
 				Taglib taglib = library.getTaglibs()[i];
@@ -238,7 +264,10 @@
 							.hasNext();) {
 						Model model = (Model) iterator.next();
 						String id = model.getArtifactId();
-						if((includeModules == null || Arrays.binarySearch(includeModules, id)>=0)&&(excludeModules == null || Arrays.binarySearch(excludeModules, id)<0)){
+						if ((includeModules == null || Arrays.binarySearch(
+								includeModules, id) >= 0)
+								&& (excludeModules == null || Arrays
+										.binarySearch(excludeModules, id) < 0)) {
 							taglibModels.add(model);
 						}
 					}
@@ -256,22 +285,27 @@
 	 */
 	private void generateTaglib(List models, Taglib taglib)
 			throws MojoExecutionException {
+		getLog().debug(
+				"Assembly taglib for uri " + taglib.getUri()
+						+ " with short name " + taglib.getShortName());
 		VelocityContext taglibContext = new VelocityContext();
 		taglibContext.put("taglib", taglib);
 		// Build includes/excludes Xpath condition
 		String nameTag = "name";
 		createTagCondition(taglib, nameTag);
-		File tld = new File(outputDirectory, "META-INF/"
-				+ taglib.getTaglib() + ".tld");
+		File tld = new File(outputDirectory, "META-INF/" + taglib.getTaglib()
+				+ ".tld");
+		getLog().debug("Write JSP taglib " + tld.getPath());
 		mergeXML(models, includeTld, TLD_TEMPLATE, "/taglib/tag"
 				+ createTagCondition(taglib, "name") + " | /taglib/listener",
-				null, new VelocityContext(taglibContext), tld);
+				null, new VelocityContext(taglibContext), tld, false);
 		File faceletsTaglib = new File(outputDirectory, "META-INF/"
 				+ taglib.getTaglib() + ".taglib.xml");
 		mergeXML(models, includeTaglib, TAGLIB_TEMPLATE, "/facelet-taglib/tag"
 				+ createTagCondition(taglib, "tag-name")
 				+ " | /facelet-taglib/function", null, new VelocityContext(
-				taglibContext), faceletsTaglib);
+				taglibContext), faceletsTaglib, false);
+		getLog().debug("Write Facelets taglib " + faceletsTaglib.getPath());
 	}
 
 	/**
@@ -390,7 +424,7 @@
 			Artifact artifact = factory.createBuildArtifact(model.getGroupId(),
 					model.getArtifactId(), model.getVersion(), model
 							.getPackaging());
-			File moduleDir = new File(buildDirectory, model.getArtifactId());
+			File moduleDir = new File(modulesDirectory, model.getArtifactId());
 			unpackArtifact(artifact, moduleDir, true);
 			artifact = factory
 					.createArtifactWithClassifier(model.getGroupId(), model
@@ -422,7 +456,7 @@
 				.addAll(projectsDependencies.values());
 		writePom(generatedProject);
 		project.setDependencies(new ArrayList(projectsDependencies.values()));
-//		project.setFile(generatedPom);
+		// project.setFile(generatedPom);
 	}
 
 	/**
@@ -477,7 +511,7 @@
 		}
 		for (Iterator iter = models.iterator(); iter.hasNext();) {
 			Model model = (Model) iter.next();
-			File moduleFacesConfig = new File(buildDirectory, model
+			File moduleFacesConfig = new File(modulesDirectory, model
 					.getArtifactId()
 					+ "/META-INF/faces-config.xml");
 			if (moduleFacesConfig.exists()) {
@@ -535,22 +569,23 @@
 	 *            XPath expression fof common part of result file.
 	 * @param keyXPath -
 	 *            XPath expression for key part of common parts
+	 * @param context -
+	 *            Velocity context for template processing.
+	 * @param namespaceAware TODO
 	 * @param keySet -
 	 *            {@link Set} to check for duplicate keys. Must not be null
-	 * @param context -
-	 *            Velocity context for template processing.
 	 * @throws MojoExecutionException
 	 */
 	private void mergeXML(List models, String filename, String templateName,
 			String commonXpath, String keyXPath, VelocityContext context,
-			File target) throws MojoExecutionException {
+			File target, boolean namespaceAware) throws MojoExecutionException {
 		Set<String> keySet = new HashSet<String>();
 		StringBuffer content = new StringBuffer();
 		List<XMLBody> xmls = new ArrayList<XMLBody>(models.size());
 		String[] split = filename.split(",");
 		for (Iterator iter = models.iterator(); iter.hasNext();) {
 			Model model = (Model) iter.next();
-			File moduleDir = new File(buildDirectory, model.getArtifactId());
+			File moduleDir = new File(modulesDirectory, model.getArtifactId());
 			DirectoryScanner ds = new DirectoryScanner();
 			ds.setFollowSymlinks(true);
 			ds.setBasedir(moduleDir);
@@ -565,7 +600,7 @@
 								+ model.getArtifactId());
 				XMLBody configBody = new XMLBody();
 				try {
-					configBody.loadXML(new FileInputStream(moduleFacesConfig));
+					configBody.loadXML(new FileInputStream(moduleFacesConfig),namespaceAware);
 					xmls.add(configBody);
 					if (commonXpath != null) {
 						if (keyXPath == null) {

Added: branches/3.1.x/cdk/maven-cdk-plugin/src/main/resources/templates/xcss.vm
===================================================================
--- branches/3.1.x/cdk/maven-cdk-plugin/src/main/resources/templates/xcss.vm	                        (rev 0)
+++ branches/3.1.x/cdk/maven-cdk-plugin/src/main/resources/templates/xcss.vm	2007-12-14 00:00:16 UTC (rev 4835)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:template xmlns:f='http:/jsf.exadel.com/template'
+   xmlns:u='http:/jsf.exadel.com/template/util'
+   xmlns="http://www.w3.org/1999/xhtml" >
+${content}
+</f:template>
\ No newline at end of file

Added: branches/3.1.x/cdk/maven-cdk-plugin/src/main/resources/templates12/xcss.vm
===================================================================
--- branches/3.1.x/cdk/maven-cdk-plugin/src/main/resources/templates12/xcss.vm	                        (rev 0)
+++ branches/3.1.x/cdk/maven-cdk-plugin/src/main/resources/templates12/xcss.vm	2007-12-14 00:00:16 UTC (rev 4835)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:template xmlns:f='http:/jsf.exadel.com/template'
+   xmlns:u='http:/jsf.exadel.com/template/util'
+   xmlns="http://www.w3.org/1999/xhtml" >
+${content}
+</f:template>
\ No newline at end of file

Modified: branches/3.1.x/cdk/maven-javascript-plugin/pom.xml
===================================================================
--- branches/3.1.x/cdk/maven-javascript-plugin/pom.xml	2007-12-13 22:50:43 UTC (rev 4834)
+++ branches/3.1.x/cdk/maven-javascript-plugin/pom.xml	2007-12-14 00:00:16 UTC (rev 4835)
@@ -6,7 +6,7 @@
 	<parent>
 		<artifactId>cdk</artifactId>
 		<groupId>org.richfaces</groupId>
-		<version>3.2.0-SNAPSHOT</version>
+		<version>3.1.3-SNAPSHOT</version>
 	</parent>
 	<groupId>org.richfaces.cdk</groupId>
 	<artifactId>maven-javascript-plugin</artifactId>

Modified: branches/3.1.x/cdk/pom.xml
===================================================================
--- branches/3.1.x/cdk/pom.xml	2007-12-13 22:50:43 UTC (rev 4834)
+++ branches/3.1.x/cdk/pom.xml	2007-12-14 00:00:16 UTC (rev 4835)
@@ -27,8 +27,9 @@
 		</pluginManagement>
 	</build>
 	<modules>
+		<module>generator</module>
 		<module>maven-cdk-plugin</module>
-		<module>generator</module>
+		<module>maven-javascript-plugin</module>
 		<module>maven-archetype-jsf-component</module>
 		<module>maven-archetype-jsfwebapp</module>
 	</modules>

Modified: branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/AjaxPortletBridge.java
===================================================================
--- branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/AjaxPortletBridge.java	2007-12-13 22:50:43 UTC (rev 4834)
+++ branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/AjaxPortletBridge.java	2007-12-14 00:00:16 UTC (rev 4835)
@@ -38,7 +38,10 @@
 public class AjaxPortletBridge extends AbstractAjaxBridge implements Bridge {
 
 	private static final Log log = LogFactory.getLog(AjaxPortletBridge.class);
+	private static final String EXCEPTION_HANDLER_CLASS_PARAMETER = ExceptionHandler.class.getName();
 	private PortletConfig portletConfig;
+	
+	private ExceptionHandler exceptionHandler;
 
 	/*
 	 * (non-Javadoc)
@@ -71,6 +74,7 @@
 		} catch (FacesException e) {
 			throw new PortletException("Initialization error", e);
 		}
+		exceptionHandler = createExceptionHandler(config);
 		if (log.isDebugEnabled()) {
 			log.debug("Done portlet initialisation for "
 					+ config.getPortletName());
@@ -78,6 +82,30 @@
 		// getPortletContext().setAttribute(PORTLET_CONFIG, config);
 	}
 
+	protected ExceptionHandler createExceptionHandler(PortletConfig config) {
+		String exceptionHandlerClassName = config.getInitParameter(EXCEPTION_HANDLER_CLASS_PARAMETER);
+		ExceptionHandler handler = null;
+		if(null != exceptionHandlerClassName){
+			ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+			if(null == classLoader){
+				classLoader = this.getClass().getClassLoader();
+			}
+			try {
+				Class<ExceptionHandler> exceptionHandlerClass = (Class<ExceptionHandler>) classLoader.loadClass(exceptionHandlerClassName);
+				handler = exceptionHandlerClass.newInstance();
+			} catch (ClassNotFoundException e) {				
+				handler = new ExceptionHandlerImpl();
+			} catch (InstantiationException e) {
+				handler = new ExceptionHandlerImpl();
+			} catch (IllegalAccessException e) {
+				handler = new ExceptionHandlerImpl();
+			}
+		} else {
+			handler = new ExceptionHandlerImpl();			
+		}
+		return handler;
+	}
+
 	public void doFacesRequest(ActionRequest request, ActionResponse response)
 			throws BridgeException {
 		initRequest(request, response, Bridge.PortletPhase.ActionPhase);
@@ -99,7 +127,7 @@
 		} catch (Exception e) {
 			// TODO - handle exception.
 			log.error("Error processing execute lifecycle", e);
-			throw new BridgeException("Error processing execute lifecycle ", e);
+			exceptionHandler.processActionException(facesContext, windowState, e);
 		} finally {
 			facesContext.release();
 		}
@@ -109,6 +137,8 @@
 			throws BridgeException {
 		initRequest(request, response, Bridge.PortletPhase.RenderPhase);
 		FacesContext facesContext = getFacesContext(request, response);
+		PortletViewState windowState = PortletStateHolder.getInstance(
+				facesContext).getWindowState(facesContext);
 		try {
 			if (null == response.getContentType()) {
 				String contenttype = request.getResponseContentType();
@@ -134,14 +164,7 @@
 					// Ignore MissingResourceException
 				}
 			}
-			// 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();
-			PortletViewState windowState = PortletStateHolder.getInstance(
-					facesContext).getWindowState(facesContext);
 			windowState.restoreRequest(facesContext, true);
 			if (null == facesContext.getViewRoot()) {
 				execute(facesContext);
@@ -185,7 +208,7 @@
 			response.reset();
 			// TODO - handle exception
 			log.error("Error processing execute lifecycle", e);
-			throw new BridgeException("Error processing execute lifecycle ", e);
+			exceptionHandler.processRenderException(facesContext, windowState, e);
 		} finally {
 			facesContext.release();
 		}

Copied: branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/ExceptionHandler.java (from rev 4834, trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/ExceptionHandler.java)
===================================================================
--- branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/ExceptionHandler.java	                        (rev 0)
+++ branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/ExceptionHandler.java	2007-12-14 00:00:16 UTC (rev 4835)
@@ -0,0 +1,32 @@
+package org.ajax4jsf.portlet;
+
+import javax.faces.context.FacesContext;
+import javax.portlet.faces.BridgeException;
+
+import org.ajax4jsf.portlet.application.PortletViewState;
+
+/**
+ * @author asmirnov
+ *
+ */
+public interface ExceptionHandler {
+	
+	/**
+	 * Process JSF exceptions at the portlet action phase
+	 * @param context
+	 * @param windowState
+	 * @param e
+	 * @throws BridgeException
+	 */
+	public void processActionException(FacesContext context, PortletViewState windowState, Exception e) throws BridgeException;
+
+	/**
+	 * Process JSF exceptions at the portlet render phase.
+	 * @param context
+	 * @param windowState
+	 * @param e
+	 * @throws BridgeException
+	 */
+	public void processRenderException(FacesContext context, PortletViewState windowState, Exception e) throws BridgeException;
+
+}

Copied: branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/ExceptionHandlerImpl.java (from rev 4834, trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/ExceptionHandlerImpl.java)
===================================================================
--- branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/ExceptionHandlerImpl.java	                        (rev 0)
+++ branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/ExceptionHandlerImpl.java	2007-12-14 00:00:16 UTC (rev 4835)
@@ -0,0 +1,34 @@
+/**
+ * 
+ */
+package org.ajax4jsf.portlet;
+
+import javax.faces.context.FacesContext;
+import javax.portlet.faces.BridgeException;
+
+import org.ajax4jsf.portlet.application.PortletViewState;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class ExceptionHandlerImpl implements ExceptionHandler {
+
+	/* (non-Javadoc)
+	 * @see org.ajax4jsf.portlet.ExceptionHandler#processActionException(javax.faces.context.FacesContext, org.ajax4jsf.portlet.application.PortletViewState, java.lang.Exception)
+	 */
+	public void processActionException(FacesContext context,
+			PortletViewState windowState, Exception e) throws BridgeException {
+		throw new BridgeException("Error processing action lifecycle",e);
+
+	}
+
+	/* (non-Javadoc)
+	 * @see org.ajax4jsf.portlet.ExceptionHandler#processRenderException(javax.faces.context.FacesContext, org.ajax4jsf.portlet.application.PortletViewState, java.lang.Exception)
+	 */
+	public void processRenderException(FacesContext context,
+			PortletViewState windowState, Exception e) throws BridgeException {
+		throw new BridgeException("Error processing render lifecycle",e);
+	}
+
+}

Modified: branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletViewState.java
===================================================================
--- branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletViewState.java	2007-12-13 22:50:43 UTC (rev 4834)
+++ branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/application/PortletViewState.java	2007-12-14 00:00:16 UTC (rev 4835)
@@ -51,11 +51,11 @@
 			javax.servlet.ServletContext.class,
 			javax.servlet.ServletRequest.class,
 			javax.servlet.ServletResponse.class,
-			javax.servlet.http.HttpSession.class,
-			AjaxContext.class};
+			javax.servlet.http.HttpSession.class, AjaxContext.class };
 
 	private static final String[] excludedRequestAttributes = {
-			"javax.servlet.include", ResponseStateManager.VIEW_STATE_PARAM, AbstractExternalContext.EXCLUDED_PARAMETERS_ATTRIBUTE };
+			"javax.servlet.include", ResponseStateManager.VIEW_STATE_PARAM,
+			AbstractExternalContext.EXCLUDED_PARAMETERS_ATTRIBUTE };
 
 	public static final String REQUEST_PARAMETERS_ATTRIBUTE = PortletViewState.class
 			.getName()
@@ -69,15 +69,12 @@
 
 	private Object componentsState;
 
-	private UIViewRoot viewRoot;
+	private transient UIViewRoot viewRoot;
 
 	private String viewId;
 
-
 	private Map<String, String[]> _requestParameters;
 
-
-
 	/**
 	 * @return the viewId
 	 */
@@ -218,7 +215,8 @@
 		beans = null;
 		Map<String, Object> requestMap = facesContext.getExternalContext()
 				.getRequestMap();
-		List existingAttributes = (List) requestMap.get(AbstractExternalContext.EXCLUDED_PARAMETERS_ATTRIBUTE);
+		List existingAttributes = (List) requestMap
+				.get(AbstractExternalContext.EXCLUDED_PARAMETERS_ATTRIBUTE);
 		if (null == existingAttributes) {
 			existingAttributes = Collections.EMPTY_LIST;
 		}
@@ -249,6 +247,17 @@
 		}
 		_requestParameters = new HashMap<String, String[]>(facesContext
 				.getExternalContext().getRequestParameterValuesMap());
+		// Seam hack - save conversation Id for a request parameter.
+		try {
+			Object conversationId = facesContext.getApplication()
+					.evaluateExpressionGet(facesContext, "#{conversation.id}",
+							Object.class);
+			if(null != conversationId){
+				_requestParameters.put("conversationId", new String[]{conversationId.toString()});
+			}
+		} catch (Exception e) {
+			// Do nothing - no seam conversation found !
+		}
 	}
 
 	public void restoreBeans(FacesContext facesContext) {
@@ -270,13 +279,17 @@
 			restoreBeans(facesContext);
 		}
 		String viewId = getViewId();
-		if(null == viewId && Bridge.PortletPhase.ActionPhase.equals(requestMap.get(Bridge.PORTLET_LIFECYCLE_PHASE))){
-			viewId = (String) externalContext.getRequestParameterMap().get(AbstractExternalContext.VIEW_ID_PARAMETER);
+		if (null == viewId
+				&& Bridge.PortletPhase.ActionPhase.equals(requestMap
+						.get(Bridge.PORTLET_LIFECYCLE_PHASE))) {
+			viewId = (String) externalContext.getRequestParameterMap().get(
+					AbstractExternalContext.VIEW_ID_PARAMETER);
 		}
 		if (null == viewId) {
 			viewId = (String) requestMap.get(Bridge.DEFAULT_VIEWID);
 			if (null == viewId) {
-				throw new BridgeDefaultViewNotSpecifiedException("could'n determine portlet view id");
+				throw new BridgeDefaultViewNotSpecifiedException(
+						"could'n determine portlet view id");
 			}
 		} else {
 			requestMap.put(Bridge.IS_POSTBACK_ATTRIBUTE, Boolean.TRUE);

Modified: branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java
===================================================================
--- branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java	2007-12-13 22:50:43 UTC (rev 4834)
+++ branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/AbstractExternalContext.java	2007-12-14 00:00:16 UTC (rev 4835)
@@ -133,8 +133,24 @@
 	private Map actionSettings;
 
 	private Object context;
+	
+	private boolean hasNavigationRedirect = false;
 
 	/**
+	 * @return the hasNavigationRedirect
+	 */
+	boolean isHasNavigationRedirect() {
+		return hasNavigationRedirect;
+	}
+
+	/**
+	 * @param hasNavigationRedirect the hasNavigationRedirect to set
+	 */
+	void setHasNavigationRedirect(boolean hasNavigationRedirect) {
+		this.hasNavigationRedirect = hasNavigationRedirect;
+	}
+
+	/**
 	 * 
 	 * @param context
 	 * @param request

Modified: branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/FacesContextFactoryImpl.java
===================================================================
--- branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/FacesContextFactoryImpl.java	2007-12-13 22:50:43 UTC (rev 4834)
+++ branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/FacesContextFactoryImpl.java	2007-12-14 00:00:16 UTC (rev 4835)
@@ -133,7 +133,7 @@
 			throw new NullPointerException(
 					"One or more parameters for a faces context instantiation is null");
 		}
-		ExternalContext externalContext;
+		AbstractExternalContext externalContext;
 		if ((context instanceof PortletContext)
 				&& (request instanceof ActionRequest)
 				&& (response instanceof ActionResponse)) {

Modified: branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/FacesContextImpl.java
===================================================================
--- branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/FacesContextImpl.java	2007-12-13 22:50:43 UTC (rev 4834)
+++ branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/FacesContextImpl.java	2007-12-14 00:00:16 UTC (rev 4835)
@@ -79,307 +79,314 @@
 
 /**
  * 
- * Implementation for <code>FacesContext</code> in Portlet Environment. 
+ * Implementation for <code>FacesContext</code> in Portlet Environment.
+ * 
  * @author shura
  * 
  * 
  */
 public class FacesContextImpl extends FacesContext {
-    
-    private boolean released = true;
 
-    private boolean renderResponse;
+	private boolean released = true;
 
-    private boolean responseComplete;
+	private boolean renderResponse;
 
-    private Application application;
+	private boolean responseComplete;
 
-    private UIViewRoot viewRoot;
+	private Application application;
 
-    private Map messages;
+	private UIViewRoot viewRoot;
 
-    private ExternalContext externalContext;
+	private Map messages;
 
-    private Lifecycle lifecycle;
+	private AbstractExternalContext externalContext;
 
-    private ResponseWriter responseWriter;
+	private Lifecycle lifecycle;
 
-    private ResponseStream responseStream;
+	private ResponseWriter responseWriter;
 
-    private ELContext elContext;
+	private ResponseStream responseStream;
 
-    public FacesContextImpl(ExternalContext externalContext, Lifecycle lifecycle) {
-	super();
-	setCurrentInstance(this);
-	this.externalContext = externalContext;
-	this.lifecycle = lifecycle;
-	this.released = false;
-    }
+	private ELContext elContext;
 
-    /*
-         * 
-         * (non-Javadoc)
-         * 
-         * 
-         * 
-         * @see org.apache.cocoon.components.faces.context.CocoonFacesContext#getLifecycle()
-         * 
-         */
-    public Lifecycle getLifecycle() {
-	checkReleased();
-	return this.lifecycle;
-    }
+	public FacesContextImpl(AbstractExternalContext externalContext,
+			Lifecycle lifecycle) {
+		super();
+		setCurrentInstance(this);
+		this.externalContext = externalContext;
+		this.lifecycle = lifecycle;
+		this.released = false;
+	}
 
-    public ELContext getELContext() {
-	checkReleased();
-	if (this.elContext == null) {
-	    Application application = getApplication();
-	    this.elContext = new ELContextImpl(application.getELResolver());
-	    this.elContext.putContext(FacesContext.class, this);
-	    UIViewRoot root = getViewRoot();
-	    if (null != root) {
-		this.elContext.setLocale(root.getLocale());
-	    }
+	/*
+	 * 
+	 * (non-Javadoc)
+	 * 
+	 * 
+	 * 
+	 * @see org.apache.cocoon.components.faces.context.CocoonFacesContext#getLifecycle()
+	 * 
+	 */
+	public Lifecycle getLifecycle() {
+		checkReleased();
+		return this.lifecycle;
 	}
-	return this.elContext;
-    }
 
-    /*
-         * 
-         * (non-Javadoc)
-         * 
-         * 
-         * 
-         * @see javax.faces.context.FacesContext#getExternalContext()
-         * 
-         */
-    public ExternalContext getExternalContext() {
-	checkReleased();
-	return this.externalContext;
-    }
+	public ELContext getELContext() {
+		checkReleased();
+		if (this.elContext == null) {
+			Application application = getApplication();
+			this.elContext = new ELContextImpl(application.getELResolver());
+			this.elContext.putContext(FacesContext.class, this);
+			UIViewRoot root = getViewRoot();
+			if (null != root) {
+				this.elContext.setLocale(root.getLocale());
+			}
+		}
+		return this.elContext;
+	}
 
-    /**
-         * 
-         * @param externalContext
-         * 
-         * The externalContext to set.
-         * 
-         */
-    // public void setExternalContext(ExternalContext externalContext) {
-    // this.externalContext = externalContext;
-    // }
-    /*
-         * 
-         * (non-Javadoc)
-         * 
-         * 
-         * 
-         * @see javax.faces.context.FacesContext#getResponseStream()
-         * 
-         */
-    public ResponseStream getResponseStream() {
-	checkReleased();
-	return this.responseStream;
-    }
+	/*
+	 * 
+	 * (non-Javadoc)
+	 * 
+	 * 
+	 * 
+	 * @see javax.faces.context.FacesContext#getExternalContext()
+	 * 
+	 */
+	public ExternalContext getExternalContext() {
+		checkReleased();
+		return this.externalContext;
+	}
 
-    /*
-         * 
-         * (non-Javadoc)
-         * 
-         * 
-         * 
-         * @see javax.faces.context.FacesContext#setResponseStream(javax.faces.context.ResponseStream)
-         * 
-         */
-    public void setResponseStream(ResponseStream responseStream) {
-	checkReleased();
-	this.responseStream = responseStream;
-    }
+	/**
+	 * 
+	 * @param externalContext
+	 * 
+	 * The externalContext to set.
+	 * 
+	 */
+	// public void setExternalContext(ExternalContext externalContext) {
+	// this.externalContext = externalContext;
+	// }
+	/*
+	 * 
+	 * (non-Javadoc)
+	 * 
+	 * 
+	 * 
+	 * @see javax.faces.context.FacesContext#getResponseStream()
+	 * 
+	 */
+	public ResponseStream getResponseStream() {
+		checkReleased();
+		return this.responseStream;
+	}
 
-    /*
-         * 
-         * (non-Javadoc)
-         * 
-         * 
-         * 
-         * @see javax.faces.context.FacesContext#getResponseWriter()
-         * 
-         */
-    public ResponseWriter getResponseWriter() {
-	checkReleased();
-	return this.responseWriter;
-    }
+	/*
+	 * 
+	 * (non-Javadoc)
+	 * 
+	 * 
+	 * 
+	 * @see javax.faces.context.FacesContext#setResponseStream(javax.faces.context.ResponseStream)
+	 * 
+	 */
+	public void setResponseStream(ResponseStream responseStream) {
+		checkReleased();
+		this.responseStream = responseStream;
+	}
 
-    /*
-         * 
-         * (non-Javadoc)
-         * 
-         * 
-         * 
-         * @see javax.faces.context.FacesContext#setResponseWriter(javax.faces.context.ResponseWriter)
-         * 
-         */
-    public void setResponseWriter(ResponseWriter responseWriter) {
-	checkReleased();
-	this.responseWriter = responseWriter;
-    }
+	/*
+	 * 
+	 * (non-Javadoc)
+	 * 
+	 * 
+	 * 
+	 * @see javax.faces.context.FacesContext#getResponseWriter()
+	 * 
+	 */
+	public ResponseWriter getResponseWriter() {
+		checkReleased();
+		return this.responseWriter;
+	}
 
-    /*
-         * 
-         * (non-Javadoc)
-         * 
-         * 
-         * 
-         * @see javax.faces.context.FacesContext#release()
-         * 
-         */
-    public void release() {
-	// Release this and default instances...
-	this.released = true;
-	FacesContext.setCurrentInstance(null);
-	// defaultContext = null;
-	this.lifecycle = null;
-	this.externalContext = null;
-	this.responseWriter = null;
-	this.application = null;
-	this.viewRoot = null;
-	this.messages = null;
-	this.responseWriter = null;
-    }
+	/*
+	 * 
+	 * (non-Javadoc)
+	 * 
+	 * 
+	 * 
+	 * @see javax.faces.context.FacesContext#setResponseWriter(javax.faces.context.ResponseWriter)
+	 * 
+	 */
+	public void setResponseWriter(ResponseWriter responseWriter) {
+		checkReleased();
+		this.responseWriter = responseWriter;
+	}
 
-    public Application getApplication() {
-	checkReleased();
-	if (this.application == null) {
-	    ApplicationFactory aFactory = (ApplicationFactory) FactoryFinder
-		    .getFactory(FactoryFinder.APPLICATION_FACTORY);
-	    this.application = aFactory.getApplication();
+	/*
+	 * 
+	 * (non-Javadoc)
+	 * 
+	 * 
+	 * 
+	 * @see javax.faces.context.FacesContext#release()
+	 * 
+	 */
+	public void release() {
+		// Release this and default instances...
+		this.released = true;
+		FacesContext.setCurrentInstance(null);
+		// defaultContext = null;
+		this.lifecycle = null;
+		this.externalContext = null;
+		this.responseWriter = null;
+		this.application = null;
+		this.viewRoot = null;
+		this.messages = null;
+		this.responseWriter = null;
 	}
-	return this.application;
-    }
 
-    public Iterator getClientIdsWithMessages() {
-	checkReleased();
-	if (this.messages == null) {
-	    return Collections.EMPTY_LIST.iterator();
-	} else {
-	    return this.messages.keySet().iterator();
+	public Application getApplication() {
+		checkReleased();
+		if (this.application == null) {
+			ApplicationFactory aFactory = (ApplicationFactory) FactoryFinder
+					.getFactory(FactoryFinder.APPLICATION_FACTORY);
+			this.application = aFactory.getApplication();
+		}
+		return this.application;
 	}
-    }
 
-    public Severity getMaximumSeverity() {
-	checkReleased();
-	Severity max = null;
-	Iterator messages = getMessages();
-	while (messages.hasNext()) {
-	    FacesMessage msg = (FacesMessage) messages.next();
-	    Severity severity = msg.getSeverity();
-	    if ((null == max) || (max.getOrdinal() < severity.getOrdinal())) {
-		max = severity;
-	    }
+	public Iterator getClientIdsWithMessages() {
+		checkReleased();
+		if (this.messages == null) {
+			return Collections.EMPTY_LIST.iterator();
+		} else {
+			return this.messages.keySet().iterator();
+		}
 	}
-	return max;
-    }
 
-    public Iterator getMessages() {
-	checkReleased();
-	if (this.messages == null) {
-	    return Collections.EMPTY_LIST.iterator();
+	public Severity getMaximumSeverity() {
+		checkReleased();
+		Severity max = null;
+		Iterator messages = getMessages();
+		while (messages.hasNext()) {
+			FacesMessage msg = (FacesMessage) messages.next();
+			Severity severity = msg.getSeverity();
+			if ((null == max) || (max.getOrdinal() < severity.getOrdinal())) {
+				max = severity;
+			}
+		}
+		return max;
 	}
-	List messages = new ArrayList();
-	for (Iterator i = this.messages.values().iterator(); i.hasNext();) {
-	    final List list = (List) i.next();
-	    messages.addAll(list);
+
+	public Iterator getMessages() {
+		checkReleased();
+		if (this.messages == null) {
+			return Collections.EMPTY_LIST.iterator();
+		}
+		List messages = new ArrayList();
+		for (Iterator i = this.messages.values().iterator(); i.hasNext();) {
+			final List list = (List) i.next();
+			messages.addAll(list);
+		}
+		if (messages.size() > 0) {
+			return messages.iterator();
+		}
+		return Collections.EMPTY_LIST.iterator();
 	}
-	if (messages.size() > 0) {
-	    return messages.iterator();
+
+	public Iterator getMessages(String clientID) {
+		checkReleased();
+		if (this.messages != null) {
+			final List list = (List) this.messages.get(clientID);
+			if (list != null) {
+				return list.iterator();
+			}
+		}
+		return Collections.EMPTY_LIST.iterator();
 	}
-	return Collections.EMPTY_LIST.iterator();
-    }
 
-    public Iterator getMessages(String clientID) {
-	checkReleased();
-	if (this.messages != null) {
-	    final List list = (List) this.messages.get(clientID);
-	    if (list != null) {
-		return list.iterator();
-	    }
+	public RenderKit getRenderKit() {
+		checkReleased();
+		UIViewRoot viewRoot = getViewRoot();
+		if (viewRoot == null) {
+			return null;
+		}
+		String renderKitId = viewRoot.getRenderKitId();
+		if (renderKitId == null) {
+			return null;
+		} else {
+			RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
+					.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+			return rkFactory.getRenderKit(this, renderKitId);
+		}
 	}
-	return Collections.EMPTY_LIST.iterator();
-    }
 
-    public RenderKit getRenderKit() {
-	checkReleased();
-	UIViewRoot viewRoot = getViewRoot();
-	if (viewRoot == null) {
-	    return null;
+	public boolean getRenderResponse() {
+		checkReleased();
+		return this.renderResponse;
 	}
-	String renderKitId = viewRoot.getRenderKitId();
-	if (renderKitId == null) {
-	    return null;
-	} else {
-	    RenderKitFactory rkFactory = (RenderKitFactory) FactoryFinder
-		    .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
-	    return rkFactory.getRenderKit(this, renderKitId);
+
+	public boolean getResponseComplete() {
+		checkReleased();
+		return this.responseComplete;
 	}
-    }
 
-    public boolean getRenderResponse() {
-	checkReleased();
-	return this.renderResponse;
-    }
+	public UIViewRoot getViewRoot() {
+		checkReleased();
+		return this.viewRoot;
+	}
 
-    public boolean getResponseComplete() {
-	checkReleased();
-	return this.responseComplete;
-    }
+	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 UIViewRoot getViewRoot() {
-	checkReleased();
-	return this.viewRoot;
-    }
-
-    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) {
+		checkReleased();
+		if (message == null) {
+			throw new NullPointerException("Message can't be null");
 		}
+		if (this.messages == null) {
+			this.messages = new HashMap();
+		}
+		List list = (List) this.messages.get(clientID);
+		if (list == null) {
+			list = new ArrayList();
+			this.messages.put(clientID, list);
+		}
+		list.add(message);
 	}
-    }
 
-    public void addMessage(String clientID, FacesMessage message) {
-	checkReleased();
-	if (message == null) {
-	    throw new NullPointerException("Message can't be null");
+	public void renderResponse() {
+		checkReleased();
+		this.renderResponse = true;
 	}
-	if (this.messages == null) {
-	    this.messages = new HashMap();
+
+	public void responseComplete() {
+		checkReleased();
+		if (externalContext.isHasNavigationRedirect()) {
+			this.renderResponse = true;
+		} else {
+			this.responseComplete = true;
+		}
 	}
-	List list = (List) this.messages.get(clientID);
-	if (list == null) {
-	    list = new ArrayList();
-	    this.messages.put(clientID, list);
-	}
-	list.add(message);
-    }
 
-    public void renderResponse() {
-	checkReleased();
-	this.renderResponse = true;
-    }
-
-    public void responseComplete() {
-	checkReleased();
-	this.responseComplete = true;
-    }
-
-    private void checkReleased() {
-	if (this.released) {
-	    throw new IllegalStateException("Context is released.");
+	private void checkReleased() {
+		if (this.released) {
+			throw new IllegalStateException("Context is released.");
+		}
 	}
-    }
 }
\ No newline at end of file

Modified: branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java
===================================================================
--- branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java	2007-12-13 22:50:43 UTC (rev 4834)
+++ branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortletContextImpl.java	2007-12-14 00:00:16 UTC (rev 4835)
@@ -8,6 +8,8 @@
 import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -19,7 +21,9 @@
 import java.util.Set;
 import java.util.regex.Pattern;
 
+import javax.faces.application.ViewHandler;
 import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
 import javax.faces.context.FacesContextFactory;
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -31,28 +35,33 @@
 import javax.portlet.PortletSession;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
+import javax.portlet.PortletURL;
 import javax.portlet.faces.Bridge;
 
 import org.ajax4jsf.webapp.WebXml;
 
 /**
- * Version of the {@link ExternalContext} for a Portlet request. {@link FacesContextFactory} will create instance of this class
- * for a portal <code>action</code> phase.
+ * Version of the {@link ExternalContext} for a Portlet request.
+ * {@link FacesContextFactory} will create instance of this class for a portal
+ * <code>action</code> phase.
+ * 
  * @author asmirnov
  * 
  */
 public class PortletContextImpl extends AbstractExternalContext {
 
+	public static final String ACTION_URL_DO_NOTHITG = "/ajax4jsfPortletBridge/actionUrl/do/nothitg";
 	private String namespace;
 
 	public PortletContextImpl(PortletContext context, PortletRequest request,
 			PortletResponse response) {
 		super(context, request, response);
 		WebXml webXml = (WebXml) context.getAttribute(WebXml.CONTEXT_ATTRIBUTE);
-		if(null != webXml){
-			_servletPath = webXml.getFacesServletPrefix();			
+		if (null != webXml) {
+			_servletPath = webXml.getFacesServletPrefix();
 		}
-		ArrayList excludedAttributes = Collections.list(request.getAttributeNames());
+		ArrayList excludedAttributes = Collections.list(request
+				.getAttributeNames());
 		request.setAttribute(EXCLUDED_PARAMETERS_ATTRIBUTE, excludedAttributes);
 	}
 
@@ -61,26 +70,26 @@
 	}
 
 	public String getResponseCharacterEncoding() {
-			return null;
+		return null;
 	}
 
 	public String getResponseContentType() {
-			return null;
+		return null;
 	}
 
 	public void setRequestCharacterEncoding(String encoding)
 			throws UnsupportedEncodingException {
-			try {
-				ActionRequest actionRequest = (ActionRequest) getPortletRequest();
-				actionRequest.setCharacterEncoding(encoding);
-			} catch (IllegalStateException e) {
-				// TODO: handle exception
-			}
+		try {
+			ActionRequest actionRequest = (ActionRequest) getPortletRequest();
+			actionRequest.setCharacterEncoding(encoding);
+		} catch (IllegalStateException e) {
+			// TODO: handle exception
+		}
 	}
 
 	public String getRequestCharacterEncoding() {
-			ActionRequest actionRequest = (ActionRequest) getPortletRequest();
-			return actionRequest.getCharacterEncoding();
+		ActionRequest actionRequest = (ActionRequest) getPortletRequest();
+		return actionRequest.getCharacterEncoding();
 	}
 
 	public String getRequestContentType() {
@@ -105,12 +114,11 @@
 
 	protected String getNamespace() {
 		if (null == namespace) {
-				namespace = (String) getRequestParameter(
-						AbstractExternalContext.NAMESPACE_PARAMETER);
-				if(null == namespace){
-					throw new IllegalStateException(
-					"Can not determine portlet namespace");
-				}
+			namespace = (String) getRequestParameter(AbstractExternalContext.NAMESPACE_PARAMETER);
+			if (null == namespace) {
+				throw new IllegalStateException(
+						"Can not determine portlet namespace");
+			}
 		}
 		return namespace;
 	}
@@ -221,21 +229,34 @@
 		if (null == path) {
 			throw new NullPointerException("Path to new view is null");
 		}
-			throw new IllegalStateException(
-					"Dispatch to new view not at render phase");
+		throw new IllegalStateException(
+				"Dispatch to new view not at render phase");
 	}
 
-	private static final Pattern absoluteUrl = Pattern.compile(""); 
-	private static final Pattern directLink = Pattern.compile(""); 
-	private static final Pattern viewIdParam = Pattern.compile(""); 
+	private static final Pattern absoluteUrl = Pattern.compile("");
+	private static final Pattern directLink = Pattern.compile("");
+	private static final Pattern viewIdParam = Pattern.compile("");
 
 	/**
 	 * @param parameters
 	 * @return
 	 */
 	@Override
-	protected String createActionUrl(Map<String, String> parameters){
-		return "/ajax4jsfPortletBridge/actionUrl/do/nothitg";
+	protected String createActionUrl(Map<String, String> parameters) {
+		String dummyActionURL = getRequestContextPath() + ACTION_URL_DO_NOTHITG;
+		try {
+			PortalActionURL actionUrl = new PortalActionURL(dummyActionURL);
+			for (Iterator<Map.Entry<String, String>> param = parameters
+					.entrySet().iterator(); param.hasNext();) {
+				Map.Entry<String, String> parameter = param.next();
+				actionUrl
+						.addParameter(parameter.getKey(), parameter.getValue());
+			}
+			return actionUrl.toString();
+		} catch (MalformedURLException e) {
+
+		}
+		return dummyActionURL;
 	}
 
 	public String encodeResourceURL(String url) {
@@ -271,7 +292,7 @@
 	}
 
 	private String _pathInfo = null;
-	
+
 	public String getRequestPathInfo() {
 		String pathInfo = (String) getRequestParameter(VIEW_ID_PARAMETER);
 		if (null == pathInfo) {
@@ -281,7 +302,7 @@
 	}
 
 	private String _servletPath = null;
-	
+
 	public String getRequestServletPath() {
 		return _servletPath;
 	}
@@ -307,12 +328,38 @@
 	}
 
 	public void redirect(String url) throws IOException {
-		if (null == url) {
+		if (null == url || url.length() < 0) {
 			throw new NullPointerException("Path to redirect is null");
 		}
 		PortalActionURL actionURL = new PortalActionURL(url);
-		if(url.startsWith("#") || (!actionURL.isInContext(getRequestContextPath())) || "true".equalsIgnoreCase(actionURL.getParameter(Bridge.DIRECT_LINK))){
+		if (url.startsWith("#")
+				|| (!actionURL.isInContext(getRequestContextPath()))
+				|| "true".equalsIgnoreCase(actionURL
+						.getParameter(Bridge.DIRECT_LINK))) {
 			((ActionResponse) getResponse()).sendRedirect(url);
+		} else {
+			internalRedirect(actionURL);
 		}
 	}
+
+	/**
+	 * @param actionURL
+	 */
+	protected void internalRedirect(PortalActionURL actionURL) {
+		// Detect ViewId from URL and create new view for them.
+		String viewId = actionURL.getParameter(VIEW_ID_PARAMETER);
+		if (null != viewId) {
+			try {
+				viewId = URLDecoder.decode(viewId, "UTF8");
+				FacesContext facesContext = FacesContext.getCurrentInstance();
+				ViewHandler viewHandler = facesContext.getApplication()
+						.getViewHandler();
+				facesContext.setViewRoot(viewHandler.createView(facesContext,
+						viewId));
+				setHasNavigationRedirect(true);
+			} catch (UnsupportedEncodingException e) {
+				// Do nothing - UTF-8 encoding is a default.
+			}
+		}
+	}
 }

Modified: branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortletRenderContextImpl.java
===================================================================
--- branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortletRenderContextImpl.java	2007-12-13 22:50:43 UTC (rev 4834)
+++ branches/3.1.x/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/context/PortletRenderContextImpl.java	2007-12-14 00:00:16 UTC (rev 4835)
@@ -91,11 +91,15 @@
 			throw new NullPointerException("Path to redirect is null");
 		}
 		PortalActionURL actionURL = new PortalActionURL(url);
-		if(!actionURL.isInContext(getRequestContextPath()) || "true".equalsIgnoreCase(actionURL.getParameter(Bridge.DIRECT_LINK))){
-			throw new IllegalStateException(
-			"Redirect to new url not at action phase");
+      if((!actionURL.isInContext(getRequestContextPath()) && null == actionURL.getParameter(VIEW_ID_PARAMETER)) || "true".equalsIgnoreCase(actionURL.getParameter(Bridge.DIRECT_LINK))){
+//			dispatch(url);
+
+//         throw new IllegalStateException(
+//			"Redirect to new url not at action phase");
+		} else {
+		// HACK - if page is in the context, just treat it as navigation case
+			internalRedirect(actionURL);
 		}
-		// HACK - if page is in the context, just treat it as navigation case
 	}
 
 	@Override
@@ -109,14 +113,14 @@
 			Entry<String, String> parameter = param.next();
 			portletURL.setParameter(parameter.getKey(), parameter.getValue());
 		}
-		return portletURL.toString();
+      return portletURL.toString();
 	}
 
 	public void dispatch(String path) throws IOException {
 		if (null == path) {
 			throw new NullPointerException("Path to new view is null");
 		}
-		PortletRequestDispatcher dispatcher = getPortletContext()
+      PortletRequestDispatcher dispatcher = getPortletContext()
 				.getRequestDispatcher(path);
 		if (null == dispatcher) {
 			throw new IllegalStateException(

Modified: branches/3.1.x/framework/impl/pom.xml
===================================================================
--- branches/3.1.x/framework/impl/pom.xml	2007-12-13 22:50:43 UTC (rev 4834)
+++ branches/3.1.x/framework/impl/pom.xml	2007-12-14 00:00:16 UTC (rev 4835)
@@ -1,4 +1,6 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 	<!--
 		<parent>
 		<artifactId>impl-parent</artifactId>
@@ -53,9 +55,11 @@
 						</goals>
 						<configuration>
 							<tasks>
-								<ant antfile="${basedir}/generatescript.xml" inheritRefs="true">
+								<ant
+									antfile="${basedir}/generatescript.xml" inheritRefs="true">
 									<target name="assembly" />
-									<property name="target-dir" value="${project.build.directory}/javascript">
+									<property name="target-dir"
+										value="${project.build.directory}/javascript">
 									</property>
 								</ant>
 							</tasks>
@@ -79,6 +83,82 @@
 					</execution>
 				</executions>
 			</plugin>
+			<plugin>
+				<groupId>org.richfaces.cdk</groupId>
+				<artifactId>maven-javascript-plugin</artifactId>
+				<version>${project.version}</version>
+				<executions>
+					<execution>
+						<goals>
+							<goal>compress</goal>
+						</goals>
+						<configuration>
+							<nosuffix>false</nosuffix>
+							<outputDirectory>
+								${project.build.directory}/compressed/
+							</outputDirectory>
+							<aggregations>
+								<aggregation>
+									<!-- remove files after aggregation (default: false)
+										<removeIncluded>true</removeIncluded>
+									-->
+									<!-- insert new line after each concatenation (default: false) -->
+									<insertNewLine>true</insertNewLine>
+									<output>
+										${project.build.outputDirectory}/org/ajax4jsf/framework.pack.js
+									</output>
+									<!-- files to include, path relative to output's directory or absolute path-->
+									<includes>
+										<include>
+											${project.build.directory}/compressed/org/ajax4jsf/javascript/scripts/prototype-min.js
+										</include>
+										<include>
+											${project.build.directory}/compressed/org/ajax4jsf/javascript/scripts/AJAX-min.js
+										</include>
+										<include>
+											${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/scriptaculous/scriptaculous-min.js
+										</include>
+										<include>
+											${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/jquery/jquery-min.js
+										</include>
+										<include>
+											${project.build.directory}/compressed/org/ajax4jsf/javascript/scripts/dnd-min.js
+										</include>
+										<include>**/*-min.js</include>
+									</includes>
+									<!-- files to exclude, path relative to output's directory -->
+									<excludes>
+										<exclude>**/*.pack.js</exclude>
+										<!-- exclude parts of the scriptaculous, so big file already included -->
+										<exclude>
+											**/scriptaculous/*.js
+										</exclude>
+										<exclude>
+											**/jquery.jcarousel-min.js
+										</exclude>
+										<exclude>
+											**/compressed.css
+										</exclude>
+									</excludes>
+								</aggregation>
+							</aggregations>
+							<resources>
+								<resource>
+									<directory>
+										target/javascript
+									</directory>
+								</resource>
+								<resource>
+									<directory>
+										src/main/resources
+									</directory>
+								</resource>
+							</resources>
+						</configuration>
+
+					</execution>
+				</executions>
+			</plugin>
 		</plugins>
 	</build>
 	<dependencies>
@@ -193,22 +273,22 @@
 		</dependency>
 	</dependencies>
 	<profiles>
-	<profile>
-		<id>clover</id>
-		<build>
-			<plugins>
-				<plugin>
-					<groupId>org.apache.maven.plugins</groupId>
-					<artifactId>maven-clover-plugin</artifactId>
-					<configuration>
-						<excludes combine.children="append">
-							<exclude>**/javacc/**</exclude>
-						</excludes>
-					</configuration>
-				</plugin>
-			</plugins>
-		</build>
-	</profile>
+		<profile>
+			<id>clover</id>
+			<build>
+				<plugins>
+					<plugin>
+						<groupId>org.apache.maven.plugins</groupId>
+						<artifactId>maven-clover-plugin</artifactId>
+						<configuration>
+							<excludes combine.children="append">
+								<exclude>**/javacc/**</exclude>
+							</excludes>
+						</configuration>
+					</plugin>
+				</plugins>
+			</build>
+		</profile>
 	</profiles>
 	<properties>
 		<jsfVersion>1.1</jsfVersion>

Modified: branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java
===================================================================
--- branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java	2007-12-13 22:50:43 UTC (rev 4834)
+++ branches/3.1.x/framework/impl/src/main/java/org/ajax4jsf/renderkit/HeaderResourcesRendererBase.java	2007-12-14 00:00:16 UTC (rev 4835)
@@ -25,10 +25,12 @@
 import java.util.LinkedHashSet;
 
 import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
 
 import org.ajax4jsf.renderkit.HeaderResourceProducer;
 import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
 import org.ajax4jsf.webapp.BaseFilter;
 
 /**
@@ -47,7 +49,7 @@
 	 * 
 	 * @see org.ajax4jsf.renderkit.HeaderResourceProducer#getHeaderScripts(javax.faces.context.FacesContext)
 	 */
-	public  LinkedHashSet getHeaderScripts(FacesContext context,
+	public LinkedHashSet getHeaderScripts(FacesContext context,
 			UIComponent component) {
 		return getUrisSet(context, getScripts(), component);
 	}
@@ -67,7 +69,7 @@
 	 * 
 	 * @see org.ajax4jsf.renderkit.HeaderResourceProducer#getHeaderStyles(javax.faces.context.FacesContext)
 	 */
-	public  LinkedHashSet getHeaderStyles(FacesContext context,
+	public LinkedHashSet getHeaderStyles(FacesContext context,
 			UIComponent component) {
 		return getUrisSet(context, getStyles(), component);
 	}
@@ -93,7 +95,7 @@
 			InternetResource[] resources, UIComponent component) {
 		if (null != resources) {
 			LinkedHashSet uris = new LinkedHashSet(); // Collections.singleton(ajaxScript.getUri(context,
-														// null));
+			// null));
 			for (int i = 0; i < resources.length; i++) {
 				InternetResource resource = resources[i];
 				uris.add(resource.getUri(context, component));
@@ -113,10 +115,19 @@
 			throws IOException {
 		if ((null == context.getExternalContext().getRequestMap().get(
 				BaseFilter.RESPONSE_WRAPPER_ATTRIBUTE))
-				/*&& (!AjaxRendererUtils.isAjaxRequest(context))*/) {
+		/* && (!AjaxRendererUtils.isAjaxRequest(context)) */) {
 			// Filter not used - encode scripts and CSS before component.
-			encodeResourcesArray(context, component, getScripts());
-			encodeResourcesArray(context, component, getStyles());
+			ExternalContext externalContext = context.getExternalContext();
+			String scriptStrategy = externalContext
+					.getInitParameter(InternetResourceBuilder.LOAD_STYLE_STRATEGY_PARAM);
+			if (null == scriptStrategy || !InternetResourceBuilder.LOAD_NONE.equals(scriptStrategy)) {
+					encodeResourcesArray(context, component, getScripts());
+			}
+			String styleStrategy = externalContext
+					.getInitParameter(InternetResourceBuilder.LOAD_STYLE_STRATEGY_PARAM);
+			if (null != styleStrategy || !InternetResourceBuilder.LOAD_NONE.equals(styleStrategy)) {
+					encodeResourcesArray(context, component, getStyles());
+			}
 		}
 	}
 
@@ -126,10 +137,12 @@
 	 * @param scripts
 	 * @throws IOException
 	 */
-	protected void encodeResourcesArray(FacesContext context, UIComponent component, InternetResource[] scripts) throws IOException {
+	protected void encodeResourcesArray(FacesContext context,
+			UIComponent component, InternetResource[] scripts)
+			throws IOException {
 		if (scripts != null) {
 			for (int i = 0; i < scripts.length; i++) {
-				scripts[i].encode(context,component);
+				scripts[i].encode(context, component);
 			}
 		}
 	}

Modified: branches/3.1.x/samples/richfaces-demo/src/main/webapp/WEB-INF/web.xml
===================================================================
--- branches/3.1.x/samples/richfaces-demo/src/main/webapp/WEB-INF/web.xml	2007-12-13 22:50:43 UTC (rev 4834)
+++ branches/3.1.x/samples/richfaces-demo/src/main/webapp/WEB-INF/web.xml	2007-12-14 00:00:16 UTC (rev 4835)
@@ -43,14 +43,14 @@
   <param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
   <param-value>NEKO</param-value>
  </context-param>
- 	<!--context-param>
+ 	<context-param>
 		<param-name>org.richfaces.LoadStyleStrategy</param-name>
 		<param-value>ALL</param-value>
 	</context-param>
 	<context-param>
 		<param-name>org.richfaces.LoadScriptStrategy</param-name>
 		<param-value>ALL</param-value>
-	</context-param-->
+	</context-param>
  
  <filter>
   <display-name>Ajax4jsf Filter</display-name>

Modified: branches/3.1.x/ui/assembly/pom.xml
===================================================================
--- branches/3.1.x/ui/assembly/pom.xml	2007-12-13 22:50:43 UTC (rev 4834)
+++ branches/3.1.x/ui/assembly/pom.xml	2007-12-14 00:00:16 UTC (rev 4835)
@@ -1,4 +1,6 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 	<parent>
 		<artifactId>ui</artifactId>
 		<groupId>org.richfaces</groupId>
@@ -58,6 +60,7 @@
 							</taglib>
 						</taglibs>
 					</library>
+					<commonStyle>org/richfaces/skin.xcss</commonStyle>
 				</configuration>
 				<executions>
 					<execution>
@@ -222,6 +225,82 @@
 					</outputDirectory>
 				</configuration>
 			</plugin>
+			<plugin>
+				<groupId>org.richfaces.cdk</groupId>
+				<artifactId>maven-javascript-plugin</artifactId>
+				<version>${project.version}</version>
+				<executions>
+					<execution>
+						<goals>
+							<goal>compress</goal>
+						</goals>
+					</execution>
+				</executions>
+				<configuration>
+					<nosuffix>false</nosuffix>
+					<outputDirectory>
+						${project.build.directory}/compressed/
+					</outputDirectory>
+					<aggregations>
+						<aggregation>
+							<!-- remove files after aggregation (default: false)
+								<removeIncluded>true</removeIncluded>
+							-->
+							<!-- insert new line after each concatenation (default: false) -->
+							<insertNewLine>true</insertNewLine>
+							<output>
+								${project.build.outputDirectory}/org/richfaces/ui.pack.js
+							</output>
+							<!-- files to include, path relative to output's directory or absolute path-->
+							<includes>
+								<include>
+									${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/drag-indicator-min.js
+								</include>
+								<include>
+									${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/simple-draggable-min.js
+								</include>
+								<include>
+									${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/simple-dropzone-min.js
+								</include>
+								<include>
+									${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/tree-min.js
+								</include>
+								<include>
+									${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/tree-selection-min.js
+								</include>
+								<include>
+									${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/tree-item-min.js
+								</include>
+								<include>
+									${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/tree-item-dnd-min.js
+								</include>
+								<include>
+									${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/modalPanel-min.js
+								</include>
+								<include>
+									${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/modalPanelBorders-min.js
+								</include>
+								<include>**/*-min.js</include>
+							</includes>
+							<!-- files to exclude, path relative to output's directory -->
+							<excludes>
+								<exclude>**/*.pack.js</exclude>
+								<!--
+									<exclude>
+									${project.build.directory}/compressed/org/richfaces/renderkit/html/scripts/jquery.jcarousel-min.js
+									</exclude>
+								-->
+								<exclude>**/scriptaculo*</exclude>
+								<exclude>**/scriptaculo*/**</exclude>
+							</excludes>
+						</aggregation>
+					</aggregations>
+					<includes>
+						<include>**/*.js</include>
+					</includes>
+				</configuration>
+			</plugin>
+
 		</plugins>
 	</build>
 	<dependencies />




More information about the richfaces-svn-commits mailing list