[portal-commits] JBoss Portal SVN: r12936 - branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Tue Mar 3 18:11:13 EST 2009


Author: chris.laprun at jboss.com
Date: 2009-03-03 18:11:13 -0500 (Tue, 03 Mar 2009)
New Revision: 12936

Modified:
   branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
Log:
- JBPORTAL-2328: if we have a page NS, force a full refresh for now... :(
- Minor optimization: do not loop over children but rather over dirty windows (which should be less) thus 
  avoiding to use getChildren which is costly...

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-03 21:30:40 UTC (rev 12935)
+++ branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java	2009-03-03 23:11:13 UTC (rev 12936)
@@ -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.ajax;
 
 import org.apache.log4j.Logger;
@@ -49,6 +50,7 @@
 import org.jboss.portal.core.model.portal.command.response.UpdatePageResponse;
 import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
 import org.jboss.portal.core.model.portal.content.WindowRendition;
+import org.jboss.portal.core.model.portal.navstate.PageNavigationalState;
 import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
 import org.jboss.portal.core.navstate.NavigationalStateChange;
 import org.jboss.portal.core.navstate.NavigationalStateContext;
@@ -85,36 +87,6 @@
  */
 public class AjaxResponseHandler implements ResponseHandler
 {
-
-   // Detect any change that would require a total refresh
-//      HttpServletRequest req = invocation.getServerContext().getClientRequest();
-//      String clientViewId = req.getHeader("view_id");
-//      if (clientViewId != null)
-//      {
-//         PortalObjectNavigationalStateContext ctx = (PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
-//         String serverViewId = ctx.getViewId();
-//         if (!clientViewId.equals(serverViewId))
-//         {
-//            // todo : that will not work for FORMS submissions, we need a response for the client
-//            // to tell to do the request the normal way
-//            try
-//            {
-//               UpdatePageLocationResponse dresp = new UpdatePageLocationResponse(req.getRequestURL().toString());
-//               AjaxResponse aresp = new AjaxResponse(dresp);
-//               aresp.sendResponse(invocation.getServerContext());
-//            }
-//            catch (IOException e)
-//            {
-//               e.printStackTrace();
-//            }
-//            catch (ServletException e)
-//            {
-//               e.printStackTrace();
-//            }
-//            return;
-//         }
-//      }
-
    /** . */
    private static final Logger log = Logger.getLogger(AjaxResponseHandler.class);
 
@@ -173,10 +145,9 @@
       {
          UpdatePageResponse upw = (UpdatePageResponse)controllerResponse;
 
-         // Obtain page and portal
+         // Obtain page
          final Page page = (Page)portalObjectContainer.getObject(upw.getPageId());
 
-
          //
          NavigationalStateContext ctx = (NavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
 
@@ -211,7 +182,8 @@
                NavigationalStateKey key = update.getKey();
 
                // We consider only portal object types
-               if (key.getType() == WindowNavigationalState.class)
+               Class type = key.getType();
+               if (type == WindowNavigationalState.class)
                {
                   // Get old window state
                   WindowNavigationalState oldNS = (WindowNavigationalState)update.getOldValue();
@@ -239,6 +211,23 @@
                   // Collect the dirty window id
                   dirtyWindowIds.add(key.getId());
                }
+               else if (type == PageNavigationalState.class)
+               {
+                  // force full refresh for now...
+                  fullRefresh = true;
+
+                  // TODO: implement proper propagation of PRPs and events
+                  /*PageNavigationalState pns = (PageNavigationalState)update.getNewValue();
+
+                  if (pns != null)
+                  {
+                     CoordinationManager coordinationManager = controllerContext.getController().getCoordinationManager();
+                     for (QName qName : pns.getParameters().keySet())
+                     {
+                        //
+                     }
+                  }*/
+               }
             }
          }
 
@@ -249,10 +238,13 @@
          if (!fullRefresh)
          {
             ArrayList<PortalObject> refreshedWindows = new ArrayList<PortalObject>();
-            for (PortalObject child : page.getChildren(PortalObject.WINDOW_MASK))
+
+            for (Object dirtyWindowId : dirtyWindowIds)
             {
-               PortalObjectId childId = child.getId();
-               if (dirtyWindowIds.contains(childId))
+               PortalObjectId poid = (PortalObjectId)dirtyWindowId;
+               String windowName = poid.getPath().getLastComponentName();
+               PortalObject child = page.getChild(windowName, Window.class);
+               if (child != null)
                {
                   refreshedWindows.add(child);
                }




More information about the portal-commits mailing list