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 2001/06/04 09:45:48 UTC

cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/customize CustomizePortlet.java

taylor      01/06/04 00:45:48

  Modified:    src/java/org/apache/jetspeed/portal/portlets/customize
                        CustomizePortlet.java
  Log:
  updated customizer to work with .vm templates
  
  Revision  Changes    Path
  1.11      +34 -5     jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/customize/CustomizePortlet.java
  
  Index: CustomizePortlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/customize/CustomizePortlet.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- CustomizePortlet.java	2001/05/29 22:57:49	1.10
  +++ CustomizePortlet.java	2001/06/04 07:45:47	1.11
  @@ -64,6 +64,7 @@
   import org.apache.jetspeed.portal.*;
   
   import org.apache.jetspeed.profiler.*;
  +import org.apache.jetspeed.services.Profiler;
   
   import org.apache.jetspeed.util.*;
   
  @@ -72,6 +73,8 @@
   
   //turbine stuff
   import org.apache.turbine.util.*;
  +import org.apache.turbine.services.velocity.TurbineVelocity;
  +import org.apache.velocity.context.Context;
   
   //java stuff
   import java.util.*;
  @@ -99,7 +102,9 @@
      /** id of the bean put into the request */
      public static final String BEAN_ID = "databean";
   
  -   private static final String JSP_PARAMETER = "jsp_location";        
  +   private static final String JSP_PARAMETER = "jsp_location";
  +   private static final String VM_PARAMETER = "vm_location";
  +   private static final String USE_TEMPLATE = "template";
      private static final String MAX_NUMBER_PARAMETER = "customization_max_number";
      
      /**  parameter to call the first page */
  @@ -292,11 +297,35 @@
           sun.misc.Sort.quicksort( portletDataBeans, new PortletDataBeanCompare());        
           bean.setHomeURL( homeURL ) ;
           bean.setPage2URL( page2URL ) ;
  -    
  -        data.getRequest( ).setAttribute( BEAN_ID, bean ) ;
  +
  +        String useTemplate = this.getPortletConfig( ).getInitParameter( USE_TEMPLATE );
  +        if (null == useTemplate || useTemplate.equals("vm"))
  +        {
  +            // generate the content
  +            String s = null;
  +            Context context = TurbineVelocity.getContext();
       
  -        EcsServletElement element = new EcsServletElement( data, this.getPortletConfig( ).getInitParameter( JSP_PARAMETER ) );
  -        return element;
  +            try
  +            {
  +                context.put( BEAN_ID, bean );
  +                String template = this.getPortletConfig().getInitParameter( VM_PARAMETER );
  +                if (-1 == template.indexOf(".vm"))
  +                    template = template + ".vm";
  +                String templatePath = Profiler.locatePortletTemplate(data, template);
  +                s = TurbineVelocity.handleRequest(context, templatePath);
  +            }
  +            catch( Exception e)
  +            {
  +                s= e.toString();
  +            }
  +            return new StringElement( s );
  +        }
  +        else
  +        {
  +            data.getRequest( ).setAttribute( BEAN_ID, bean ) ;
  +            EcsServletElement element = new EcsServletElement( data, this.getPortletConfig( ).getInitParameter( JSP_PARAMETER ) );
  +            return element;
  +        }
       
       }                           
   
  
  
  

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