You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2006/07/26 21:46:11 UTC
svn commit: r425816 - in
/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout:
ajax-xml/psml.vm impl/Constants.java impl/GetPageAction.java
Author: taylor
Date: Wed Jul 26 12:46:11 2006
New Revision: 425816
URL: http://svn.apache.org/viewvc?rev=425816&view=rev
Log:
To support client-side aggregation in desktop, the "sizes" property for a layout fragment will be retrieved
from the layout-portlet init-parameters when it is not explicitly specified is the psml.
This means that layout fragments in the GetPageAction psml response will contain a "sizes"
property regardless of whether it is defined in the actual psml.
from Steve Milek
Modified:
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/Constants.java
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/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?rev=425816&r1=425815&r2=425816&view=diff
==============================================================================
--- 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 Wed Jul 26 12:46:11 2006
@@ -1,8 +1,15 @@
#macro (traverseFragments $f)
<fragment id="$f.Id" type="$f.Type" name="$f.Name" decorator="$!f.Decorator">
+ #set($hasSizesProperty=false)
#foreach ($prop in $f.getProperties().entrySet())
<property name="$prop.Key" value="$prop.Value" />
+ #if($prop.Key == "sizes")
+ #set($hasSizesProperty=true)
+ #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)
<preference name="$pref.Name" readOnly='$pref.isReadOnly()'>
#foreach ($value in $pref.ValueList)
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java?rev=425816&r1=425815&r2=425816&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/layout/impl/Constants.java Wed Jul 26 12:46:11 2006
@@ -55,6 +55,7 @@
public static final String PAGES = "pages";
public static final String PAGE = "page";
public static final String FOLDER = "folder";
+ public static final String SIZES = "sizes";
public static final String STANDARD_MENUS = "standardMenus";
public static final String CUSTOM_MENUS = "customMenus";
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?rev=425816&r1=425815&r2=425816&view=diff
==============================================================================
--- 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 Wed Jul 26 12:46:11 2006
@@ -16,16 +16,24 @@
package org.apache.jetspeed.layout.impl;
import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Iterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.jetspeed.JetspeedActions;
import org.apache.jetspeed.ajax.AjaxAction;
import org.apache.jetspeed.ajax.AjaxBuilder;
+import org.apache.jetspeed.components.portletregistry.PortletRegistry;
import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.om.page.Fragment;
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;
/**
* Get Page retrieves a page from the Page Manager store and PSML format
@@ -42,12 +50,16 @@
{
protected Log log = LogFactory.getLog(GetPageAction.class);
+ private PortletRegistry registry;
+
public GetPageAction(String template,
String errorTemplate,
PageManager pageManager,
- PortletActionSecurityBehavior securityBehavior)
+ PortletActionSecurityBehavior securityBehavior,
+ PortletRegistry registry)
{
super(template, errorTemplate, pageManager, securityBehavior);
+ this.registry = registry;
}
public boolean run(RequestContext requestContext, Map resultMap)
@@ -67,6 +79,9 @@
Page page = requestContext.getPage();
resultMap.put(STATUS, status);
resultMap.put(PAGE, page);
+ Map fragSizes = new HashMap();
+ retrieveLayoutFragmentSizes( page.getRootFragment(), fragSizes );
+ resultMap.put( SIZES, fragSizes );
}
catch (Exception e)
{
@@ -80,5 +95,67 @@
return success;
}
-
+ protected void retrieveLayoutFragmentSizes( Fragment frag, Map fragSizes )
+ {
+ if ( frag != null && "layout".equals( frag.getType() ) )
+ {
+ String sizesVal = frag.getProperty( "sizes" );
+ if ( sizesVal == null || sizesVal.length() == 0 )
+ {
+ String layoutName = frag.getName();
+ if ( layoutName != null && layoutName.length() > 0 )
+ {
+ // logic below is copied from org.apache.jetspeed.portlets.MultiColumnPortlet
+ PortletDefinition portletDef = registry.getPortletDefinitionByUniqueName(frag.getName());
+ ParameterSet paramSet = portletDef.getInitParameterSet();
+ Parameter sizesParam = paramSet.get( "sizes" );
+ String sizesParamVal = ( sizesParam == null ) ? null : sizesParam.getValue();
+ if ( sizesParamVal != null && sizesParamVal.length() > 0 )
+ {
+ fragSizes.put( frag.getId(), sizesParamVal );
+ //log.info( "GetPageAction settings sizes for " + frag.getId() + " to " + sizesParamVal);
+ }
+ else
+ {
+ Parameter colsParam = paramSet.get( "columns" );
+ String colsParamVal = ( colsParam == null ) ? null : colsParam.getValue();
+ if ( colsParamVal != null && colsParamVal.length() > 0 )
+ {
+ int cols = 0;
+ try
+ {
+ cols = Integer.parseInt( colsParamVal );
+ }
+ catch ( NumberFormatException ex )
+ {
+ }
+ if ( cols < 1 )
+ {
+ cols = 2;
+ }
+ switch (cols)
+ {
+ case 1: sizesParamVal = "100%"; break;
+ case 2: sizesParamVal = "50%,50%"; break;
+ case 3: sizesParamVal = "34%,33%,33%"; break;
+ default: sizesParamVal = "50%,50%"; break;
+ }
+ fragSizes.put( frag.getId(), sizesParamVal );
+ //log.info( "GetPageAction defaulting sizes for " + frag.getId() + " to " + sizesParamVal);
+ }
+ }
+ }
+ }
+ List childFragments = frag.getFragments();
+ if ( childFragments != null )
+ {
+ Iterator childFragIter = childFragments.iterator();
+ while ( childFragIter.hasNext() )
+ {
+ Fragment childFrag = (Fragment)childFragIter.next();
+ retrieveLayoutFragmentSizes( childFrag, fragSizes );
+ }
+ }
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org