Author: thomas.heute(a)jboss.com
Date: 2008-04-15 08:06:59 -0400 (Tue, 15 Apr 2008)
New Revision: 10589
Added:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/aspects/controller/CleanNSInterceptor.java
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java
branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
Log:
JBPORTAL-1988: Add a way to clean the navigational state of windows on page refresh
Added:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/aspects/controller/CleanNSInterceptor.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/aspects/controller/CleanNSInterceptor.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/aspects/controller/CleanNSInterceptor.java 2008-04-15
12:06:59 UTC (rev 10589)
@@ -0,0 +1,59 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.aspects.controller;
+
+import java.util.Collection;
+
+import org.jboss.portal.common.invocation.InvocationException;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerInterceptor;
+import org.jboss.portal.core.controller.ControllerResponse;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
+import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
+import org.jboss.portal.core.navstate.NavigationalStateKey;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class CleanNSInterceptor extends ControllerInterceptor
+{
+
+ @Override
+ public ControllerResponse invoke(ControllerCommand cmd) throws Exception,
InvocationException
+ {
+ if (cmd instanceof ViewPageCommand)
+ {
+ ViewPageCommand vpc = (ViewPageCommand)cmd;
+ Collection<PortalObject> children = vpc.getPage().getChildren();
+ for (PortalObject portalObject: children)
+ {
+ cmd.removeAttribute(ControllerCommand.NAVIGATIONAL_STATE_SCOPE, new
NavigationalStateKey(WindowNavigationalState.class, portalObject.getId()));
+ }
+ }
+ return (ControllerResponse)cmd.invokeNext();
+ }
+
+}
+
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java 2008-04-15
11:45:47 UTC (rev 10588)
+++
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/model/portal/PortalObject.java 2008-04-15
12:06:59 UTC (rev 10589)
@@ -120,14 +120,14 @@
*
* @return the children
*/
- Collection getChildren();
+ Collection<PortalObject> getChildren();
/**
* Return all the children of this object filtered with a particular mask.
*
* @return the children
*/
- Collection getChildren(int mask);
+ Collection<PortalObject> getChildren(int mask);
/**
* Return the parent object.
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2008-04-15
11:45:47 UTC (rev 10588)
+++
branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2008-04-15
12:06:59 UTC (rev 10589)
@@ -209,7 +209,17 @@
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
</mbean>
+ <!--
+ This interceptor cleans the Navigation state of windows when the user call a new
page or refresh the page
+ -->
<mbean
+ code="org.jboss.portal.core.aspects.controller.CleanNSInterceptor"
+ name="portal:service=Interceptor,type=Command,name=CleanNS"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+ <mbean
code="org.jboss.portal.core.aspects.controller.node.PortalNodeInterceptor"
name="portal:service=Interceptor,type=Command,name=PortalNode"
xmbean-dd=""
@@ -267,6 +277,7 @@
<depends-list optional-attribute-name="InterceptorNames">
<depends-list-element>portal:service=Interceptor,type=Command,name=ResourceAcquisition</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=Ajax</depends-list-element>
+ <!--
depends-list-element>portal:service=Interceptor,type=Command,name=CleanNS</depends-list-element
-->
<depends-list-element>portal:service=Interceptor,type=Command,name=NavigationalState</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=PortalNode</depends-list-element>
<depends-list-element>portal:service=Interceptor,type=Command,name=PolicyEnforcement</depends-list-element>