[richfaces-svn-commits] JBoss Rich Faces SVN: r2970 - in trunk: samples/seamIntegration/src/main/webapp/WEB-INF and 2 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Mon Sep 17 18:59:08 EDT 2007
Author: alexsmirnov
Date: 2007-09-17 18:59:08 -0400 (Mon, 17 Sep 2007)
New Revision: 2970
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java
trunk/samples/seamIntegration/src/main/webapp/WEB-INF/web.xml
trunk/sandbox/samples/dialog-window-sample/src/main/webapp/dialog.xhtml
trunk/sandbox/ui/dialog-window/pom.xml
Log:
Create workaround for a http://jira.jboss.com/jira/browse/JBSEAM-460
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java 2007-09-17 18:57:02 UTC (rev 2969)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxStateManager.java 2007-09-17 22:59:08 UTC (rev 2970)
@@ -25,6 +25,7 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -56,6 +57,8 @@
*/
public class AjaxStateManager extends StateManager {
+ private static final Class[] STATE_MANAGER_ARGUMENTS = new Class[] { StateManager.class };
+
protected static final int DEFAULT_NUMBER_OF_VIEWS = 16;
private static final String VIEW_STATES_MAP = AjaxStateManager.class
@@ -68,6 +71,8 @@
private final StateManager parent;
+ private StateManager seamStateManager;
+
private final ComponentsLoader componentLoader;
private int viewSequence = 0;
@@ -83,6 +88,73 @@
super();
this.parent = parent;
componentLoader = new ComponentsLoaderImpl();
+ // HACK - Seam perform significant operations before save tree state.
+ // Try to create it instance by reflection,
+ // to call in real state saving operations.
+ ClassLoader classLoader = Thread.currentThread()
+ .getContextClassLoader();
+ if (null == classLoader) {
+ classLoader = AjaxStateManager.class.getClassLoader();
+ }
+ try {
+ Class seamStateManagerClass = classLoader
+ .loadClass("org.jboss.seam.jsf.SeamStateManager");
+ Constructor constructor = seamStateManagerClass
+ .getConstructor(STATE_MANAGER_ARGUMENTS);
+ seamStateManager = (StateManager) constructor
+ .newInstance(new Object[] { new StateManager() {
+
+ protected Object getComponentStateToSave(
+ FacesContext arg0) {
+ // do nothing
+ return null;
+ }
+
+ protected Object getTreeStructureToSave(
+ FacesContext arg0) {
+ // do nothing
+ return null;
+ }
+
+ protected void restoreComponentState(FacesContext arg0,
+ UIViewRoot arg1, String arg2) {
+ // do nothing
+
+ }
+
+ protected UIViewRoot restoreTreeStructure(
+ FacesContext arg0, String arg1, String arg2) {
+ // do nothing
+ return null;
+ }
+
+ public UIViewRoot restoreView(FacesContext arg0,
+ String arg1, String arg2) {
+ // do nothing
+ return null;
+ }
+
+ public SerializedView saveSerializedView(
+ FacesContext arg0) {
+ // delegate to enclosed class method.
+ return buildSerializedView(arg0);
+ }
+
+ public void writeState(FacesContext arg0,
+ SerializedView arg1) throws IOException {
+ // do nothing
+ }
+
+ } });
+ if(_log.isDebugEnabled()){
+ _log.debug("Create instance of the SeamStateManager");
+ }
+ } catch (Exception e) {
+ seamStateManager = null;
+ if(_log.isDebugEnabled()){
+ _log.debug("SeamStateManager is not present");
+ }
+ }
}
/*
@@ -202,24 +274,31 @@
id);
if (null == restoredState) {
if (_log.isDebugEnabled()) {
- _log.debug("No saved view state found for a Id "+id+". Restore last saved state");
+ _log
+ .debug("No saved view state found for a Id "
+ + id
+ + ". Restore last saved state");
}
restoredState = (Object[]) logicalStates
.get(logicalStates.firstKey());
}
} else {
if (_log.isDebugEnabled()) {
- _log.debug("No version Id for a saved view state in request. Restore last saved state");
+ _log
+ .debug("No version Id for a saved view state in request. Restore last saved state");
}
restoredState = (Object[]) logicalStates
.get(logicalStates.firstKey());
}
- } else if (_log.isDebugEnabled()) {
- _log.debug("Can't restore view state : no saved states for a ViewId "+viewId);
+ } else if (_log.isDebugEnabled()) {
+ _log
+ .debug("Can't restore view state : no saved states for a ViewId "
+ + viewId);
}
} else if (_log.isDebugEnabled()) {
- _log.debug("Can't restore view state : no saved view states in session");
+ _log
+ .debug("Can't restore view state : no saved view states in session");
}
}
@@ -229,6 +308,19 @@
}
public SerializedView saveSerializedView(FacesContext context) {
+ if (null == seamStateManager) {
+ return buildSerializedView(context);
+ } else {
+ // Delegate save method to seam State Manager.
+ return seamStateManager.saveSerializedView(context);
+ }
+ }
+
+ /**
+ * @param context
+ * @return
+ */
+ protected SerializedView buildSerializedView(FacesContext context) {
SerializedView serializedView = null;
UIViewRoot viewRoot = context.getViewRoot();
if (!viewRoot.isTransient()) {
@@ -276,7 +368,7 @@
return id;
}
}
- synchronized (viewSequenceMutex ) {
+ synchronized (viewSequenceMutex) {
if (viewSequence++ == Character.MAX_VALUE) {
viewSequence = 0;
}
Modified: trunk/samples/seamIntegration/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/samples/seamIntegration/src/main/webapp/WEB-INF/web.xml 2007-09-17 18:57:02 UTC (rev 2969)
+++ trunk/samples/seamIntegration/src/main/webapp/WEB-INF/web.xml 2007-09-17 22:59:08 UTC (rev 2970)
@@ -80,15 +80,5 @@
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
- <security-constraint>
- <display-name>Restrict raw XHTML Documents</display-name>
- <web-resource-collection>
- <web-resource-name>XHTML</web-resource-name>
- <url-pattern>*.xhtml</url-pattern>
- </web-resource-collection>
- <auth-constraint>
- <role-name>NONE</role-name>
- </auth-constraint>
- </security-constraint>
</web-app>
Modified: trunk/sandbox/samples/dialog-window-sample/src/main/webapp/dialog.xhtml
===================================================================
--- trunk/sandbox/samples/dialog-window-sample/src/main/webapp/dialog.xhtml 2007-09-17 18:57:02 UTC (rev 2969)
+++ trunk/sandbox/samples/dialog-window-sample/src/main/webapp/dialog.xhtml 2007-09-17 22:59:08 UTC (rev 2970)
@@ -3,7 +3,7 @@
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
- xmlns:dialog="http://labs.jboss.com/jbossrichfaces/ui/ui/dialog-window"
+ xmlns:dialog="http://richfaces.org/dialog"
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
>
<head>
Modified: trunk/sandbox/ui/dialog-window/pom.xml
===================================================================
--- trunk/sandbox/ui/dialog-window/pom.xml 2007-09-17 18:57:02 UTC (rev 2969)
+++ trunk/sandbox/ui/dialog-window/pom.xml 2007-09-17 22:59:08 UTC (rev 2970)
@@ -26,7 +26,9 @@
<library>
<prefix>org.richfaces.ui</prefix>
<taglib>
+ <uri>http://richfaces.org/dialog</uri>
<shortName>dialog</shortName>
+ <displayName>Core ajax components tags</displayName>
</taglib>
</library>
</configuration>
More information about the richfaces-svn-commits
mailing list