Right, for anybody interested I eventually solved my problem and I don't think for one
minute that it's elegant but it does the job.
EssentiallyI created a custom CommandInterceptor (see code below). The interceptor clears
the navigational state of all portlet windows in the portal if there there is an action
request to the portlet window called "DNSCustomerContextSelectionPortletWindow".
Fortunately in my scenario an action request targetting this portlet window will mean I
need to clear the navigational state of all portlet windows in the portal.
The interceptor needs to be built to a jar file and the jar file placed in :
| /jboss-4.0.4.GA/server/default/deploy/jboss-portal.sar/lib/
|
The interceptor then needs to be added to the Command interceptor stack defined in
| /jboss-4.0.4.GA/server/default/deploy/jboss-portal.sar/META-INF/jboss-service.xml
|
|
This is done as follows:
| <mbean
|
code="com.dns.jboss.portal.interceptor.DNSCustomerContextChangeInterceptor"
|
name="portal:service=Interceptor,type=Command,name=DNSCustomerContextChangeCheck"
| xmbean-dd=""
|
xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
| <xmbean/>
| </mbean>
|
| <mbean
| code="org.jboss.portal.server.impl.invocation.JBossInterceptorStack"
| name="portal:service=InterceptorStack,type=Command"
| xmbean-dd=""
|
xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
| <xmbean/>
| <depends-list optional-attribute-name="InterceptorNames">
|
<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>
|
<depends-list-element>portal:service=Interceptor,type=Command,name=PageNavigation</depends-list-element>
|
<depends-list-element>portal:service=Interceptor,type=Command,name=EventBroadcaster</depends-list-element>
|
<depends-list-element>portal:service=Interceptor,type=Command,name=DNSCustomerContextChangeCheck</depends-list-element>
| </depends-list>
| </mbean>
|
|
|
|
| package com.dns.jboss.portal.interceptor;
|
| import java.util.Collection;
| import java.util.Iterator;
|
| import org.apache.log4j.Logger;
| import org.jboss.portal.common.invocation.InvocationException;
| import org.jboss.portal.core.command.CommandInterceptor;
| import org.jboss.portal.core.command.ControllerCommand;
| import org.jboss.portal.core.command.InvokeWindowActionCommand;
| import org.jboss.portal.core.model.portal.Page;
| import org.jboss.portal.core.model.portal.Window;
| import org.jboss.portal.server.ServerInvocation;
|
|
| public class DNSCustomerContextChangeInterceptor extends CommandInterceptor
| {
| private static final Logger log = Logger.getLogger(
DNSCustomerContextChangeInterceptor.class );
|
| public void invoke( ControllerCommand cmd ) throws Exception, InvocationException
| {
| if ( customerContextChange( cmd ) )
| clearPortalNavigationalState( (InvokeWindowActionCommand)cmd );
| cmd.invokeNext();
| }
|
| private boolean customerContextChange( ControllerCommand command )
| {
| if (command instanceof InvokeWindowActionCommand)
| {
| InvokeWindowActionCommand iwac = (InvokeWindowActionCommand)command;
| if ( iwac.getWindow().getName().equals(
"DNSCustomerContextSelectionPortletWindow" ) )
| return true;
| }
| return false;
| }
|
| private void clearPortalNavigationalState( InvokeWindowActionCommand iwac )
| {
| Collection portalChildren = iwac.getPortal().getChildren();
|
| for( Iterator i = portalChildren.iterator(); i.hasNext(); )
| {
| Object portalChild = i.next();
| if ( portalChild instanceof Page )
| {
| Page page = (Page)portalChild;
| Collection pageChildren = ( (Page) portalChild ).getChildren();
| for ( Iterator j = pageChildren.iterator(); j.hasNext(); )
| {
| Object pageChild = j.next();
| if ( pageChild instanceof Window )
| {
| Window window = (Window)pageChild;
| if ( !window.equals( iwac.getWindow() ) )
| {
| ServerInvocation sinv =
iwac.getContext().getExecutionContext().getServerInvocation();
| log.debug( "CLEARING NAV STATE OF WINDOW: " +
window.getName() );
|
sinv.getRequest().getNavigationContext().setNavigationalState(window.getInstanceRef(),
null );
|
| //WindowNavigationalState windowNavState =
(WindowNavigationalState)sinv.getRequest().getNavigationContext().getNavigationalState(
window.getId() + "_window");
| //windowNavState = new WindowNavigationalState();
|
//sinv.getRequest().getNavigationContext().setNavigationalState(window.getId() +
"_window", windowNavState);
| }
| }
| }
| }
| }
| }
|
| }
|
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4125037#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...