portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r425149 - in /portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity: JetspeedPowerTool.java JetspeedPowerToolFactory.java JetspeedPowerToolImpl.java
Date Mon, 24 Jul 2006 19:13:26 GMT
Author: taylor
Date: Mon Jul 24 12:13:25 2006
New Revision: 425149

URL: http://svn.apache.org/viewvc?rev=425149&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-559

Portlets are usually aggregated from the PSML file.
This feature will allow you to place portlets in the decorator templates as well.
The trick here is to get user preferences to work with it, since the portlet will not be associated
with a page. 

Modified:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerTool.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolFactory.java
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerTool.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerTool.java?rev=425149&r1=425148&r2=425149&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerTool.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerTool.java
Mon Jul 24 12:13:25 2006
@@ -255,4 +255,7 @@
      * @param velocityContext
      */
     void setVelocityContext(Context velocityContext);
+    
+    
+    String renderPortletEntity(String entityId, String portletId);
 }

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolFactory.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolFactory.java?rev=425149&r1=425148&r2=425149&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolFactory.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolFactory.java
Mon Jul 24 12:13:25 2006
@@ -19,6 +19,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.aggregator.PortletRenderer;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.services.title.DynamicTitleService;
 
@@ -32,23 +33,30 @@
 
     private DynamicTitleService titleService;
     
-    public JetspeedPowerToolFactory(String jptClassName, DynamicTitleService titleService)
+    /* Allows us to render portlets and other fragments */
+    private PortletRenderer renderer;
+    
+    public JetspeedPowerToolFactory(String jptClassName, DynamicTitleService titleService,
PortletRenderer renderer)
     throws ClassNotFoundException, NoSuchMethodException
     {
         this.jptClassName = jptClassName;
         jptClass = Thread.currentThread().getContextClassLoader().loadClass(jptClassName);
         constructor =
             jptClass.getConstructor(
-                new Class[] {RequestContext.class, DynamicTitleService.class});        
+                new Class[] {RequestContext.class, DynamicTitleService.class, PortletRenderer.class});
       
         this.titleService = titleService;
+        this.renderer = renderer;
     }
     
+    
+    
+    
     public JetspeedPowerTool getJetspeedPowerTool(RequestContext requestContext)
     throws PortletException
     {
         try
         {
-            Object[] initArgs = { requestContext, this.titleService };
+        	Object [] initArgs = { requestContext, this.titleService, this.renderer };
             return (JetspeedPowerTool)constructor.newInstance(initArgs);
         }
         catch (Exception e)

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java?rev=425149&r1=425148&r2=425149&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
Mon Jul 24 12:13:25 2006
@@ -18,6 +18,7 @@
 import java.io.PrintWriter;
 import java.io.Writer;
 import java.security.Principal;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
@@ -37,6 +38,10 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.jetspeed.Jetspeed;
 import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.aggregator.ContentDispatcher;
+import org.apache.jetspeed.aggregator.PortletRenderer;
+import org.apache.jetspeed.aggregator.impl.PortletAggregatorFragmentImpl;
+import org.apache.jetspeed.aggregator.impl.PortletRendererImpl;
 import org.apache.jetspeed.capabilities.CapabilityMap;
 import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
 import org.apache.jetspeed.components.portletentity.PortletEntityNotGeneratedException;
@@ -50,6 +55,8 @@
 import org.apache.jetspeed.locator.TemplateLocator;
 import org.apache.jetspeed.locator.TemplateLocatorException;
 import org.apache.jetspeed.om.page.ContentFragment;
+import org.apache.jetspeed.om.page.ContentFragmentImpl;
+import org.apache.jetspeed.om.page.Fragment;
 import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.services.title.DynamicTitleService;
@@ -128,8 +135,10 @@
     private DynamicTitleService titleService;
     
     private BasePortalURL baseUrlAccess;
+    
+    private PortletRenderer renderer;
 
-    public JetspeedPowerToolImpl(RequestContext requestContext, DynamicTitleService titleService)
throws Exception
+    public JetspeedPowerToolImpl(RequestContext requestContext, DynamicTitleService titleService,PortletRenderer
renderer) throws Exception
     {
         HttpServletRequest request = requestContext.getRequest();
         this.requestContext = requestContext;
@@ -165,6 +174,8 @@
         decorationLocatorDescriptor.setMediaType(capabilityMap.getPreferredMediaType().getName());
         decorationLocatorDescriptor.setCountry(locale.getCountry());
         decorationLocatorDescriptor.setLanguage(locale.getLanguage());
+        
+        this.renderer = renderer;
     }
 
     /**
@@ -843,6 +854,22 @@
         {
             velocityContext.put(name, object);
         }
+    }
+    
+    public String renderPortletEntity(String entityId, String portletId)
+    {
+
+        RequestContext context = getRequestContext();
+
+        PortletAggregatorFragmentImpl fragment = new PortletAggregatorFragmentImpl(
+                entityId);
+        fragment.setType(Fragment.PORTLET);
+        fragment.setName(portletId);
+        ContentFragment contentFragment = new ContentFragmentImpl(fragment,
+                new HashMap());
+        //renderer.renderNow(contentFragment, context);
+        renderer.render(contentFragment, context);
+        return contentFragment.getRenderedContent();
     }
 
 }



---------------------------------------------------------------------
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