[portal-commits] JBoss Portal SVN: r12957 - in branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core: controller/portlet and 2 other directories.
portal-commits at lists.jboss.org
portal-commits at lists.jboss.org
Fri Mar 6 11:26:23 EST 2009
Author: chris.laprun at jboss.com
Date: 2009-03-06 11:26:22 -0500 (Fri, 06 Mar 2009)
New Revision: 12957
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPageCommand.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
Log:
- JBPORTAL-2326: needs to be tested
+ If no parameters is passed to a page to be displayed, erased previous page navigational state
+ If we have a PNS, pass the current state as parameters to ViewPageCommand before full refresh in AJAX context (hackish)
+ Improved getPortletPublicNavigationalState method to avoid unnecessary work
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2009-03-06 15:35:06 UTC (rev 12956)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java 2009-03-06 16:26:22 UTC (rev 12957)
@@ -71,10 +71,13 @@
import org.jboss.portal.theme.render.ThemeContext;
import org.jboss.portal.web.ServletContextDispatcher;
+import javax.xml.namespace.QName;
import java.io.StringWriter;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Map;
import java.util.Set;
/**
@@ -157,7 +160,8 @@
// Whether we need a full refresh or not
boolean fullRefresh = false;
- //
+ // in case we have we have a page navigational state...
+ Map<String, String[]> parameters = null;
if (ctx.getChanges() == null)
{
@@ -213,20 +217,33 @@
}
else if (type == PageNavigationalState.class)
{
- // force full refresh for now...
+ // force full refresh for now... for JBPORTAL-2326
fullRefresh = true;
// TODO: implement proper propagation of PRPs and events
- /*PageNavigationalState pns = (PageNavigationalState)update.getNewValue();
+ PageNavigationalState pns = (PageNavigationalState)update.getNewValue();
if (pns != null)
{
- CoordinationManager coordinationManager = controllerContext.getController().getCoordinationManager();
+
+ // todo: fix-me, this is a hack to copy PRPs when we force the full refresh as parameters to ViewPageCommand...
+ Map<QName, String[]> qNameMap = pns.getParameters();
+ if (qNameMap != null && !qNameMap.isEmpty())
+ {
+ parameters = new HashMap<String, String[]>(qNameMap.size());
+
+ for (Map.Entry<QName, String[]> entry : qNameMap.entrySet())
+ {
+ parameters.put(entry.getKey().toString(), entry.getValue());
+ }
+ }
+
+ /*CoordinationManager coordinationManager = controllerContext.getController().getCoordinationManager();
for (QName qName : pns.getParameters().keySet())
{
//
- }
- }*/
+ }*/
+ }
}
}
}
@@ -358,7 +375,17 @@
}
// We perform a full refresh
- ViewPageCommand rpc = new ViewPageCommand(page.getId());
+ ViewPageCommand rpc;
+ if (parameters == null)
+ {
+ rpc = new ViewPageCommand(page.getId());
+ }
+ else
+ {
+ // if we have parameters from a PNS, feed them to ViewPageCommand (this is rather hackish)
+ rpc = new ViewPageCommand(page.getId(), parameters);
+ }
+
String url = controllerContext.renderURL(rpc, null, null);
UpdatePageLocationResponse dresp = new UpdatePageLocationResponse(url);
return new AjaxResponse(dresp);
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java 2009-03-06 15:35:06 UTC (rev 12956)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/portlet/ControllerPageNavigationalState.java 2009-03-06 16:26:22 UTC (rev 12957)
@@ -20,6 +20,7 @@
* 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.controller.portlet;
import org.jboss.portal.core.CoreConstants;
@@ -136,7 +137,6 @@
//
windowPublicNavigationalStateUpdate.clear();
-
}
if (updates != null)
@@ -191,8 +191,6 @@
//
pageUpdates.clear();
}
-
-
}
/**
@@ -332,78 +330,84 @@
{
PortletInfo info = controllerContext.getPortletInfo(windowName);
- CoordinationManager manager = getCoordinationManager();
-
- // For explicit initiate windowPublicNavigationStateUpdate with previous state
- if (windowPublicNavigationalStateUpdate == null)
- {
- initiateWindowPublicNavigationalStateUpdate();
- }
-
if (info != null)
{
NavigationInfo navigation = info.getNavigation();
if (navigation != null)
{
- Map<String, String[]> publicNavigationalState = new HashMap<String, String[]>();
- for (ParameterInfo parameterInfo : navigation.getPublicParameters())
+ Map<String, String[]> publicNavigationalState = null;
+
+ // first make sure that we actually have public parameters before actually doing anything
+ Collection<? extends ParameterInfo> publicParameters = navigation.getPublicParameters();
+ if (publicParameters != null && !publicParameters.isEmpty())
{
+ publicNavigationalState = new HashMap<String, String[]>();
+ CoordinationManager manager = getCoordinationManager();
- QName parameterName = parameterInfo.getName();
- Collection<String> bindings = manager.getBindingNames(getWindow(windowName), parameterName);
+ // For explicit initiate windowPublicNavigationStateUpdate with previous state
+ if (windowPublicNavigationalStateUpdate == null)
+ {
+ initiateWindowPublicNavigationalStateUpdate();
+ }
- // Don't store the URI as a page scoped public render parameter but window scoped
- // Also for explicit and parameter with no bindings
- if (CoreConstants.JBOSS_PORTAL_CONTENT_URI.equals(parameterName) || (!implicitMode && bindings.size() == 0))
+ for (ParameterInfo parameterInfo : publicParameters)
{
- String[] parameterValue = getWindowPublicNavigationalState(windowName, parameterName);
- if (parameterValue != null)
+ QName parameterName = parameterInfo.getName();
+ Collection<String> bindings = manager.getBindingNames(getWindow(windowName), parameterName);
+
+ // Don't store the URI as a page scoped public render parameter but window scoped
+ // Also for explicit and parameter with no bindings
+ if (CoreConstants.JBOSS_PORTAL_CONTENT_URI.equals(parameterName) || (!implicitMode && bindings.size() == 0))
{
- String parameterId = parameterInfo.getId();
+ String[] parameterValue = getWindowPublicNavigationalState(windowName, parameterName);
- // We clone the value here so we keep the internal state not potentially changed
- publicNavigationalState.put(parameterId, parameterValue.clone());
+ if (parameterValue != null)
+ {
+ String parameterId = parameterInfo.getId();
+
+ // We clone the value here so we keep the internal state not potentially changed
+ publicNavigationalState.put(parameterId, parameterValue.clone());
+ }
}
- }
- else
- {
- String[] parameterValue = getPublicNavigationalState(parameterName);
+ else
+ {
+ String[] parameterValue = getPublicNavigationalState(parameterName);
- // Explicit binding
- String[] explicitParameterValue = null;
+ // Explicit binding
+ String[] explicitParameterValue = null;
- // Check all bindings for this window/qname pair
- // If this window/qname is bound several times with different updated params value will be unpredictable...
- for (String binding : bindings)
- {
- explicitParameterValue = getPublicNavigationalState(new QName(XMLConstants.DEFAULT_NS_PREFIX, binding));
+ // Check all bindings for this window/qname pair
+ // If this window/qname is bound several times with different updated params value will be unpredictable...
+ for (String binding : bindings)
+ {
+ explicitParameterValue = getPublicNavigationalState(new QName(XMLConstants.DEFAULT_NS_PREFIX, binding));
- // if a PNS has been found for a binding, use it and do not look further
+ // if a PNS has been found for a binding, use it and do not look further
+ if (explicitParameterValue != null)
+ {
+ break;
+ }
+ }
+
+ //
+ String parameterId = parameterInfo.getId();
+
+ //
if (explicitParameterValue != null)
{
- break;
+ // We clone the value here so we keep the internal state not potentially changed
+ publicNavigationalState.put(parameterId, explicitParameterValue.clone());
}
+ else if (implicitMode && parameterValue != null)
+ {
+ // We clone the value here so we keep the internal state not potentially changed
+ publicNavigationalState.put(parameterId, parameterValue.clone());
+ }
}
-
- //
- String parameterId = parameterInfo.getId();
-
- //
- if (explicitParameterValue != null)
- {
- // We clone the value here so we keep the internal state not potentially changed
- publicNavigationalState.put(parameterId, explicitParameterValue.clone());
- }
- else if (implicitMode && parameterValue != null)
- {
- // We clone the value here so we keep the internal state not potentially changed
- publicNavigationalState.put(parameterId, parameterValue.clone());
- }
}
}
- //
return publicNavigationalState;
}
}
@@ -629,11 +633,11 @@
throw new IllegalStateException("Was called with a non null windowPublicNavigationalStateUpdate field");
}
- //
- windowPublicNavigationalStateUpdate = new HashMap<String, HashMap<QName, String[]>>();
+ Set<String> windowNames = controllerContext.getWindowNames();
+ windowPublicNavigationalStateUpdate = new HashMap<String, HashMap<QName, String[]>>(windowNames.size());
// Initial state for all windows on this page
- for (String windowName : controllerContext.getWindowNames())
+ for (String windowName : windowNames)
{
HashMap<QName, String[]> publicContentStateParams = getWindowPublicContentStateParameters(windowName);
windowPublicNavigationalStateUpdate.put(windowName, publicContentStateParams);
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPageCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPageCommand.java 2009-03-06 15:35:06 UTC (rev 12956)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/command/view/ViewPageCommand.java 2009-03-06 16:26:22 UTC (rev 12957)
@@ -93,25 +93,25 @@
public ControllerResponse execute() throws ControllerException
{
+ NavigationalStateContext nsContext = (NavigationalStateContext)context.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
+
+ String pageId = getPage().getId().toString();
+
if (parameters.size() > 0)
{
- NavigationalStateContext nsContext = (NavigationalStateContext)context.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
-
- //
- String pageId = getPage().getId().toString();
-
- //
Map<QName, String[]> state = new HashMap<QName, String[]>();
- //
for (Map.Entry<String, String[]> entry : parameters.entrySet())
{
state.put(new QName(XMLConstants.DEFAULT_NS_PREFIX, entry.getKey()), entry.getValue());
}
- //
nsContext.setPageNavigationalState(pageId, new PageNavigationalState(state));
}
+ else
+ {
+ nsContext.setPageNavigationalState(pageId, null);
+ }
//
return new UpdatePageResponse(page.getId());
Modified: branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2009-03-06 15:35:06 UTC (rev 12956)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/model/portal/navstate/PortalObjectNavigationalStateContext.java 2009-03-06 16:26:22 UTC (rev 12957)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -135,7 +135,7 @@
{
PortalObjectId id = (PortalObjectId)wantedKey.getId();
Object storedNS = store.getAttribute(id.toString());
- if (storedNS instanceof WindowNavigationalState)
+ if (storedNS instanceof WindowNavigationalState || storedNS instanceof PageNavigationalState)
{
oldNS = storedNS;
}
More information about the portal-commits
mailing list