JBoss Rich Faces SVN: r5404 - in trunk: extensions/portletbridge/portletbridge-impl and 7 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2008-01-15 20:35:34 -0500 (Tue, 15 Jan 2008)
New Revision: 5404
Added:
trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockPortletSession.java
trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/seam/
trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/seam/SeamPhaseListener.java
trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/
trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/AbstractSeamPortletTestCase.java
trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/MockUserTransaction.java
trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/PhaseListenerActionPhaseTest.java
trunk/samples/seamPortletEar/seamBookingPortlet/src/main/java/org/ajax4jsf/portlet/seam/SeamPhaseListener.java
Modified:
trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/AbstractAjax4jsfPortletTestCase.java
trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockActionRequest.java
trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockPortletContext.java
trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockPortletRequest.java
trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockRenderRequest.java
trunk/extensions/portletbridge/portletbridge-impl/pom.xml
trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/context/ContextFactoryTest.java
trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/context/PortletExternalContextTest.java
trunk/samples/scrollableDataTableDemo/src/main/webapp/WEB-INF/web.xml
Log:
Create Seam test classes for a portlet requests.
Modified: trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/AbstractAjax4jsfPortletTestCase.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/AbstractAjax4jsfPortletTestCase.java 2008-01-16 01:30:07 UTC (rev 5403)
+++ trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/AbstractAjax4jsfPortletTestCase.java 2008-01-16 01:35:34 UTC (rev 5404)
@@ -24,7 +24,7 @@
public void setUp() throws Exception {
super.setUp();
- portletContext = new MockPortletContext();
+ portletContext = new MockPortletContext(servletContext);
portletConfig = new MockPortletConfig(portletContext);
}
@@ -42,7 +42,7 @@
*
*/
protected void setupActionRequest() {
- actionRequest = new MockActionRequest();
+ actionRequest = new MockActionRequest(portletContext);
actionResponse = new MockActionResponse();
externalContext.setRequest(actionRequest);
externalContext.setResponse(actionResponse);
@@ -52,7 +52,7 @@
*
*/
protected void setupRenderRequest() {
- renderRequest = new MockRenderRequest();
+ renderRequest = new MockRenderRequest(portletContext);
renderResponse = new MockRenderResponse();
externalContext.setRequest(renderRequest);
externalContext.setResponse(renderResponse);
Modified: trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockActionRequest.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockActionRequest.java 2008-01-16 01:30:07 UTC (rev 5403)
+++ trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockActionRequest.java 2008-01-16 01:35:34 UTC (rev 5404)
@@ -8,6 +8,7 @@
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import javax.portlet.ActionRequest;
+import javax.portlet.PortletContext;
/**
* @author asmirnov
@@ -15,7 +16,12 @@
*/
public class MockActionRequest extends MockPortletRequest implements
ActionRequest {
- /* (non-Javadoc)
+ public MockActionRequest(PortletContext portletContext) {
+ super(portletContext);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
* @see javax.portlet.ActionRequest#getCharacterEncoding()
*/
public String getCharacterEncoding() {
Modified: trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockPortletContext.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockPortletContext.java 2008-01-16 01:30:07 UTC (rev 5403)
+++ trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockPortletContext.java 2008-01-16 01:35:34 UTC (rev 5404)
@@ -14,6 +14,8 @@
import javax.portlet.PortletContext;
import javax.portlet.PortletRequestDispatcher;
+import org.apache.shale.test.mock.MockServletContext;
+
/**
* @author asmirnov
*
@@ -22,42 +24,39 @@
public static final String PORTLET_INIT_VALUE = "portlet_init_value";
public static final String INIT_PARAMETER = "init_parameter";
- private Map<String, String> initParameters;
- private Map<String, Object> attributes;
+ private MockServletContext servletContext;
- public MockPortletContext() {
- initParameters = new HashMap<String, String>();
- initParameters.put(INIT_PARAMETER, PORTLET_INIT_VALUE);
- attributes = new HashMap<String, Object>();
+ public MockPortletContext(MockServletContext sc) {
+ servletContext = sc;
}
/* (non-Javadoc)
* @see javax.portlet.PortletContext#getAttribute(java.lang.String)
*/
public Object getAttribute(String arg0) {
- return attributes.get(arg0);
+ return servletContext.getAttribute(arg0);
}
/* (non-Javadoc)
* @see javax.portlet.PortletContext#getAttributeNames()
*/
public Enumeration getAttributeNames() {
- return Collections.enumeration(attributes.keySet());
+ return servletContext.getAttributeNames();
}
/* (non-Javadoc)
* @see javax.portlet.PortletContext#getInitParameter(java.lang.String)
*/
public String getInitParameter(String arg0) {
- return initParameters.get(arg0);
+ return servletContext.getInitParameter(arg0);
}
/* (non-Javadoc)
* @see javax.portlet.PortletContext#getInitParameterNames()
*/
public Enumeration getInitParameterNames() {
- return Collections.enumeration(initParameters.keySet());
+ return servletContext.getInitParameterNames();
}
/* (non-Javadoc)
@@ -72,8 +71,8 @@
* @see javax.portlet.PortletContext#getMimeType(java.lang.String)
*/
public String getMimeType(String arg0) {
- // TODO Auto-generated method stub
- return null;
+ // TODO Auto-generated method stub
+ return servletContext.getMimeType(arg0);
}
/* (non-Javadoc)
@@ -97,7 +96,7 @@
*/
public String getPortletContextName() {
// TODO Auto-generated method stub
- return null;
+ return "testPortlet";
}
/* (non-Javadoc)
@@ -105,7 +104,7 @@
*/
public String getRealPath(String arg0) {
// TODO Auto-generated method stub
- return null;
+ return servletContext.getRealPath(arg0);
}
/* (non-Javadoc)
@@ -121,7 +120,7 @@
*/
public URL getResource(String arg0) throws MalformedURLException {
// TODO Auto-generated method stub
- return null;
+ return servletContext.getResource(arg0);
}
/* (non-Javadoc)
@@ -129,7 +128,7 @@
*/
public InputStream getResourceAsStream(String arg0) {
// TODO Auto-generated method stub
- return null;
+ return servletContext.getResourceAsStream(arg0);
}
/* (non-Javadoc)
@@ -137,7 +136,7 @@
*/
public Set getResourcePaths(String arg0) {
// TODO Auto-generated method stub
- return null;
+ return servletContext.getResourcePaths(arg0);
}
/* (non-Javadoc)
@@ -145,7 +144,7 @@
*/
public String getServerInfo() {
// TODO Auto-generated method stub
- return null;
+ return servletContext.getServerInfo();
}
/* (non-Javadoc)
@@ -153,6 +152,7 @@
*/
public void log(String arg0) {
// TODO Auto-generated method stub
+ servletContext.log(arg0);
}
/* (non-Javadoc)
@@ -160,23 +160,24 @@
*/
public void log(String arg0, Throwable arg1) {
// TODO Auto-generated method stub
+ servletContext.log(arg0, arg1);
}
/* (non-Javadoc)
* @see javax.portlet.PortletContext#removeAttribute(java.lang.String)
*/
public void removeAttribute(String arg0) {
- attributes.remove(arg0);
+ servletContext.removeAttribute(arg0);
}
/* (non-Javadoc)
* @see javax.portlet.PortletContext#setAttribute(java.lang.String, java.lang.Object)
*/
public void setAttribute(String arg0, Object arg1) {
- attributes.put(arg0, arg1);
+ servletContext.setAttribute(arg0, arg1);
}
public void setInitParameter(String name, String value) {
- initParameters.put(name, value);
+ servletContext.addInitParameter(name, value);
}
}
Modified: trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockPortletRequest.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockPortletRequest.java 2008-01-16 01:30:07 UTC (rev 5403)
+++ trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockPortletRequest.java 2008-01-16 01:35:34 UTC (rev 5404)
@@ -11,6 +11,7 @@
import java.util.Locale;
import java.util.Map;
import javax.portlet.PortalContext;
+import javax.portlet.PortletContext;
import javax.portlet.PortletMode;
import javax.portlet.PortletPreferences;
import javax.portlet.PortletRequest;
@@ -32,8 +33,10 @@
public Map attributes = new HashMap();
public PortletMode mode = PortletMode.VIEW;
public WindowState windowState = WindowState.NORMAL;
+ public MockPortletSession portletSession = null;
+ private PortletContext portletContext;
- public MockPortletRequest() {
+ public MockPortletRequest(PortletContext portletContext) {
parameters.put(PARAMETER, new String[]{PARAMETER_VALUE1,PARAMETER_VALUE2});
}
/* (non-Javadoc)
@@ -139,15 +142,17 @@
*/
public PortletSession getPortletSession() {
// TODO Auto-generated method stub
- return null;
+ return getPortletSession(true);
}
/* (non-Javadoc)
* @see javax.portlet.PortletRequest#getPortletSession(boolean)
*/
public PortletSession getPortletSession(boolean arg0) {
- // TODO Auto-generated method stub
- return null;
+ if(arg0 && null == portletSession){
+ portletSession = new MockPortletSession(portletContext);
+ }
+ return portletSession;
}
/* (non-Javadoc)
Added: trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockPortletSession.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockPortletSession.java (rev 0)
+++ trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockPortletSession.java 2008-01-16 01:35:34 UTC (rev 5404)
@@ -0,0 +1,168 @@
+/**
+ *
+ */
+package org.ajax4jsf.portlet;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.portlet.PortletContext;
+import javax.portlet.PortletSession;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class MockPortletSession implements PortletSession {
+
+ private static final String ID = "foobar";
+
+ private Map<String, Object> portletScopeAttributes;
+
+ private Map<String, Object> appScopeAttributes;
+
+ private long created;
+
+ private PortletContext portletContext;
+
+ private int maxInactive = 0;
+
+ public MockPortletSession(PortletContext pc) {
+ portletContext = pc;
+ portletScopeAttributes = new HashMap<String, Object>();
+ appScopeAttributes = new HashMap<String, Object>();
+ created = System.currentTimeMillis();
+ }
+
+ private Map<String,Object> getAttributesMap(int scope) {
+ return scope == PORTLET_SCOPE?portletScopeAttributes:appScopeAttributes;
+ }
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#getAttribute(java.lang.String)
+ */
+ public Object getAttribute(String arg0) {
+ // TODO Auto-generated method stub
+ return getAttribute(arg0, PORTLET_SCOPE);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#getAttribute(java.lang.String, int)
+ */
+ public Object getAttribute(String arg0, int arg1) {
+ return getAttributesMap(arg1).get(arg0);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#getAttributeNames()
+ */
+ public Enumeration getAttributeNames() {
+ // TODO Auto-generated method stub
+ return getAttributeNames(PORTLET_SCOPE);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#getAttributeNames(int)
+ */
+ public Enumeration getAttributeNames(int arg0) {
+ // TODO Auto-generated method stub
+ return Collections.enumeration(getAttributesMap(arg0).keySet());
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#getCreationTime()
+ */
+ public long getCreationTime() {
+ // TODO Auto-generated method stub
+ return created;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#getId()
+ */
+ public String getId() {
+ // TODO Auto-generated method stub
+ return ID;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#getLastAccessedTime()
+ */
+ public long getLastAccessedTime() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#getMaxInactiveInterval()
+ */
+ public int getMaxInactiveInterval() {
+ // TODO Auto-generated method stub
+ return maxInactive;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#getPortletContext()
+ */
+ public PortletContext getPortletContext() {
+ // TODO Auto-generated method stub
+ return portletContext;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#invalidate()
+ */
+ public void invalidate() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#isNew()
+ */
+ public boolean isNew() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#removeAttribute(java.lang.String)
+ */
+ public void removeAttribute(String arg0) {
+ removeAttribute(arg0, PORTLET_SCOPE);
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#removeAttribute(java.lang.String, int)
+ */
+ public void removeAttribute(String arg0, int arg1) {
+ getAttributesMap(arg1).remove(arg0);
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#setAttribute(java.lang.String, java.lang.Object)
+ */
+ public void setAttribute(String arg0, Object arg1) {
+ setAttribute(arg0, arg1, PORTLET_SCOPE);
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#setAttribute(java.lang.String, java.lang.Object, int)
+ */
+ public void setAttribute(String arg0, Object arg1, int arg2) {
+ getAttributesMap(arg2).put(arg0, arg1);
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.portlet.PortletSession#setMaxInactiveInterval(int)
+ */
+ public void setMaxInactiveInterval(int arg0) {
+ maxInactive = arg0;
+ }
+
+}
Property changes on: trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockPortletSession.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Modified: trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockRenderRequest.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockRenderRequest.java 2008-01-16 01:30:07 UTC (rev 5403)
+++ trunk/extensions/portletbridge/portletbridge-api/src/test/java/org/ajax4jsf/portlet/MockRenderRequest.java 2008-01-16 01:35:34 UTC (rev 5404)
@@ -3,6 +3,7 @@
*/
package org.ajax4jsf.portlet;
+import javax.portlet.PortletContext;
import javax.portlet.RenderRequest;
/**
@@ -11,4 +12,9 @@
*/
public class MockRenderRequest extends MockPortletRequest implements
RenderRequest {
+
+ public MockRenderRequest(PortletContext portletContext) {
+ super(portletContext);
+ // TODO Auto-generated constructor stub
+ }
}
Modified: trunk/extensions/portletbridge/portletbridge-impl/pom.xml
===================================================================
--- trunk/extensions/portletbridge/portletbridge-impl/pom.xml 2008-01-16 01:30:07 UTC (rev 5403)
+++ trunk/extensions/portletbridge/portletbridge-impl/pom.xml 2008-01-16 01:35:34 UTC (rev 5404)
@@ -44,6 +44,32 @@
<optional>true</optional>
</dependency>
<dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-commons-annotations</artifactId>
+ <version>3.3.0.ga</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <version>3.2.0.ga</version>
+ <optional>true</optional>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.0.1B</version>
Added: trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/seam/SeamPhaseListener.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/seam/SeamPhaseListener.java (rev 0)
+++ trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/seam/SeamPhaseListener.java 2008-01-16 01:35:34 UTC (rev 5404)
@@ -0,0 +1,608 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.ajax4jsf.portlet.seam;
+
+import static javax.faces.event.PhaseId.ANY_PHASE;
+import static javax.faces.event.PhaseId.INVOKE_APPLICATION;
+import static javax.faces.event.PhaseId.PROCESS_VALIDATIONS;
+import static javax.faces.event.PhaseId.RENDER_RESPONSE;
+import static javax.faces.event.PhaseId.RESTORE_VIEW;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+import org.jboss.seam.Seam;
+import org.jboss.seam.contexts.Context;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.contexts.FacesLifecycle;
+import org.jboss.seam.core.ConversationList;
+import org.jboss.seam.core.ConversationPropagation;
+import org.jboss.seam.core.ConversationStack;
+import org.jboss.seam.core.Events;
+import org.jboss.seam.core.Init;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.exception.Exceptions;
+import org.jboss.seam.faces.FacesManager;
+import org.jboss.seam.faces.FacesMessages;
+import org.jboss.seam.faces.FacesPage;
+import org.jboss.seam.faces.Switcher;
+import org.jboss.seam.faces.Validation;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.navigation.Pages;
+import org.jboss.seam.pageflow.Pageflow;
+import org.jboss.seam.persistence.PersistenceContexts;
+import org.jboss.seam.transaction.Transaction;
+import org.jboss.seam.util.Reflections;
+
+/**
+ * Manages the Seam contexts associated with a JSF request
+ * throughout the lifecycle of the request. Performs
+ * transaction demarcation when Seam transaction management
+ * is enabled. Hacks the JSF lifecyle to provide page
+ * actions and page parameters.
+ *
+ * @author Gavin King
+ */
+public class SeamPhaseListener implements PhaseListener
+{
+ private static final long serialVersionUID = -9127555729455066493L;
+
+ private static final LogProvider log = Logging.getLogProvider(SeamPhaseListener.class);
+
+ private static boolean exists = false;
+
+ private static final Method SET_RENDER_PARAMETER;
+ private static final Class ACTION_RESPONSE;
+ private static final Class PORTLET_REQUEST;
+
+ static
+ {
+ Method method = null;
+ Class actionResponseClass = null;
+ Class portletRequestClass = null;
+ try
+ {
+ Class[] parameterTypes = { String.class, String.class };
+ actionResponseClass = Class.forName("javax.portlet.ActionResponse");
+ portletRequestClass = Class.forName("javax.portlet.PortletRequest");
+ method = actionResponseClass.getMethod("setRenderParameter", parameterTypes);
+ }
+ catch (Exception e) {}
+ SET_RENDER_PARAMETER = method;
+ ACTION_RESPONSE = actionResponseClass;
+ PORTLET_REQUEST = portletRequestClass;
+ }
+
+ public SeamPhaseListener()
+ {
+ if (exists)
+ {
+ log.warn("There should only be one Seam phase listener per application");
+ }
+ exists=true;
+ }
+
+ public PhaseId getPhaseId()
+ {
+ return ANY_PHASE;
+ }
+
+ public void beforePhase(PhaseEvent event)
+ {
+ log.trace( "before phase: " + event.getPhaseId() );
+
+ FacesLifecycle.setPhaseId( event.getPhaseId() );
+
+ try
+ {
+ if ( isPortletRequest(event) )
+ {
+ beforePortletPhase(event);
+ }
+ else
+ {
+ beforeServletPhase(event);
+ }
+ raiseEventsBeforePhase(event);
+ }
+ catch (Exception e)
+ {
+ log.error("uncaught exception", e);
+ try
+ {
+ Exceptions.instance().handle(e);
+ }
+ catch (Exception ehe)
+ {
+ log.error("swallowing exception", e);
+ }
+ }
+
+ }
+
+ private void beforeServletPhase(PhaseEvent event)
+ {
+ if ( event.getPhaseId() == RESTORE_VIEW )
+ {
+ beforeRestoreView( event.getFacesContext() );
+ }
+
+ handleTransactionsBeforePhase(event);
+
+ if ( event.getPhaseId() == RENDER_RESPONSE )
+ {
+ beforeRenderResponse( event.getFacesContext() );
+ }
+
+ }
+
+ private void beforePortletPhase(PhaseEvent event)
+ {
+
+ FacesContext facesContext = event.getFacesContext();
+
+ if ( event.getPhaseId() == RESTORE_VIEW || event.getPhaseId() == RENDER_RESPONSE )
+ {
+ beforeRestoreView(facesContext);
+ }
+
+ //delegate to subclass:
+ handleTransactionsBeforePhase(event);
+
+ if ( event.getPhaseId() == RENDER_RESPONSE )
+ {
+ afterRestoreView(facesContext);
+ beforeRenderResponse( event.getFacesContext() );
+ }
+ }
+
+ public void afterPhase(PhaseEvent event)
+ {
+ log.trace( "after phase: " + event.getPhaseId() );
+
+ try
+ {
+ raiseEventsAfterPhase(event);
+ if ( isPortletRequest(event) )
+ {
+ afterPortletPhase(event);
+ }
+ else
+ {
+ afterServletPhase(event);
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("uncaught exception", e);
+ try
+ {
+ Exceptions.instance().handle(e);
+ // A redirect occurred inside the error handler, and we are in after
+ // phase, so we need to clean up now as there are no more after
+ // phases to be run
+ if ( event.getFacesContext().getResponseComplete() )
+ {
+ afterResponseComplete(event.getFacesContext());
+ }
+ }
+ catch (Exception ehe)
+ {
+ log.error("swallowing exception", e);
+ }
+ }
+
+ FacesLifecycle.clearPhaseId();
+
+ }
+
+ private void afterServletPhase(PhaseEvent event)
+ {
+
+ FacesContext facesContext = event.getFacesContext();
+
+ if ( event.getPhaseId() == RESTORE_VIEW )
+ {
+ afterRestoreView(facesContext);
+ }
+ else if ( event.getPhaseId() == INVOKE_APPLICATION )
+ {
+ afterInvokeApplication();
+ }
+ else if ( event.getPhaseId() == PROCESS_VALIDATIONS )
+ {
+ afterProcessValidations(facesContext);
+ }
+
+ //has to happen after, since restoreAnyConversationContext()
+ //can add messages
+ FacesMessages.afterPhase();
+
+ handleTransactionsAfterPhase(event);
+
+ if ( event.getPhaseId() == RENDER_RESPONSE )
+ {
+ afterRenderResponse(facesContext);
+ }
+ else if ( facesContext.getResponseComplete() )
+ {
+ afterResponseComplete(facesContext);
+ }
+ }
+
+ private void afterPortletPhase(PhaseEvent event)
+ {
+ FacesContext facesContext = event.getFacesContext();
+
+ if ( event.getPhaseId() == RESTORE_VIEW )
+ {
+ afterRestoreView(facesContext);
+ }
+ else if ( event.getPhaseId() == INVOKE_APPLICATION )
+ {
+ afterInvokeApplication();
+ }
+ else if ( event.getPhaseId() == PROCESS_VALIDATIONS )
+ {
+ afterProcessValidations(facesContext);
+ }
+
+ FacesMessages.afterPhase();
+
+ //delegate to subclass:
+ handleTransactionsAfterPhase(event);
+
+ if ( event.getPhaseId() == RENDER_RESPONSE )
+ {
+ //writeConversationIdToResponse( facesContext.getExternalContext().getResponse() );
+ afterRenderResponse(facesContext);
+ }
+ else if ( event.getPhaseId() == INVOKE_APPLICATION || facesContext.getRenderResponse() || facesContext.getResponseComplete() )
+ {
+ Manager manager = Manager.instance();
+ manager.beforeRedirect();
+ if ( manager.isLongRunningConversation() )
+ {
+ setPortletRenderParameter(
+ facesContext.getExternalContext().getResponse(),
+ manager.getConversationIdParameter(),
+ manager.getCurrentConversationId()
+ );
+ }
+ afterResponseComplete(facesContext);
+ }
+
+ }
+
+ private static void setPortletRenderParameter(Object response, String conversationIdParameter, String conversationId)
+ {
+ if ( ACTION_RESPONSE.isInstance(response) )
+ {
+ Reflections.invokeAndWrap(SET_RENDER_PARAMETER, response, conversationIdParameter, conversationId);
+ }
+ }
+
+ private static boolean isPortletRequest(PhaseEvent event)
+ {
+ return PORTLET_REQUEST!=null &&
+ PORTLET_REQUEST.isInstance( event.getFacesContext().getExternalContext().getRequest() );
+ }
+
+ public void handleTransactionsBeforePhase(PhaseEvent event)
+ {
+ if ( Init.instance().isTransactionManagementEnabled() )
+ {
+ PhaseId phaseId = event.getPhaseId();
+ boolean beginTran = phaseId == PhaseId.RENDER_RESPONSE ||
+ phaseId == ( Transaction.instance().isConversationContextRequired() ? PhaseId.APPLY_REQUEST_VALUES : PhaseId.RESTORE_VIEW );
+ //( phaseId == PhaseId.RENDER_RESPONSE && !Init.instance().isClientSideConversations() );
+
+ if (beginTran)
+ {
+ begin(phaseId);
+ }
+ }
+ }
+
+ public void handleTransactionsAfterPhase(PhaseEvent event)
+ {
+ if ( Init.instance().isTransactionManagementEnabled() )
+ {
+ PhaseId phaseId = event.getPhaseId();
+ boolean commitTran = phaseId == PhaseId.INVOKE_APPLICATION ||
+ event.getFacesContext().getRenderResponse() || //TODO: no need to commit the tx if we failed to restore the view
+ event.getFacesContext().getResponseComplete() ||
+ phaseId == PhaseId.RENDER_RESPONSE;
+ //( phaseId == PhaseId.RENDER_RESPONSE && !Init.instance().isClientSideConversations() );
+
+ if (commitTran)
+ {
+ commitOrRollback(phaseId); //we commit before destroying contexts, cos the contexts have the PC in them
+ }
+ }
+ }
+
+ protected void handleTransactionsAfterPageActions(FacesContext facesContext)
+ {
+ if ( Init.instance().isTransactionManagementEnabled() )
+ {
+ commitOrRollback(PhaseId.INVOKE_APPLICATION);
+ if ( !facesContext.getResponseComplete() )
+ {
+ begin(PhaseId.INVOKE_APPLICATION);
+ }
+ }
+ }
+
+ protected void afterInvokeApplication()
+ {
+ if ( Init.instance().isTransactionManagementEnabled() )
+ {
+ addTransactionFailedMessage();
+ }
+ }
+
+ protected void afterProcessValidations(FacesContext facesContext)
+ {
+ Validation.instance().afterProcessValidations(facesContext);
+ }
+
+ /**
+ * Set up the Seam contexts, except for the conversation
+ * context
+ */
+ protected void beforeRestoreView(FacesContext facesContext)
+ {
+ FacesLifecycle.beginRequest( facesContext.getExternalContext() );
+ }
+
+ /**
+ * Restore the page and conversation contexts during a JSF request
+ */
+ protected void afterRestoreView(FacesContext facesContext)
+ {
+ FacesLifecycle.resumePage();
+ Map parameters = facesContext.getExternalContext().getRequestParameterMap();
+ ConversationPropagation.instance().restoreConversationId(parameters);
+ boolean conversationFound = Manager.instance().restoreConversation();
+ FacesLifecycle.resumeConversation( facesContext.getExternalContext() );
+ postRestorePage(facesContext, parameters, conversationFound);
+ }
+
+ public void raiseEventsBeforePhase(PhaseEvent event)
+ {
+ if ( Contexts.isApplicationContextActive() )
+ {
+ Events.instance().raiseEvent("org.jboss.seam.beforePhase", event);
+ }
+
+ /*if ( Contexts.isConversationContextActive() && Init.instance().isJbpmInstalled() && Pageflow.instance().isInProcess() )
+ {
+ String name;
+ PhaseId phaseId = event.getPhaseId();
+ if ( phaseId == PhaseId.PROCESS_VALIDATIONS )
+ {
+ name = "process-validations";
+ }
+ else if ( phaseId == PhaseId.UPDATE_MODEL_VALUES )
+ {
+ name = "update-model-values";
+ }
+ else if ( phaseId == PhaseId.INVOKE_APPLICATION )
+ {
+ name = "invoke-application";
+ }
+ else if ( phaseId == PhaseId.RENDER_RESPONSE )
+ {
+ name = "render-response";
+ }
+ else
+ {
+ return;
+ }
+ Pageflow.instance().processEvents(name);
+ }*/
+ }
+
+ public void raiseEventsAfterPhase(PhaseEvent event)
+ {
+ if ( Contexts.isApplicationContextActive() )
+ {
+ Events.instance().raiseEvent("org.jboss.seam.afterPhase", event);
+ }
+ }
+
+ /**
+ * Add a faces message when Seam-managed transactions fail.
+ */
+ protected void addTransactionFailedMessage()
+ {
+ try
+ {
+ if ( Transaction.instance().isRolledBackOrMarkedRollback() )
+ {
+ FacesMessages.instance().addFromResourceBundleOrDefault(
+ FacesMessage.SEVERITY_WARN,
+ "org.jboss.seam.TransactionFailed",
+ "Transaction failed"
+ );
+ }
+ }
+ catch (Exception e) {} //swallow silently, not important
+ }
+
+ protected void beforeRenderResponse(FacesContext facesContext)
+ {
+
+ if ( Contexts.isPageContextActive() )
+ {
+ Context pageContext = Contexts.getPageContext();
+ //after every time that the view may have changed,
+ //we need to flush the page context, since the
+ //attribute map is being discarder
+ pageContext.flush();
+ //force refresh of the conversation lists (they are kept in PAGE context)
+ pageContext.remove(Seam.getComponentName(Switcher.class));
+ pageContext.remove("org.jboss.seam.core.conversationList");
+ pageContext.remove("org.jboss.seam.core.conversationStack");
+ }
+
+ preRenderPage(facesContext);
+
+ if ( facesContext.getResponseComplete() )
+ {
+ //workaround for a bug in MyFaces prior to 1.1.3
+ if ( Init.instance().isMyFacesLifecycleBug() )
+ {
+ FacesLifecycle.endRequest( facesContext.getExternalContext() );
+ }
+ }
+ else //if the page actions did not call responseComplete()
+ {
+ FacesMessages.instance().beforeRenderResponse();
+ //do this both before and after render, since conversations
+ //and pageflows can begin during render
+ FacesManager.instance().prepareBackswitch(facesContext);
+ }
+
+ FacesPage.instance().storeConversation();
+ FacesPage.instance().storePageflow();
+
+ PersistenceContexts persistenceContexts = PersistenceContexts.instance();
+ if (persistenceContexts != null)
+ {
+ persistenceContexts.beforeRender();
+ }
+ }
+
+ protected void afterRenderResponse(FacesContext facesContext)
+ {
+ //do this both before and after render, since conversations
+ //and pageflows can begin during render
+ FacesManager.instance().prepareBackswitch(facesContext);
+
+ PersistenceContexts persistenceContexts = PersistenceContexts.instance();
+ if (persistenceContexts != null)
+ {
+ persistenceContexts.afterRender();
+ }
+
+ ExternalContext externalContext = facesContext.getExternalContext();
+ Manager.instance().endRequest( externalContext.getSessionMap() );
+ FacesLifecycle.endRequest(externalContext);
+ }
+
+ protected void afterResponseComplete(FacesContext facesContext)
+ {
+ //responseComplete() was called by one of the other phases,
+ //so we will never get to the RENDER_RESPONSE phase
+ //Note: we can't call Manager.instance().beforeRedirect() here,
+ //since a redirect is not the only reason for a responseComplete
+ ExternalContext externalContext = facesContext.getExternalContext();
+ Manager.instance().endRequest( externalContext.getSessionMap() );
+ FacesLifecycle.endRequest( facesContext.getExternalContext() );
+ }
+
+ private void postRestorePage(FacesContext facesContext, Map parameters, boolean conversationFound)
+ {
+ if ( !Pages.isDebugPage() )
+ {
+ // Only redirect to no-conversation-view if a login redirect isn't required
+ if (!conversationFound && !Pages.instance().isLoginRedirectRequired(facesContext))
+ {
+ Pages.instance().redirectToNoConversationView();
+ }
+
+ Manager.instance().handleConversationPropagation(parameters);
+
+ if ( Init.instance().isJbpmInstalled() && !isExceptionHandlerRedirect() )
+ {
+ Pageflow.instance().validatePageflow(facesContext);
+ }
+
+ Pages.instance().postRestore(facesContext);
+ }
+ }
+
+ private boolean preRenderPage(FacesContext facesContext)
+ {
+ if ( Pages.isDebugPage() )
+ {
+ return false;
+ }
+ else
+ {
+ FacesLifecycle.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ boolean actionsWereCalled = false;
+ try
+ {
+ actionsWereCalled = Pages.instance().preRender(facesContext);
+ return actionsWereCalled;
+ }
+ finally
+ {
+ FacesLifecycle.setPhaseId(PhaseId.RENDER_RESPONSE);
+ if (actionsWereCalled)
+ {
+ FacesMessages.afterPhase();
+ handleTransactionsAfterPageActions(facesContext); //TODO: does it really belong in the finally?
+ }
+ }
+ }
+ }
+
+ private boolean isExceptionHandlerRedirect()
+ {
+ return Contexts.getConversationContext().isSet("org.jboss.seam.handledException");
+ }
+
+ void begin(PhaseId phaseId)
+ {
+ try
+ {
+ if ( !Transaction.instance().isActiveOrMarkedRollback() )
+ {
+ log.debug("beginning transaction prior to phase: " + phaseId);
+ Transaction.instance().begin();
+ }
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Could not start transaction", e);
+ }
+ }
+
+ void commitOrRollback(PhaseId phaseId)
+ {
+ try
+ {
+ if ( Transaction.instance().isActive() )
+ {
+ log.debug("committing transaction after phase: " + phaseId);
+ Transaction.instance().commit();
+ }
+ else if ( Transaction.instance().isRolledBackOrMarkedRollback() )
+ {
+ log.debug("rolling back transaction after phase: " + phaseId);
+ Transaction.instance().rollback();
+ }
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Could not commit transaction", e);
+ }
+ }
+
+}
Property changes on: trunk/extensions/portletbridge/portletbridge-impl/src/main/java/org/ajax4jsf/portlet/seam/SeamPhaseListener.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Modified: trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/context/ContextFactoryTest.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/context/ContextFactoryTest.java 2008-01-16 01:30:07 UTC (rev 5403)
+++ trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/context/ContextFactoryTest.java 2008-01-16 01:35:34 UTC (rev 5404)
@@ -60,8 +60,8 @@
*/
public void testGetFacesContextPortlet() {
FacesContextFactoryImpl factory = new FacesContextFactoryImpl(facesContextFactory);
- MockPortletContext portletContext = new MockPortletContext();
- MockActionRequest portletRequest = new MockActionRequest();
+ MockPortletContext portletContext = new MockPortletContext(servletContext);
+ MockActionRequest portletRequest = new MockActionRequest(portletContext);
MockActionResponse portletResponse = new MockActionResponse();
FacesContext context = factory.getFacesContext(portletContext,
portletRequest, portletResponse, lifecycle);
Modified: trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/context/PortletExternalContextTest.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/context/PortletExternalContextTest.java 2008-01-16 01:30:07 UTC (rev 5403)
+++ trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/context/PortletExternalContextTest.java 2008-01-16 01:35:34 UTC (rev 5404)
@@ -34,8 +34,8 @@
*/
public void setUp() throws Exception {
super.setUp();
- portletContext=new MockPortletContext();
- portletRequest = new MockActionRequest();
+ portletContext=new MockPortletContext(servletContext);
+ portletRequest = new MockActionRequest(portletContext);
portletResponse = new MockActionResponse();
portletContextImpl = new PortletExternalContextImpl(portletContext,portletRequest,portletResponse);
portalFacesContext = new FacesContextImpl(portletContextImpl,lifecycle);
Added: trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/AbstractSeamPortletTestCase.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/AbstractSeamPortletTestCase.java (rev 0)
+++ trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/AbstractSeamPortletTestCase.java 2008-01-16 01:35:34 UTC (rev 5404)
@@ -0,0 +1,87 @@
+/**
+ *
+ */
+package org.ajax4jsf.portlet.seam;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.portlet.faces.Bridge;
+
+import org.ajax4jsf.portlet.AbstractAjax4jsfPortletTestCase;
+import org.ajax4jsf.portlet.AjaxPortletBridge;
+import org.jboss.seam.Component;
+import org.jboss.seam.Seam;
+import org.jboss.seam.contexts.ApplicationContext;
+import org.jboss.seam.contexts.Context;
+import org.jboss.seam.contexts.TestLifecycle;
+import org.jboss.seam.core.Conversation;
+import org.jboss.seam.core.ConversationEntries;
+import org.jboss.seam.core.ConversationPropagation;
+import org.jboss.seam.core.Events;
+import org.jboss.seam.core.Init;
+import org.jboss.seam.core.ResourceLoader;
+import org.jboss.seam.faces.FacesManager;
+import org.jboss.seam.faces.FacesMessages;
+import org.jboss.seam.faces.FacesPage;
+import org.jboss.seam.faces.Validation;
+import org.jboss.seam.navigation.Pages;
+import org.jboss.seam.web.Session;
+
+/**
+ * @author asmirnov
+ *
+ */
+public abstract class AbstractSeamPortletTestCase extends
+ AbstractAjax4jsfPortletTestCase {
+
+ protected Bridge portletBridge;
+
+ public AbstractSeamPortletTestCase(String name) {
+ super(name);
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ ExternalContext externalContext = setupRequest();
+ facesContext.setExternalContext(externalContext);
+ portletBridge = new AjaxPortletBridge();
+ portletBridge.init(portletConfig);
+ Context appContext = new ApplicationContext( externalContext.getApplicationMap() );
+ installComponents(appContext);
+ }
+
+ protected abstract ExternalContext setupRequest();
+
+ @Override
+ public void tearDown() throws Exception {
+ TestLifecycle.endTest();
+ super.tearDown();
+ portletBridge = null;
+ }
+
+ protected void installComponents(Context appContext)
+ {
+ Init init = new Init();
+ init.setTransactionManagementEnabled(true);
+ appContext.set( Seam.getComponentName(Init.class), init );
+ installComponent(appContext, MockUserTransaction.class);
+ installComponent(appContext, FacesManager.class);
+ installComponent(appContext, ConversationEntries.class);
+ installComponent(appContext, FacesPage.class);
+ installComponent(appContext, Conversation.class);
+ installComponent(appContext, FacesMessages.class);
+ installComponent(appContext, Pages.class);
+ installComponent(appContext, Events.class);
+ installComponent(appContext, Validation.class);
+ installComponent(appContext, Session.class);
+ installComponent(appContext, ConversationPropagation.class);
+ installComponent(appContext, ResourceLoader.class);
+ }
+
+ protected void installComponent(Context appContext, Class clazz)
+ {
+ appContext.set( Seam.getComponentName(clazz) + ".component", new Component(clazz) );
+ }
+
+}
Property changes on: trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/AbstractSeamPortletTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Added: trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/MockUserTransaction.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/MockUserTransaction.java (rev 0)
+++ trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/MockUserTransaction.java 2008-01-16 01:35:34 UTC (rev 5404)
@@ -0,0 +1,115 @@
+/**
+ *
+ */
+package org.ajax4jsf.portlet.seam;
+
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
+
+import javax.persistence.EntityManager;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+import org.jboss.seam.transaction.AbstractUserTransaction;
+
+/**
+ * @author asmirnov
+ *
+ */
+@Name("org.jboss.seam.transaction.transaction")
+(a)Scope(ScopeType.EVENT)
+@Install(value = false, precedence = FRAMEWORK)
+@BypassInterceptors
+public class MockUserTransaction extends AbstractUserTransaction {
+
+ private static final Log _log = LogFactory.getLog(MockUserTransaction.class);
+
+ private int status = Status.STATUS_NO_TRANSACTION;
+
+ /* (non-Javadoc)
+ * @see org.jboss.seam.transaction.AbstractUserTransaction#registerSynchronization(javax.transaction.Synchronization)
+ */
+ @Override
+ public void registerSynchronization(Synchronization arg0) {
+ _log.info("registerSyncronisation");
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see javax.transaction.UserTransaction#begin()
+ */
+ public void begin() throws NotSupportedException, SystemException {
+ _log.info("Transaction begin");
+ if(status != Status.STATUS_NO_TRANSACTION){
+ throw new SystemException("Transaction already active");
+ }
+ status = Status.STATUS_ACTIVE;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.transaction.UserTransaction#commit()
+ */
+ public void commit() throws RollbackException, HeuristicMixedException,
+ HeuristicRollbackException, SecurityException,
+ IllegalStateException, SystemException {
+ _log.info("Transaction commit");
+ if(status != Status.STATUS_ACTIVE){
+ throw new SystemException("Transaction not active");
+ }
+ status = Status.STATUS_COMMITTED;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.transaction.UserTransaction#getStatus()
+ */
+ public int getStatus() throws SystemException {
+ // TODO Auto-generated method stub
+ return status;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.transaction.UserTransaction#rollback()
+ */
+ public void rollback() throws IllegalStateException, SecurityException,
+ SystemException {
+ _log.info("transaction rollback");
+ if(status != Status.STATUS_ACTIVE){
+ throw new SystemException("Transaction not active");
+ }
+ status = Status.STATUS_ROLLEDBACK;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.transaction.UserTransaction#setRollbackOnly()
+ */
+ public void setRollbackOnly() throws IllegalStateException, SystemException {
+ _log.info("Transaction set to rollback only");
+ status = Status.STATUS_MARKED_ROLLBACK;
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.transaction.UserTransaction#setTransactionTimeout(int)
+ */
+ public void setTransactionTimeout(int arg0) throws SystemException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void enlist(EntityManager entityManager) throws SystemException {
+ _log.info("Transaction enlist");
+ // do nothing
+ }
+}
Property changes on: trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/MockUserTransaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Added: trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/PhaseListenerActionPhaseTest.java
===================================================================
--- trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/PhaseListenerActionPhaseTest.java (rev 0)
+++ trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/PhaseListenerActionPhaseTest.java 2008-01-16 01:35:34 UTC (rev 5404)
@@ -0,0 +1,75 @@
+/**
+ *
+ */
+package org.ajax4jsf.portlet.seam;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.portlet.faces.Bridge;
+
+import org.ajax4jsf.portlet.context.AbstractExternalContext;
+import org.ajax4jsf.portlet.context.PortletExternalContextImpl;
+import org.jboss.seam.contexts.Contexts;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class PhaseListenerActionPhaseTest extends AbstractSeamPortletTestCase {
+
+ private SeamPhaseListener phaseListener;
+ /**
+ * @param name
+ */
+ public PhaseListenerActionPhaseTest(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.portlet.seam.AbstractSeamPortletTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ phaseListener = new SeamPhaseListener();
+ lifecycle.addPhaseListener(phaseListener);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.portlet.seam.AbstractSeamPortletTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ phaseListener = null;
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.portlet.seam.SeamPhaseListener#beforePhase(javax.faces.event.PhaseEvent)}.
+ */
+ public void testBeforePhase() {
+ assertFalse(Contexts.isEventContextActive());
+ phaseListener.beforePhase(new PhaseEvent(facesContext,PhaseId.RESTORE_VIEW,lifecycle));
+ assertTrue(Contexts.isEventContextActive());
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.portlet.seam.SeamPhaseListener#afterPhase(javax.faces.event.PhaseEvent)}.
+ */
+ public void testAfterPhase() {
+ assertFalse(Contexts.isEventContextActive());
+ phaseListener.beforePhase(new PhaseEvent(facesContext,PhaseId.RESTORE_VIEW,lifecycle));
+ phaseListener.afterPhase(new PhaseEvent(facesContext,PhaseId.RESTORE_VIEW,lifecycle));
+ assertTrue(Contexts.isEventContextActive());
+ }
+
+ @Override
+ protected ExternalContext setupRequest() {
+ setupActionRequest();
+ request.setAttribute(Bridge.PORTLET_LIFECYCLE_PHASE, Bridge.PortletPhase.ActionPhase);
+ request.setAttribute(AbstractExternalContext.PORTLET_CONFIG_ATTRIBUTE,
+ portletConfig);
+
+ return new PortletExternalContextImpl(portletContext,actionRequest,actionResponse);
+ }
+
+}
Property changes on: trunk/extensions/portletbridge/portletbridge-impl/src/test/java/org/ajax4jsf/portlet/seam/PhaseListenerActionPhaseTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Modified: trunk/samples/scrollableDataTableDemo/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/samples/scrollableDataTableDemo/src/main/webapp/WEB-INF/web.xml 2008-01-16 01:30:07 UTC (rev 5403)
+++ trunk/samples/scrollableDataTableDemo/src/main/webapp/WEB-INF/web.xml 2008-01-16 01:35:34 UTC (rev 5404)
@@ -36,7 +36,8 @@
<filter>
<display-name>Ajax4jsf Filter</display-name>
<filter-name>ajax4jsf</filter-name>
- <filter-class>org.ajax4jsf.FastFilter</filter-class>
+ <filter-class>org.ajax4jsf.FastFilter</filter-class>
+ <init-param><param-name>enable-cache</param-name><param-value>false</param-value></init-param>
</filter>
<filter>
<display-name>Request Metrics</display-name>
Added: trunk/samples/seamPortletEar/seamBookingPortlet/src/main/java/org/ajax4jsf/portlet/seam/SeamPhaseListener.java
===================================================================
--- trunk/samples/seamPortletEar/seamBookingPortlet/src/main/java/org/ajax4jsf/portlet/seam/SeamPhaseListener.java (rev 0)
+++ trunk/samples/seamPortletEar/seamBookingPortlet/src/main/java/org/ajax4jsf/portlet/seam/SeamPhaseListener.java 2008-01-16 01:35:34 UTC (rev 5404)
@@ -0,0 +1,629 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.ajax4jsf.portlet.seam;
+
+import static javax.faces.event.PhaseId.ANY_PHASE;
+import static javax.faces.event.PhaseId.INVOKE_APPLICATION;
+import static javax.faces.event.PhaseId.PROCESS_VALIDATIONS;
+import static javax.faces.event.PhaseId.RENDER_RESPONSE;
+import static javax.faces.event.PhaseId.RESTORE_VIEW;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+import org.jboss.seam.Seam;
+import org.jboss.seam.contexts.Context;
+import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.contexts.FacesLifecycle;
+import org.jboss.seam.core.ConversationList;
+import org.jboss.seam.core.ConversationPropagation;
+import org.jboss.seam.core.ConversationStack;
+import org.jboss.seam.core.Events;
+import org.jboss.seam.core.Init;
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.exception.Exceptions;
+import org.jboss.seam.faces.FacesManager;
+import org.jboss.seam.faces.FacesMessages;
+import org.jboss.seam.faces.FacesPage;
+import org.jboss.seam.faces.Switcher;
+import org.jboss.seam.faces.Validation;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
+import org.jboss.seam.navigation.Pages;
+import org.jboss.seam.pageflow.Pageflow;
+import org.jboss.seam.persistence.PersistenceContexts;
+import org.jboss.seam.transaction.Transaction;
+import org.jboss.seam.util.Reflections;
+
+/**
+ * Manages the Seam contexts associated with a JSF request
+ * throughout the lifecycle of the request. Performs
+ * transaction demarcation when Seam transaction management
+ * is enabled. Hacks the JSF lifecyle to provide page
+ * actions and page parameters.
+ *
+ * @author Gavin King
+ */
+public class SeamPhaseListener implements PhaseListener
+{
+ public static final String JAVAX_PORTLET_FACES_PHASE = "javax.portlet.faces.phase";
+
+private static final long serialVersionUID = -9127555729455066493L;
+
+ private static final LogProvider log = Logging.getLogProvider(SeamPhaseListener.class);
+
+ private static boolean exists = false;
+
+ private static final Method SET_RENDER_PARAMETER;
+ private static final Class ACTION_RESPONSE;
+ private static final Class PORTLET_REQUEST;
+
+ static
+ {
+ Method method = null;
+ Class actionResponseClass = null;
+ Class portletRequestClass = null;
+ try
+ {
+ Class[] parameterTypes = { String.class, String.class };
+ actionResponseClass = Class.forName("javax.portlet.ActionResponse");
+ portletRequestClass = Class.forName("javax.portlet.PortletRequest");
+ method = actionResponseClass.getMethod("setRenderParameter", parameterTypes);
+ }
+ catch (Exception e) {}
+ SET_RENDER_PARAMETER = method;
+ ACTION_RESPONSE = actionResponseClass;
+ PORTLET_REQUEST = portletRequestClass;
+ }
+
+ public SeamPhaseListener()
+ {
+ if (exists)
+ {
+ log.warn("There should only be one Seam phase listener per application");
+ }
+ exists=true;
+ }
+
+ public PhaseId getPhaseId()
+ {
+ return ANY_PHASE;
+ }
+
+ public void beforePhase(PhaseEvent event)
+ {
+ log.trace( "before phase: " + event.getPhaseId() );
+
+ FacesLifecycle.setPhaseId( event.getPhaseId() );
+
+ try
+ {
+ if ( isPortletRequest(event) )
+ {
+ beforePortletPhase(event);
+ }
+ else
+ {
+ beforeServletPhase(event);
+ }
+ raiseEventsBeforePhase(event);
+ }
+ catch (Exception e)
+ {
+ log.error("uncaught exception", e);
+ try
+ {
+ Exceptions.instance().handle(e);
+ }
+ catch (Exception ehe)
+ {
+ log.error("swallowing exception", e);
+ }
+ }
+
+ }
+
+ private void beforeServletPhase(PhaseEvent event)
+ {
+ if ( event.getPhaseId() == RESTORE_VIEW )
+ {
+ beforeRestoreView( event.getFacesContext() );
+ }
+
+ handleTransactionsBeforePhase(event);
+
+ if ( event.getPhaseId() == RENDER_RESPONSE )
+ {
+ beforeRenderResponse( event.getFacesContext() );
+ }
+
+ }
+
+ private void beforePortletPhase(PhaseEvent event)
+ {
+ // Changed to compability with JSR-301 portlet bridhe
+ FacesContext facesContext = event.getFacesContext();
+
+ if ( event.getPhaseId() == RESTORE_VIEW /*|| event.getPhaseId() == RENDER_RESPONSE*/ )
+ {
+ beforeRestoreView(facesContext);
+ }
+
+ if (!Contexts.isApplicationContextActive()) {
+ beforeRestoreView(facesContext);
+ afterRestoreView(facesContext);
+ }
+
+ //delegate to subclass:
+ handleTransactionsBeforePhase(event);
+
+ if ( event.getPhaseId() == RENDER_RESPONSE )
+ {
+// afterRestoreView(facesContext);
+ beforeRenderResponse( event.getFacesContext() );
+ }
+ }
+
+ public void afterPhase(PhaseEvent event)
+ {
+ log.trace( "after phase: " + event.getPhaseId() );
+
+ try
+ {
+ raiseEventsAfterPhase(event);
+ if ( isPortletRequest(event) )
+ {
+ afterPortletPhase(event);
+ }
+ else
+ {
+ afterServletPhase(event);
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("uncaught exception", e);
+ try
+ {
+ Exceptions.instance().handle(e);
+ // A redirect occurred inside the error handler, and we are in after
+ // phase, so we need to clean up now as there are no more after
+ // phases to be run
+ if ( event.getFacesContext().getResponseComplete() )
+ {
+ afterResponseComplete(event.getFacesContext());
+ }
+ }
+ catch (Exception ehe)
+ {
+ log.error("swallowing exception", e);
+ }
+ }
+
+ FacesLifecycle.clearPhaseId();
+
+ }
+
+ private void afterServletPhase(PhaseEvent event)
+ {
+
+ FacesContext facesContext = event.getFacesContext();
+
+ if ( event.getPhaseId() == RESTORE_VIEW )
+ {
+ afterRestoreView(facesContext);
+ }
+ else if ( event.getPhaseId() == INVOKE_APPLICATION )
+ {
+ afterInvokeApplication();
+ }
+ else if ( event.getPhaseId() == PROCESS_VALIDATIONS )
+ {
+ afterProcessValidations(facesContext);
+ }
+
+ //has to happen after, since restoreAnyConversationContext()
+ //can add messages
+ FacesMessages.afterPhase();
+
+ handleTransactionsAfterPhase(event);
+
+ if ( event.getPhaseId() == RENDER_RESPONSE )
+ {
+ afterRenderResponse(facesContext);
+ }
+ else if ( facesContext.getResponseComplete() )
+ {
+ afterResponseComplete(facesContext);
+ }
+ }
+
+ private void afterPortletPhase(PhaseEvent event)
+ {
+ FacesContext facesContext = event.getFacesContext();
+
+ if ( event.getPhaseId() == RESTORE_VIEW )
+ {
+ afterRestoreView(facesContext);
+ }
+ else if ( event.getPhaseId() == INVOKE_APPLICATION )
+ {
+ afterInvokeApplication();
+ }
+ else if ( event.getPhaseId() == PROCESS_VALIDATIONS )
+ {
+ afterProcessValidations(facesContext);
+ }
+
+ FacesMessages.afterPhase();
+
+
+ Object bridgePhase = facesContext.getExternalContext().getRequestMap().get(JAVAX_PORTLET_FACES_PHASE);
+
+
+ if ( event.getPhaseId() == RENDER_RESPONSE )
+ {
+ //delegate to subclass:
+ handleTransactionsAfterPhase(event);
+ //writeConversationIdToResponse( facesContext.getExternalContext().getResponse() );
+ afterRenderResponse(facesContext);
+ }
+ else if ( (null == bridgePhase || "ActionPhase".equals(bridgePhase.toString())) && (event.getPhaseId() == INVOKE_APPLICATION || facesContext.getRenderResponse() || facesContext.getResponseComplete()) )
+ {
+ preRenderPage(facesContext, event.getPhaseId());
+ //delegate to subclass:
+ handleTransactionsAfterPhase(event);
+ Manager manager = Manager.instance();
+ manager.beforeRedirect();
+ if ( manager.isLongRunningConversation() )
+ {
+ setPortletRenderParameter(
+ facesContext.getExternalContext().getResponse(),
+ manager.getConversationIdParameter(),
+ manager.getCurrentConversationId()
+ );
+ }
+ afterResponseComplete(facesContext);
+ } else {
+ //delegate to subclass:
+ handleTransactionsAfterPhase(event);
+ }
+
+ }
+
+ private static void setPortletRenderParameter(Object response, String conversationIdParameter, String conversationId)
+ {
+ if ( ACTION_RESPONSE.isInstance(response) )
+ {
+ Reflections.invokeAndWrap(SET_RENDER_PARAMETER, response, conversationIdParameter, conversationId);
+ }
+ }
+
+ private static boolean isPortletRequest(PhaseEvent event)
+ {
+ return PORTLET_REQUEST!=null &&
+ PORTLET_REQUEST.isInstance( event.getFacesContext().getExternalContext().getRequest() );
+ }
+
+ public void handleTransactionsBeforePhase(PhaseEvent event)
+ {
+ if ( Init.instance().isTransactionManagementEnabled() )
+ {
+ PhaseId phaseId = event.getPhaseId();
+ boolean beginTran = phaseId == PhaseId.RENDER_RESPONSE ||
+ phaseId == ( Transaction.instance().isConversationContextRequired() ? PhaseId.APPLY_REQUEST_VALUES : PhaseId.RESTORE_VIEW );
+ //( phaseId == PhaseId.RENDER_RESPONSE && !Init.instance().isClientSideConversations() );
+
+ if (beginTran)
+ {
+ begin(phaseId);
+ }
+ }
+ }
+
+ public void handleTransactionsAfterPhase(PhaseEvent event)
+ {
+ if ( Init.instance().isTransactionManagementEnabled() )
+ {
+ PhaseId phaseId = event.getPhaseId();
+ boolean commitTran = phaseId == PhaseId.INVOKE_APPLICATION ||
+ event.getFacesContext().getRenderResponse() || //TODO: no need to commit the tx if we failed to restore the view
+ event.getFacesContext().getResponseComplete() ||
+ phaseId == PhaseId.RENDER_RESPONSE;
+ //( phaseId == PhaseId.RENDER_RESPONSE && !Init.instance().isClientSideConversations() );
+
+ if (commitTran)
+ {
+ commitOrRollback(phaseId); //we commit before destroying contexts, cos the contexts have the PC in them
+ }
+ }
+ }
+
+ protected void handleTransactionsAfterPageActions(FacesContext facesContext)
+ {
+ if ( Init.instance().isTransactionManagementEnabled() )
+ {
+ commitOrRollback(PhaseId.INVOKE_APPLICATION);
+ if ( !facesContext.getResponseComplete() )
+ {
+ begin(PhaseId.INVOKE_APPLICATION);
+ }
+ }
+ }
+
+ protected void afterInvokeApplication()
+ {
+ if ( Init.instance().isTransactionManagementEnabled() )
+ {
+ addTransactionFailedMessage();
+ }
+ }
+
+ protected void afterProcessValidations(FacesContext facesContext)
+ {
+ Validation.instance().afterProcessValidations(facesContext);
+ }
+
+ /**
+ * Set up the Seam contexts, except for the conversation
+ * context
+ */
+ protected void beforeRestoreView(FacesContext facesContext)
+ {
+ FacesLifecycle.beginRequest( facesContext.getExternalContext() );
+ }
+
+ /**
+ * Restore the page and conversation contexts during a JSF request
+ */
+ protected void afterRestoreView(FacesContext facesContext)
+ {
+ FacesLifecycle.resumePage();
+ Map parameters = facesContext.getExternalContext().getRequestParameterMap();
+ ConversationPropagation.instance().restoreConversationId(parameters);
+ boolean conversationFound = Manager.instance().restoreConversation();
+ FacesLifecycle.resumeConversation( facesContext.getExternalContext() );
+ postRestorePage(facesContext, parameters, conversationFound);
+ }
+
+ public void raiseEventsBeforePhase(PhaseEvent event)
+ {
+ if ( Contexts.isApplicationContextActive() )
+ {
+ Events.instance().raiseEvent("org.jboss.seam.beforePhase", event);
+ }
+
+ /*if ( Contexts.isConversationContextActive() && Init.instance().isJbpmInstalled() && Pageflow.instance().isInProcess() )
+ {
+ String name;
+ PhaseId phaseId = event.getPhaseId();
+ if ( phaseId == PhaseId.PROCESS_VALIDATIONS )
+ {
+ name = "process-validations";
+ }
+ else if ( phaseId == PhaseId.UPDATE_MODEL_VALUES )
+ {
+ name = "update-model-values";
+ }
+ else if ( phaseId == PhaseId.INVOKE_APPLICATION )
+ {
+ name = "invoke-application";
+ }
+ else if ( phaseId == PhaseId.RENDER_RESPONSE )
+ {
+ name = "render-response";
+ }
+ else
+ {
+ return;
+ }
+ Pageflow.instance().processEvents(name);
+ }*/
+ }
+
+ public void raiseEventsAfterPhase(PhaseEvent event)
+ {
+ if ( Contexts.isApplicationContextActive() )
+ {
+ Events.instance().raiseEvent("org.jboss.seam.afterPhase", event);
+ }
+ }
+
+ /**
+ * Add a faces message when Seam-managed transactions fail.
+ */
+ protected void addTransactionFailedMessage()
+ {
+ try
+ {
+ if ( Transaction.instance().isRolledBackOrMarkedRollback() )
+ {
+ FacesMessages.instance().addFromResourceBundleOrDefault(
+ FacesMessage.SEVERITY_WARN,
+ "org.jboss.seam.TransactionFailed",
+ "Transaction failed"
+ );
+ }
+ }
+ catch (Exception e) {} //swallow silently, not important
+ }
+
+ protected void beforeRenderResponse(FacesContext facesContext)
+ {
+
+ if ( Contexts.isPageContextActive() )
+ {
+ Context pageContext = Contexts.getPageContext();
+ //after every time that the view may have changed,
+ //we need to flush the page context, since the
+ //attribute map is being discarder
+ pageContext.flush();
+ //force refresh of the conversation lists (they are kept in PAGE context)
+ pageContext.remove(Seam.getComponentName(Switcher.class));
+ pageContext.remove("org.jboss.seam.core.conversationList");
+ pageContext.remove("org.jboss.seam.core.conversationStack");
+ }
+
+ preRenderPage(facesContext, PhaseId.RENDER_RESPONSE);
+
+ if ( facesContext.getResponseComplete() )
+ {
+ //workaround for a bug in MyFaces prior to 1.1.3
+ if ( Init.instance().isMyFacesLifecycleBug() )
+ {
+ FacesLifecycle.endRequest( facesContext.getExternalContext() );
+ }
+ }
+ else //if the page actions did not call responseComplete()
+ {
+ FacesMessages.instance().beforeRenderResponse();
+ //do this both before and after render, since conversations
+ //and pageflows can begin during render
+ FacesManager.instance().prepareBackswitch(facesContext);
+ }
+
+ FacesPage.instance().storeConversation();
+ FacesPage.instance().storePageflow();
+
+ PersistenceContexts persistenceContexts = PersistenceContexts.instance();
+ if (persistenceContexts != null)
+ {
+ persistenceContexts.beforeRender();
+ }
+ }
+
+ protected void afterRenderResponse(FacesContext facesContext)
+ {
+ //do this both before and after render, since conversations
+ //and pageflows can begin during render
+ FacesManager.instance().prepareBackswitch(facesContext);
+
+ PersistenceContexts persistenceContexts = PersistenceContexts.instance();
+ if (persistenceContexts != null)
+ {
+ persistenceContexts.afterRender();
+ }
+
+ ExternalContext externalContext = facesContext.getExternalContext();
+ Manager.instance().endRequest( externalContext.getSessionMap() );
+ FacesLifecycle.endRequest(externalContext);
+ }
+
+ protected void afterResponseComplete(FacesContext facesContext)
+ {
+ //responseComplete() was called by one of the other phases,
+ //so we will never get to the RENDER_RESPONSE phase
+ //Note: we can't call Manager.instance().beforeRedirect() here,
+ //since a redirect is not the only reason for a responseComplete
+ ExternalContext externalContext = facesContext.getExternalContext();
+ Manager.instance().endRequest( externalContext.getSessionMap() );
+ FacesLifecycle.endRequest( facesContext.getExternalContext() );
+ }
+
+ private void postRestorePage(FacesContext facesContext, Map parameters, boolean conversationFound)
+ {
+ if ( !Pages.isDebugPage() )
+ {
+ // Only redirect to no-conversation-view if a login redirect isn't required
+ if (!conversationFound && !Pages.instance().isLoginRedirectRequired(facesContext))
+ {
+ Pages.instance().redirectToNoConversationView();
+ }
+
+ Manager.instance().handleConversationPropagation(parameters);
+
+ if ( Init.instance().isJbpmInstalled() && !isExceptionHandlerRedirect() )
+ {
+ Pageflow.instance().validatePageflow(facesContext);
+ }
+
+ Pages.instance().postRestore(facesContext);
+ }
+ }
+
+
+
+ private boolean preRenderPage(FacesContext facesContext, PhaseId phaseId)
+ {
+ if ( Pages.isDebugPage() )
+ {
+ return false;
+ }
+ else
+ {
+ FacesLifecycle.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ boolean actionsWereCalled = false;
+ try
+ {
+ actionsWereCalled = Pages.instance().preRender(facesContext);
+ return actionsWereCalled;
+ }
+ finally
+ {
+ FacesLifecycle.setPhaseId(phaseId);
+ if (actionsWereCalled)
+ {
+ FacesMessages.afterPhase();
+ handleTransactionsAfterPageActions(facesContext); //TODO: does it really belong in the finally?
+ }
+ }
+ }
+ }
+
+ private boolean isExceptionHandlerRedirect()
+ {
+ return Contexts.getConversationContext().isSet("org.jboss.seam.handledException");
+ }
+
+ void begin(PhaseId phaseId)
+ {
+ try
+ {
+ if ( !Transaction.instance().isActiveOrMarkedRollback() )
+ {
+ if(!Transaction.instance().isNoTransaction()){
+ Transaction.instance().rollback();
+ }
+ log.debug("beginning transaction prior to phase: " + phaseId);
+ Transaction.instance().begin();
+ }
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Could not start transaction", e);
+ }
+ }
+
+ void commitOrRollback(PhaseId phaseId)
+ {
+ try
+ {
+ if ( Transaction.instance().isActive() )
+ {
+ log.debug("committing transaction after phase: " + phaseId);
+ Transaction.instance().commit();
+ }
+ else if ( Transaction.instance().isRolledBackOrMarkedRollback() )
+ {
+ log.debug("rolling back transaction after phase: " + phaseId);
+ Transaction.instance().rollback();
+ }
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Could not commit transaction", e);
+ }
+ }
+
+}
Property changes on: trunk/samples/seamPortletEar/seamBookingPortlet/src/main/java/org/ajax4jsf/portlet/seam/SeamPhaseListener.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
16 years, 12 months
JBoss Rich Faces SVN: r5403 - in branches/3.1.x/ui: listShuttle/src/main/java/org/richfaces/renderkit and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-01-15 20:30:07 -0500 (Tue, 15 Jan 2008)
New Revision: 5403
Modified:
branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java
branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
Log:
http://jira.jboss.com/jira/browse/RF-1819
Modified: branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2008-01-16 00:45:18 UTC (rev 5402)
+++ branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/component/UIListShuttle.java 2008-01-16 01:30:07 UTC (rev 5403)
@@ -8,13 +8,11 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
-import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
@@ -564,6 +562,10 @@
final ArrayList targetList = new ArrayList();
try {
+
+ Object key = getRowKey();
+ captureOrigValue(context);
+
walk(context, new DataVisitor() {
public void process(FacesContext context, Object rowKey,
@@ -579,6 +581,10 @@
}
}
}, null);
+
+ setRowKey(key);
+ restoreOrigValue(context);
+
} catch (IOException e) {
throw new ConverterException(e.getLocalizedMessage(), e);
}
Modified: branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java 2008-01-16 00:45:18 UTC (rev 5402)
+++ branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/renderkit/ListShuttleRendererBase.java 2008-01-16 01:30:07 UTC (rev 5403)
@@ -5,7 +5,6 @@
import java.io.IOException;
import java.io.StringWriter;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -115,7 +114,7 @@
if (source == listShuttleRowKey.isFacadeSource()) {
ResponseWriter writer = context.getResponseWriter();
- String clientId = holder.getTable().getClientId(context);
+ String clientId = table.getClientId(context);
writer.startElement(HTML.TR_ELEMENT, table);
writer.writeAttribute("id", clientId, null);
Modified: branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx 2008-01-16 00:45:18 UTC (rev 5402)
+++ branches/3.1.x/ui/listShuttle/src/main/templates/org/richfaces/htmlListShuttle.jspx 2008-01-16 01:30:07 UTC (rev 5403)
@@ -28,6 +28,7 @@
</h:scripts>
<f:clientId var="clientId"/>
+
<table id="#{clientId}" class="rich-list-shuttle #{component.attributes['styleClass']}"
cellspacing="0" cellpadding="0"
x:passThruWithExclusions="id, class, styleClass">
@@ -47,6 +48,8 @@
Boolean switchByClick = (Boolean) component.getAttributes().get("switchByClick");
variables.setVariable("switchByClick", switchByClick);
+
+ variables.setVariable("baseClientId", component.getBaseClientId(context));
]]>
</jsp:scriptlet>
@@ -121,7 +124,7 @@
</td>
<td>
<div class="rich-shuttle-target-items #{component.listClass}" >
- <input type="hidden" value=":" style="display: none;" name="#{clientId}" />
+ <input type="hidden" value=":" style="display: none;" name="#{baseClientId}" />
<input id="#{clientId}tlFocusKeeper" type="button" value="" style="width: 1px; position: absolute; left: -32767px;"/>
Modified: branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2008-01-16 00:45:18 UTC (rev 5402)
+++ branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/component/UIOrderingList.java 2008-01-16 01:30:07 UTC (rev 5403)
@@ -542,6 +542,9 @@
try {
final ArrayList list = new ArrayList(getRowCount());
+ Object key = getRowKey();
+ captureOrigValue(context);
+
walk(context, new DataVisitor() {
public void process(FacesContext context, Object rowKey,
Object argument) throws IOException {
@@ -552,6 +555,9 @@
}, null);
+ setRowKey(key);
+ restoreOrigValue(context);
+
newValue = createContainer(list, previousValue);
} catch (IOException e) {
throw new ConverterException(e.getLocalizedMessage(), e);
16 years, 12 months
JBoss Rich Faces SVN: r5402 - in branches/3.1.x: ui/listShuttle/src/main/java/org/richfaces/model and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-01-15 19:45:18 -0500 (Tue, 15 Jan 2008)
New Revision: 5402
Added:
branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java
branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java
branches/3.1.x/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java
Removed:
branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleDataModel.java
branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java
branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/model/OrderingListDataModel.java
Log:
http://jira.jboss.com/jira/browse/RF-1855
http://jira.jboss.com/jira/browse/RF-1856
Copied: branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java (from rev 5189, trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java)
===================================================================
--- branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java (rev 0)
+++ branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java 2008-01-16 00:45:18 UTC (rev 5402)
@@ -0,0 +1,151 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModel;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceDataModel;
+
+/**
+ * Dual map-based extended data model for model-translating components like list shuttle
+ * @author Nick Belaevski
+ *
+ */
+public class ListShuttleDataModel extends ExtendedDataModel {
+
+ private ListShuttleRowKey rowKey;
+
+ private SequenceDataModel sourceModel;
+ private SequenceDataModel targetModel;
+
+ private Map data;
+
+ private Object wrappedData;
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
+ */
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
+ */
+ public void setRowKey(Object key) {
+ this.rowKey = (ListShuttleRowKey) key;
+ }
+
+ public void walk(final FacesContext context, final DataVisitor visitor, final Range range,
+ final Object argument) throws IOException {
+ if (data != null) {
+ Iterator iterator = data.entrySet().iterator();
+
+ while (iterator.hasNext()) {
+ Entry entry =(Map.Entry) iterator.next();
+
+ visitor.process(context, entry.getKey(), argument);
+ }
+
+ } else {
+ sourceModel.walk(context, new DataVisitor() {
+
+ public void process(FacesContext context, Object rowKey,
+ Object argument) throws IOException {
+
+ ListShuttleRowKey key = new ListShuttleRowKey(rowKey, true);
+ visitor.process(context, key, argument);
+ }
+ }, range, argument);
+
+ targetModel.walk(context, new DataVisitor() {
+
+ public void process(FacesContext context, Object rowKey,
+ Object argument) throws IOException {
+
+ ListShuttleRowKey key = new ListShuttleRowKey(rowKey, false);
+ visitor.process(context, key, argument);
+ }
+
+ }, range, argument);
+ }
+ }
+
+ public int getRowCount() {
+ if (data != null) {
+ return data.size();
+ } else {
+ return sourceModel.getRowCount() + targetModel.getRowCount();
+ }
+ }
+
+ public Object getRowData() {
+ if (data != null) {
+ return data.get(rowKey);
+ } else {
+ if (this.rowKey != null) {
+ if (this.rowKey.isSource()) {
+ return sourceModel.getRowData();
+ } else {
+ return targetModel.getRowData();
+ }
+ } else {
+ return null;
+ }
+ }
+ }
+
+ public int getRowIndex() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Object getWrappedData() {
+ return wrappedData;
+ }
+
+ public boolean isRowAvailable() {
+ if (data != null) {
+ return data.containsKey(rowKey);
+ } else {
+ if (rowKey != null) {
+ if (rowKey.isSource()) {
+ return sourceModel.isRowAvailable();
+ } else {
+ return targetModel.isRowAvailable();
+ }
+ } else {
+ return false;
+ }
+ }
+ }
+
+ public void setRowIndex(int rowIndex) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setWrappedData(Object data) {
+ this.rowKey = null;
+ this.wrappedData = data;
+
+ if (data instanceof Map) {
+ this.data = (Map) data;
+ } else {
+ DataModel[] models = (DataModel[]) data;
+ this.sourceModel = new SequenceDataModel(models[0]);
+ this.targetModel = new SequenceDataModel(models[1]);
+ }
+ }
+
+}
Copied: branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java (from rev 5189, trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java)
===================================================================
--- branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java (rev 0)
+++ branches/3.1.x/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java 2008-01-16 00:45:18 UTC (rev 5402)
@@ -0,0 +1,82 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import java.io.Serializable;
+
+/**
+ * Special type of row key containing information on item origin and new placement
+ *
+ * @author Nick Belaevski
+ *
+ */
+public class ListShuttleRowKey implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3308741255288495879L;
+
+ private boolean source;
+
+ private boolean facadeSource;
+
+ private Object rowKey;
+
+ public boolean isSource() {
+ return source;
+ }
+
+ public boolean isFacadeSource() {
+ return facadeSource;
+ }
+
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((rowKey == null) ? 0 : rowKey.hashCode());
+ result = prime * result + (source ? 1231 : 1237);
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ListShuttleRowKey other = (ListShuttleRowKey) obj;
+ if (rowKey == null) {
+ if (other.rowKey != null)
+ return false;
+ } else if (!rowKey.equals(other.rowKey))
+ return false;
+ if (source != other.source)
+ return false;
+ return true;
+ }
+
+ public String toString() {
+ return (source ? "" : "t") + rowKey.toString();
+ }
+
+ public ListShuttleRowKey(Object rowKey, boolean source) {
+ super();
+ this.rowKey = rowKey;
+ this.source = source;
+ this.facadeSource = source;
+ }
+
+ public ListShuttleRowKey(Object rowKey, boolean source, boolean facadeSource) {
+ super();
+ this.rowKey = rowKey;
+ this.source = source;
+ this.facadeSource = facadeSource;
+ }
+}
Copied: branches/3.1.x/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java (from rev 5189, trunk/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java)
===================================================================
--- branches/3.1.x/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java (rev 0)
+++ branches/3.1.x/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java 2008-01-16 00:45:18 UTC (rev 5402)
@@ -0,0 +1,83 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+
+/**
+ * Map-based extended data model for model-translating components like ordering list
+ *
+ * @author Nick Belaevski
+ * mailto:nbelaevski@exadel.com
+ * created 07.11.2007
+ *
+ */
+public class OrderingListDataModel extends ExtendedDataModel {
+
+ private Map data;
+
+ private Object rowKey;
+
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ public void setRowKey(Object rowKey) {
+ this.rowKey = rowKey;
+ }
+
+ public void walk(FacesContext context, DataVisitor visitor, Range range,
+ Object argument) throws IOException {
+
+ Set entrySet = data.entrySet();
+ Iterator iterator = entrySet.iterator();
+
+ while (iterator.hasNext()) {
+ Map.Entry entry = (Map.Entry) iterator.next();
+
+ visitor.process(context, entry.getKey(), argument);
+ }
+ }
+
+ public int getRowCount() {
+ return data.size();
+ }
+
+ public Object getRowData() {
+ return data.get(rowKey);
+ }
+
+ public int getRowIndex() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Object getWrappedData() {
+ return data;
+ }
+
+ public boolean isRowAvailable() {
+ return data.containsKey(rowKey);
+ }
+
+ public void setRowIndex(int rowIndex) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setWrappedData(Object data) {
+ this.rowKey = null;
+ this.data = (Map) data;
+ }
+
+}
Deleted: branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleDataModel.java
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleDataModel.java 2008-01-15 23:35:41 UTC (rev 5401)
+++ branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleDataModel.java 2008-01-16 00:45:18 UTC (rev 5402)
@@ -1,150 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.faces.context.FacesContext;
-import javax.faces.model.DataModel;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceDataModel;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class ListShuttleDataModel extends ExtendedDataModel {
-
- private ListShuttleRowKey rowKey;
-
- private SequenceDataModel sourceModel;
- private SequenceDataModel targetModel;
-
- private Map data;
-
- private Object wrappedData;
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
- */
- public Object getRowKey() {
- return rowKey;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
- */
- public void setRowKey(Object key) {
- this.rowKey = (ListShuttleRowKey) key;
- }
-
- public void walk(final FacesContext context, final DataVisitor visitor, final Range range,
- final Object argument) throws IOException {
- if (data != null) {
- Iterator iterator = data.entrySet().iterator();
-
- while (iterator.hasNext()) {
- Entry entry =(Map.Entry) iterator.next();
-
- visitor.process(context, entry.getKey(), argument);
- }
-
- } else {
- sourceModel.walk(context, new DataVisitor() {
-
- public void process(FacesContext context, Object rowKey,
- Object argument) throws IOException {
-
- ListShuttleRowKey key = new ListShuttleRowKey(rowKey, true);
- visitor.process(context, key, argument);
- }
- }, range, argument);
-
- targetModel.walk(context, new DataVisitor() {
-
- public void process(FacesContext context, Object rowKey,
- Object argument) throws IOException {
-
- ListShuttleRowKey key = new ListShuttleRowKey(rowKey, false);
- visitor.process(context, key, argument);
- }
-
- }, range, argument);
- }
- }
-
- public int getRowCount() {
- if (data != null) {
- return data.size();
- } else {
- return sourceModel.getRowCount() + targetModel.getRowCount();
- }
- }
-
- public Object getRowData() {
- if (data != null) {
- return data.get(rowKey);
- } else {
- if (this.rowKey != null) {
- if (this.rowKey.isSource()) {
- return sourceModel.getRowData();
- } else {
- return targetModel.getRowData();
- }
- } else {
- return null;
- }
- }
- }
-
- public int getRowIndex() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public Object getWrappedData() {
- return wrappedData;
- }
-
- public boolean isRowAvailable() {
- if (data != null) {
- return data.containsKey(rowKey);
- } else {
- if (rowKey != null) {
- if (rowKey.isSource()) {
- return sourceModel.isRowAvailable();
- } else {
- return targetModel.isRowAvailable();
- }
- } else {
- return false;
- }
- }
- }
-
- public void setRowIndex(int rowIndex) {
- // TODO Auto-generated method stub
-
- }
-
- public void setWrappedData(Object data) {
- this.rowKey = null;
- this.wrappedData = data;
-
- if (data instanceof Map) {
- this.data = (Map) data;
- } else {
- DataModel[] models = (DataModel[]) data;
- this.sourceModel = new SequenceDataModel(models[0]);
- this.targetModel = new SequenceDataModel(models[1]);
- }
- }
-
-}
Deleted: branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java 2008-01-15 23:35:41 UTC (rev 5401)
+++ branches/3.1.x/ui/listShuttle/src/main/java/org/richfaces/model/ListShuttleRowKey.java 2008-01-16 00:45:18 UTC (rev 5402)
@@ -1,80 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import java.io.Serializable;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class ListShuttleRowKey implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 3308741255288495879L;
-
- private boolean source;
-
- private boolean facadeSource;
-
- private Object rowKey;
-
- public boolean isSource() {
- return source;
- }
-
- public boolean isFacadeSource() {
- return facadeSource;
- }
-
- public Object getRowKey() {
- return rowKey;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((rowKey == null) ? 0 : rowKey.hashCode());
- result = prime * result + (source ? 1231 : 1237);
- return result;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ListShuttleRowKey other = (ListShuttleRowKey) obj;
- if (rowKey == null) {
- if (other.rowKey != null)
- return false;
- } else if (!rowKey.equals(other.rowKey))
- return false;
- if (source != other.source)
- return false;
- return true;
- }
-
- public String toString() {
- return (source ? "" : "t") + rowKey.toString();
- }
-
- public ListShuttleRowKey(Object rowKey, boolean source) {
- super();
- this.rowKey = rowKey;
- this.source = source;
- this.facadeSource = source;
- }
-
- public ListShuttleRowKey(Object rowKey, boolean source, boolean facadeSource) {
- super();
- this.rowKey = rowKey;
- this.source = source;
- this.facadeSource = facadeSource;
- }
-}
Deleted: branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/model/OrderingListDataModel.java
===================================================================
--- branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/model/OrderingListDataModel.java 2008-01-15 23:35:41 UTC (rev 5401)
+++ branches/3.1.x/ui/orderingList/src/main/java/org/richfaces/model/OrderingListDataModel.java 2008-01-16 00:45:18 UTC (rev 5402)
@@ -1,81 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-
-/**
- * @author Nick Belaevski
- * mailto:nbelaevski@exadel.com
- * created 07.11.2007
- *
- */
-public class OrderingListDataModel extends ExtendedDataModel {
-
- private Map data;
-
- private Object rowKey;
-
- public Object getRowKey() {
- return rowKey;
- }
-
- public void setRowKey(Object rowKey) {
- this.rowKey = rowKey;
- }
-
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
-
- Set entrySet = data.entrySet();
- Iterator iterator = entrySet.iterator();
-
- while (iterator.hasNext()) {
- Map.Entry entry = (Map.Entry) iterator.next();
-
- visitor.process(context, entry.getKey(), argument);
- }
- }
-
- public int getRowCount() {
- return data.size();
- }
-
- public Object getRowData() {
- return data.get(rowKey);
- }
-
- public int getRowIndex() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public Object getWrappedData() {
- return data;
- }
-
- public boolean isRowAvailable() {
- return data.containsKey(rowKey);
- }
-
- public void setRowIndex(int rowIndex) {
- // TODO Auto-generated method stub
-
- }
-
- public void setWrappedData(Object data) {
- this.rowKey = null;
- this.data = (Map) data;
- }
-
-}
16 years, 12 months
JBoss Rich Faces SVN: r5401 - trunk/framework/api/src/main/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-01-15 18:35:41 -0500 (Tue, 15 Jan 2008)
New Revision: 5401
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java
trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java
trunk/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java
Log:
http://jira.jboss.com/jira/browse/RF-1855
Modified: trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java 2008-01-15 22:08:58 UTC (rev 5400)
+++ trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java 2008-01-15 23:35:41 UTC (rev 5401)
@@ -17,6 +17,7 @@
import org.ajax4jsf.model.SequenceDataModel;
/**
+ * Dual map-based extended data model for model-translating components like list shuttle
* @author Nick Belaevski
*
*/
Modified: trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java 2008-01-15 22:08:58 UTC (rev 5400)
+++ trunk/framework/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java 2008-01-15 23:35:41 UTC (rev 5401)
@@ -6,6 +6,8 @@
import java.io.Serializable;
/**
+ * Special type of row key containing information on item origin and new placement
+ *
* @author Nick Belaevski
*
*/
Modified: trunk/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java 2008-01-15 22:08:58 UTC (rev 5400)
+++ trunk/framework/api/src/main/java/org/richfaces/model/OrderingListDataModel.java 2008-01-15 23:35:41 UTC (rev 5401)
@@ -15,6 +15,8 @@
import org.ajax4jsf.model.Range;
/**
+ * Map-based extended data model for model-translating components like ordering list
+ *
* @author Nick Belaevski
* mailto:nbelaevski@exadel.com
* created 07.11.2007
16 years, 12 months
JBoss Rich Faces SVN: r5399 - branches/3.1.x/framework/api/src/main/java/org/richfaces/model/selection.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2008-01-15 15:55:59 -0500 (Tue, 15 Jan 2008)
New Revision: 5399
Modified:
branches/3.1.x/framework/api/src/main/java/org/richfaces/model/selection/SimpleSelection.java
Log:
http://jira.jboss.com/jira/browse/RF-1756
Modified: branches/3.1.x/framework/api/src/main/java/org/richfaces/model/selection/SimpleSelection.java
===================================================================
--- branches/3.1.x/framework/api/src/main/java/org/richfaces/model/selection/SimpleSelection.java 2008-01-15 20:52:08 UTC (rev 5398)
+++ branches/3.1.x/framework/api/src/main/java/org/richfaces/model/selection/SimpleSelection.java 2008-01-15 20:55:59 UTC (rev 5399)
@@ -5,6 +5,7 @@
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.Set;
/**
@@ -15,7 +16,7 @@
private static final long serialVersionUID = 1L;
- private Set keys = new HashSet();
+ private Set keys = new LinkedHashSet();
public boolean addKey(Object rowKey) {
return keys.add(rowKey);
17 years
JBoss Rich Faces SVN: r5398 - branches/3.1.x/ui/calendar/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2008-01-15 15:52:08 -0500 (Tue, 15 Jan 2008)
New Revision: 5398
Modified:
branches/3.1.x/ui/calendar/src/main/config/component/calendar.xml
Log:
http://jira.jboss.com/jira/browse/RF-1857
Modified: branches/3.1.x/ui/calendar/src/main/config/component/calendar.xml
===================================================================
--- branches/3.1.x/ui/calendar/src/main/config/component/calendar.xml 2008-01-15 20:46:12 UTC (rev 5397)
+++ branches/3.1.x/ui/calendar/src/main/config/component/calendar.xml 2008-01-15 20:52:08 UTC (rev 5398)
@@ -533,6 +533,11 @@
</description>
<defaultvalue>false</defaultvalue>
</property>
+ <property>
+ <name>inputSize</name>
+ <classname>int</classname>
+ </property>
+
</component>
&listeners;
17 years
JBoss Rich Faces SVN: r5397 - branches/3.1.x/framework/impl/src/main/javascript/ajaxjsf.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2008-01-15 15:46:12 -0500 (Tue, 15 Jan 2008)
New Revision: 5397
Modified:
branches/3.1.x/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
Log:
http://jira.jboss.com/jira/browse/RF-1771
Modified: branches/3.1.x/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- branches/3.1.x/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2008-01-15 19:37:54 UTC (rev 5396)
+++ branches/3.1.x/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2008-01-15 20:46:12 UTC (rev 5397)
@@ -902,11 +902,12 @@
var data = request.getJSON('_ajax:data');
try {
var newscript = Sarissa.getText(oncomplete,true);
-// if (window.execScript) {
-// window.execScript( newscript );
-// } else {
+ if (!window.data) {
+ window.data = data;
+ } else {
+ Object.extend(window.data, data);
+ }
window.eval(newscript);
-// }
} catch(e){
LOG.error('Error evaluate oncomplete function '+e.Message);
}
17 years
JBoss Rich Faces SVN: r5396 - in trunk/sandbox/ui/combobox/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: vmolotkov
Date: 2008-01-15 14:37:54 -0500 (Tue, 15 Jan 2008)
New Revision: 5396
Modified:
trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx
Log:
component's structure is changed
Modified: trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
===================================================================
--- trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2008-01-15 18:17:56 UTC (rev 5395)
+++ trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2008-01-15 19:37:54 UTC (rev 5396)
@@ -425,6 +425,7 @@
}
}
}
+ this.iframe.show();
this.listParent.show();
this.listParent.fire("rich:onlistcall", {});
@@ -439,6 +440,7 @@
hide : function() {
this.resetState();
+ this.iframe.hide();
this.listParent.hide();
},
@@ -505,6 +507,8 @@
}
this.listParent.style.top = top + "px";
this.listParent.style.left = 0 + "px";
+ this.iframe.style.top = Richfaces.ComboBoxList.getElemXY(this.listParent).top + this.fieldDimensions.height + "px";
+ this.iframe.style.left = Richfaces.ComboBoxList.getElemXY(this.listParent).left + "px";
},
scrolling : function(event) {
Modified: trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx
===================================================================
--- trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx 2008-01-15 18:17:56 UTC (rev 5395)
+++ trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx 2008-01-15 19:37:54 UTC (rev 5396)
@@ -193,34 +193,36 @@
}
]]>
</jsp:scriptlet>
- <div id="#{clientId}" class="rich-combobox-font rich-combobox-shell #{styleClass}" style="width:#{listWidth}; z-index:1;#{style}"
- x:passThruWithExclusions="value,name,type,id,styleClass,class,style,size,autocomplete,disabled,onchange">
- <div class="rich-combobox-font rich-combobox-shell" style="width:#{width};z-index:1;">
- <input id="comboboxField#{clientId}"
- name="comboboxField#{clientId}"
- disabled="#{disabled}"
- class="rich-combobox-font-inactive rich-combobox-input-inactive #{inputDisabledClass}" type="text"
- value="#{value}"
- size="#{inputSize}"
- autocomplete="off"
- onchange="#{component.attributes['onchange']}"
- onselect="#{component.attributes['onselect']}"
- onblur="#{component.attributes['onblur']}"
- style="width:#{width}; #{inputStyle}"
- />
- <input id="comboBoxButtonBG#{clientId}" readonly="true" type="text" value="" class="rich-combobox-font-inactive rich-combobox-button-background rich-combobox-button-inactive"/>
- <input id="comboboxButton#{clientId}" readonly="true" disabled="#{disabled}" type="text" value="" style="#{buttonStyle}; background-image: #{buttonIconNormal};"
- class="rich-combobox-font-inactive rich-combobox-button-icon-inactive rich-combobox-button-inactive #{buttonDisabledClass}"/>
-
- <input type="text" class="rich-combobox-strut rich-combobox-font" style="width:#{width}"/>
+ <div id="#{clientId}">
+ <div id="control#{clientId}" class="rich-combobox-font rich-combobox-shell #{styleClass}" style="width:#{listWidth}; z-index:1;#{style}"
+ x:passThruWithExclusions="value,name,type,id,styleClass,class,style,size,autocomplete,disabled,onchange">
+ <div class="rich-combobox-font rich-combobox-shell" style="width:#{width};z-index:1;">
+ <input id="comboboxField#{clientId}"
+ name="comboboxField#{clientId}"
+ disabled="#{disabled}"
+ class="rich-combobox-font-inactive rich-combobox-input-inactive #{inputDisabledClass}" type="text"
+ value="#{value}"
+ size="#{inputSize}"
+ autocomplete="off"
+ onchange="#{component.attributes['onchange']}"
+ onselect="#{component.attributes['onselect']}"
+ onblur="#{component.attributes['onblur']}"
+ style="width:#{width}; #{inputStyle}"
+ />
+ <input id="comboBoxButtonBG#{clientId}" readonly="true" type="text" value="" class="rich-combobox-font-inactive rich-combobox-button-background rich-combobox-button-inactive"/>
+ <input id="comboboxButton#{clientId}" readonly="true" disabled="#{disabled}" type="text" value="" style="#{buttonStyle}; background-image: #{buttonIconNormal};"
+ class="rich-combobox-font-inactive rich-combobox-button-icon-inactive rich-combobox-button-inactive #{buttonDisabledClass}"/>
+
+ <input type="text" class="rich-combobox-strut rich-combobox-font" style="width:#{width}"/>
+ </div>
</div>
- </div>
- <iframe id="iframe#{clientId}" class="rich-combobox-list-scroll rich-combobox-list-position" frameborder="0" style="width:#{listWidth};z-index:2;background-color:white;"/>
- <div id="listParent#{clientId}" class="rich-combobox-list-cord #{listClass}" style="display:none; #{listStyle};z-index:3;">
- <div id="listPosition#{clientId}" class="rich-combobox-list-position" style="width:#{listWidth};">
- <div id="listDecoration#{clientId}" class="rich-combobox-list-decoration">
- <div id="list#{clientId}" class="rich-combobox-list-scroll" style="width:#{listWidth};">
- <f:call name="encodeItems"/>
+ <iframe id="iframe#{clientId}" class="rich-combobox-list-scroll rich-combobox-list-position" frameborder="0" style="display:none; width:#{listWidth};z-index:2;"/>
+ <div id="listParent#{clientId}" class="rich-combobox-list-cord #{listClass}" style="display:none; #{listStyle};z-index:3;">
+ <div id="listPosition#{clientId}" class="rich-combobox-list-position" style="width:#{listWidth};">
+ <div id="listDecoration#{clientId}" class="rich-combobox-list-decoration">
+ <div id="list#{clientId}" class="rich-combobox-list-scroll" style="width:#{listWidth};">
+ <f:call name="encodeItems"/>
+ </div>
</div>
</div>
</div>
@@ -268,7 +270,7 @@
}
}
- var combobox = new Richfaces.ComboBox( "#{clientId}",
+ var combobox = new Richfaces.ComboBox( "control#{clientId}",
"list#{clientId}",
"listParent#{clientId}",
"comboboxField#{clientId}",
17 years
JBoss Rich Faces SVN: r5395 - branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: vmolotkov
Date: 2008-01-15 13:17:56 -0500 (Tue, 15 Jan 2008)
New Revision: 5395
Modified:
branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
Log:
components were changed
Modified: branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js
===================================================================
--- branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2008-01-15 18:17:52 UTC (rev 5394)
+++ branches/3.1.x/ui/listShuttle/src/main/resources/org/richfaces/renderkit/html/scripts/ListShuttle.js 2008-01-15 18:17:56 UTC (rev 5395)
@@ -156,7 +156,7 @@
}
this.controlListManager();
this.targetList.controlListManager();
- this.saveState();
+ //this.saveState();
this.targetLayoutManager.widthSynchronization();
this.sourceLayoutManager.widthSynchronization();
@@ -212,10 +212,10 @@
component.shuttleTbody = table.tBodies[0];
},
- saveState : function() {
+ /*saveState : function() {
this.targetList.saveState();
this.sourceList.saveState();
- },
+ },*/
moveItemByClick : function(event, sourceComponent, targetComponent, layoutManager) {
var item = this.sourceList.getEventTargetRow(event);
@@ -223,7 +223,7 @@
this.controlListManager();
this.targetList.controlListManager();
- this.saveState();
+ //this.saveState();
this.targetLayoutManager.widthSynchronization();
this.sourceLayoutManager.widthSynchronization();
17 years