portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r469711 - in /portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed: container/url/impl/ decoration/ layout/ajax-xml/ layout/impl/
Date Wed, 01 Nov 2006 00:02:30 GMT
Author: taylor
Date: Tue Oct 31 16:02:29 2006
New Revision: 469711

URL: http://svn.apache.org/viewvc?view=rev&rev=469711
Log:
return actions (window states, modes) in getpage ajax api

Modified:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/psml.vm
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPageAction.java

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java?view=diff&rev=469711&r1=469710&r2=469711
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/container/url/impl/AbstractPortalURL.java
Tue Oct 31 16:02:29 2006
@@ -92,6 +92,32 @@
         return navStateParameter;
     }
     
+    public String createNavigationalEncoding(PortletWindow window, Map parameters, PortletMode
mode, WindowState state, boolean action)
+    {
+        try
+        {
+            return getNavigationalStateParameterName() + ":" + getNavigationalState().encode(window,
parameters, mode, state, action);
+        }
+        catch (UnsupportedEncodingException e)
+        {
+            e.printStackTrace();
+            return "";            
+        }    
+    }
+    
+    public String createNavigationalEncoding(PortletWindow window, PortletMode mode, WindowState
state)
+    {
+        try
+        {
+            return getNavigationalStateParameterName() + ":" + getNavigationalState().encode(window,
mode, state);
+        }
+        catch (UnsupportedEncodingException e)
+        {
+            e.printStackTrace();
+            return "";            
+        }                
+    }
+    
     protected void decodeBaseURL(HttpServletRequest request)
     {
         if (base == null)

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java?view=diff&rev=469711&r1=469710&r2=469711
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/AbstractDecoratorActionsFactory.java
Tue Oct 31 16:02:29 2006
@@ -38,8 +38,12 @@
         String actionName = template.getAction();
 
         PortalURL portalURL = rc.getPortalURL();
-        String actionURL = portalURL.createPortletURL(pw, template.getCustomMode(), template.getCustomState(),
-                        portalURL.isSecure()).toString();
+        Boolean isAjaxRequest = (Boolean)rc.getAttribute(DecorationValve.IS_AJAX_DECORATION_REQUEST);
+        
+        String actionURL = (isAjaxRequest == null) 
+            ? portalURL.createPortletURL(pw, template.getCustomMode(), template.getCustomState(),
+                        portalURL.isSecure()).toString()
+            :  portalURL.createNavigationalEncoding(pw, template.getCustomMode(), template.getCustomState());
 
         String linkURL = decoration.getResource("images/" + actionName + ".gif");
 
@@ -48,4 +52,5 @@
 
         return new DecoratorAction(actionName, rc.getLocale(), linkURL, actionURL, customAction);
     }
+        
 }

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java?view=diff&rev=469711&r1=469710&r2=469711
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
Tue Oct 31 16:02:29 2006
@@ -61,6 +61,7 @@
 public class DecorationValve extends AbstractValve implements Valve
 {
     public static final String ACTION_IMAGE_EXTENSION_ATTR = "actionImageExtension";
+    public static final String IS_AJAX_DECORATION_REQUEST = "org.apache.jetspeed.decoration.ajax";
     
     protected final static Log log = LogFactory.getLog(DecorationValve.class);
     
@@ -82,6 +83,12 @@
 
     public void invoke(RequestContext requestContext, ValveContext context) throws PipelineException
     {
+        boolean isAjaxRequest = (context == null);
+        if (isAjaxRequest)
+        {
+            requestContext.setAttribute(IS_AJAX_DECORATION_REQUEST, new Boolean(true));
+        }
+        
         if (requestContext.getRequest().getParameter("clearThemeCache") != null)
         {
             decorationFactory.clearCache(requestContext);
@@ -105,9 +112,12 @@
         
         ContentFragment rootFragment = page.getRootContentFragment();
         
-        initFragment(requestContext, theme, rootFragment, pageActionAccess); 
+        initFragment(requestContext, theme, rootFragment, pageActionAccess, isAjaxRequest);

         
-        context.invokeNext(requestContext);
+        if (!isAjaxRequest)
+        {
+            context.invokeNext(requestContext);
+        }
     }
 
     public String toString()
@@ -156,7 +166,12 @@
      * @throws PortletEntityNotStoredException 
      * @throws FailedToRetrievePortletWindow 
      */
-    protected void initActionsForFragment(RequestContext requestContext, ContentFragment
fragment, PageActionAccess pageActionAccess, Decoration decoration) throws FailedToRetrievePortletWindow,
PortletEntityNotStoredException
+    protected void initActionsForFragment(
+                        RequestContext requestContext, 
+                        ContentFragment fragment, 
+                        PageActionAccess pageActionAccess, 
+                        Decoration decoration,
+                        boolean isAjaxRequest) throws FailedToRetrievePortletWindow, PortletEntityNotStoredException
     {
         PortletWindow window = windowAccessor.getPortletWindow(fragment); 
         PortletDefinitionComposite portlet = (PortletDefinitionComposite) window.getPortletEntity().getPortletDefinition();
@@ -167,14 +182,14 @@
         }
 
         List actions = Collections.EMPTY_LIST;
-
+        
         PortletMode currentMode = requestContext.getPortalURL().getNavigationalState().getMode(window);
         WindowState currentState = requestContext.getPortalURL().getNavigationalState().getState(window);
         ContentTypeSet content = portlet.getContentTypeSet();
         
         if ( fragment.equals(requestContext.getPage().getRootFragment()) )
         {
-            actions = getPageModes(requestContext, window, content, currentMode, currentState,
pageActionAccess, decoration);
+            actions = getPageModes(requestContext, window, content, currentMode, currentState,
pageActionAccess, decoration, isAjaxRequest);
         }
         else if ( !Fragment.LAYOUT.equals(fragment.getType()) )
         {
@@ -250,7 +265,8 @@
      * @throws PortletEntityNotStoredException 
      */
     protected List getPageModes(RequestContext requestContext, PortletWindow window, ContentTypeSet
content, 
-                    PortletMode mode, WindowState state, PageActionAccess pageActionAccess,
Decoration decoration)
+                    PortletMode mode, WindowState state, PageActionAccess pageActionAccess,
Decoration decoration,
+                    boolean isAjaxRequest)
     {
         List pageModes = new ArrayList();
         
@@ -261,7 +277,9 @@
             {
                 // switch back to VIEW mode and NORMAL state.
                 PortalURL portalURL = requestContext.getPortalURL();
-                String action = portalURL.createPortletURL(window, PortletMode.VIEW, WindowState.NORMAL,
portalURL.isSecure()).toString();
+                String action = (isAjaxRequest)
+                  ? portalURL.createNavigationalEncoding(window, PortletMode.VIEW, WindowState.NORMAL)
                         
+                  : portalURL.createPortletURL(window, PortletMode.VIEW, WindowState.NORMAL,
portalURL.isSecure()).toString();
                 String actionName = PortletMode.VIEW.toString();
                 pageModes.add(new DecoratorAction(actionName, requestContext.getLocale(),
decoration.getResource("images/" + actionName + ".gif"),action));
             }
@@ -274,7 +292,9 @@
                 parameters.put("pageMode",paramValues);
 
                 // Use an ActionURL to set the oposite pageMode and always set VIEW mode
and state NORMAL 
-                String action = portalURL.createPortletURL(window, parameters, PortletMode.VIEW,
WindowState.NORMAL, true, portalURL.isSecure()).toString();
+                String action = (isAjaxRequest)
+                    ? portalURL.createNavigationalEncoding(window, parameters, PortletMode.VIEW,
WindowState.NORMAL, true)                                              
+                    : portalURL.createPortletURL(window, parameters, PortletMode.VIEW, WindowState.NORMAL,
true, portalURL.isSecure()).toString();
                 pageModes.add(new DecoratorAction(targetMode, requestContext.getLocale(),
decoration.getResource("images/" + targetMode + ".gif"), action));
                 
                 if (content.supportsPortletMode(PortletMode.HELP))
@@ -283,12 +303,16 @@
                     {
                         // force it back to VIEW mode first with an ActionURL, as well as
setting HELP mode and MAXIMIZED state
                         paramValues[0] = PortletMode.VIEW.toString();
-                        action = portalURL.createPortletURL(window, parameters, PortletMode.HELP,
WindowState.MAXIMIZED, true, portalURL.isSecure()).toString();
+                        action = (isAjaxRequest)
+                            ? portalURL.createNavigationalEncoding(window, parameters, PortletMode.HELP,
WindowState.MAXIMIZED, true)                                                  
+                            : portalURL.createPortletURL(window, parameters, PortletMode.HELP,
WindowState.MAXIMIZED, true, portalURL.isSecure()).toString();
                     }
                     else
                     {
                         // switch to mode HELP and state MAXIMIZED
-                        action = portalURL.createPortletURL(window,PortletMode.HELP, WindowState.MAXIMIZED,
portalURL.isSecure()).toString();
+                        action = (isAjaxRequest)
+                            ? portalURL.createNavigationalEncoding(window, PortletMode.HELP,
WindowState.MAXIMIZED)                        
+                            : portalURL.createPortletURL(window,PortletMode.HELP, WindowState.MAXIMIZED,
portalURL.isSecure()).toString();
                     }
                     String actionName = PortletMode.HELP.toString();
                     pageModes.add(new DecoratorAction(actionName, requestContext.getLocale(),
decoration.getResource("images/" + actionName + ".gif"), action));
@@ -314,7 +338,11 @@
      * @param fragment
      * @param pageActionAccess
      */
-    protected void initFragment(RequestContext requestContext, Theme theme, ContentFragment
fragment, PageActionAccess pageActionAccess) 
+    protected void initFragment(RequestContext requestContext, 
+                                Theme theme, 
+                                ContentFragment fragment, 
+                                PageActionAccess pageActionAccess,
+                                boolean isAjaxRequest)
     {
         final List contentFragments = fragment.getContentFragments();
         
@@ -324,14 +352,14 @@
             while(itr.hasNext())
             {
                 ContentFragment aFragment = (ContentFragment) itr.next();
-                initFragment(requestContext, theme, aFragment, pageActionAccess);
+                initFragment(requestContext, theme, aFragment, pageActionAccess, isAjaxRequest);
             }
         }
         
         try
         {
             fragment.setDecoration(theme.getDecoration(fragment));
-            initActionsForFragment(requestContext, fragment, pageActionAccess, theme.getDecoration(fragment));
+            initActionsForFragment(requestContext, fragment, pageActionAccess, theme.getDecoration(fragment),
isAjaxRequest);
         }
         catch (Exception e)
         {
@@ -340,4 +368,5 @@
        
     }   
 
+    
 }

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/psml.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/psml.vm?view=diff&rev=469711&r1=469710&r2=469711
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/psml.vm
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/ajax-xml/psml.vm
Tue Oct 31 16:02:29 2006
@@ -6,22 +6,27 @@
        #if($prop.Key == "sizes")
           #set($hasSizesProperty=true)
        #end
-	#end
+	    #end
     #if($f.Type == "layout" && ! $hasSizesProperty && $sizes.get($f.Id))
        <property name="sizes" value="$sizes.get($f.Id)" />
     #end
-	#foreach ($pref in $f.Preferences)
+#foreach ($pref in $f.Preferences)
 		<preference name="$pref.Name" readOnly='$pref.isReadOnly()'>		
 		  #foreach ($value in $pref.ValueList)
 		    <value>$value</value>
 		  #end
 		</preference>
 	#end
-    #if($f.Type == "layout")
+#if($f.Type == "layout")
 		#foreach($subf in $f.Fragments)
         #traverseFragments($subf)
 		#end
 	#end
+	#if($f.Type == "portlet")
+	#foreach ($action in $f.decoration.actions)
+     <action name="${action.Name}"  url="${action.Action}"/>    
+#end
+	#end
     </fragment>                                		
 #end
 
@@ -39,9 +44,9 @@
   <title>$page.Title</title>
   <short-title>$page.ShortTitle</short-title>
   
-  #foreach ($meta in $page.Metadata.Fields)
+#foreach ($meta in $page.Metadata.Fields)
 	<metadata name="$meta.Name" xml:lang="$meta.Locale.Language">$meta.Value</metadata>
-  #end
+#end
 
 #if ($fragments == "true")    
   #traverseFragments($page.RootFragment)

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPageAction.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPageAction.java?view=diff&rev=469711&r1=469710&r2=469711
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPageAction.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/GetPageAction.java
Tue Oct 31 16:02:29 2006
@@ -15,10 +15,10 @@
  */
 package org.apache.jetspeed.layout.impl;
 
-import java.util.Map;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -26,15 +26,15 @@
 import org.apache.jetspeed.ajax.AjaxAction;
 import org.apache.jetspeed.ajax.AjaxBuilder;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
+import org.apache.jetspeed.decoration.DecorationValve;
 import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
-import org.apache.jetspeed.om.page.Link;
-import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.request.RequestContext;
-import org.apache.pluto.om.portlet.PortletDefinition;
-import org.apache.pluto.om.common.ParameterSet;
 import org.apache.pluto.om.common.Parameter;
+import org.apache.pluto.om.common.ParameterSet;
+import org.apache.pluto.om.portlet.PortletDefinition;
 
 /**
  * Get Page retrieves a page from the Page Manager store and PSML format
@@ -52,15 +52,18 @@
     protected Log log = LogFactory.getLog(GetPageAction.class);
     
     private PortletRegistry registry;
+    private DecorationValve decorationValve;
     
     public GetPageAction(String template, 
             String errorTemplate, 
             PageManager pageManager,
             PortletActionSecurityBehavior securityBehavior,
-            PortletRegistry registry)
+            PortletRegistry registry,
+            DecorationValve decorationValve)
     {
         super(template, errorTemplate, pageManager, securityBehavior);
         this.registry = registry;
+        this.decorationValve = decorationValve;
     }
 
     public boolean run(RequestContext requestContext, Map resultMap)
@@ -76,7 +79,11 @@
                 success = false;
                 return success;
             }            
-            //String filter = getActionParameter(requestContext, FILTER);
+            
+            // Run the Decoration valve to get actions
+            decorationValve.invoke(requestContext, null);
+            
+            //String filter = getActionParameter(requestContext, FILTER);            
             Page page = requestContext.getPage();
             String pageName = getActionParameter(requestContext, PAGE);
             if (pageName != null)



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message