1 package org.apache.jetspeed.portal.portlets; 2 3 import org.apache.turbine.util.RunData; 5 import org.apache.turbine.services.velocity.TurbineVelocity; 6 import org.apache.turbine.modules.ActionLoader; 7 8 import org.apache.jetspeed.portal.Portlet; 10 import org.apache.jetspeed.portal.portlets.AbstractPortlet; 11 import org.apache.jetspeed.portal.PortletException; 12 13 import org.apache.ecs.ConcreteElement; 15 import org.apache.ecs.StringElement; 16 17 import org.apache.velocity.context.Context; 19 20 import org.apache.turbine.util.Log; 21 22 23 48 public class VTLPortlet extends AbstractVTLPortlet 49 { 50 public ConcreteElement getContent( RunData rundata ) 51 { 52 String template = rundata.getParameters().getString ( "vtlTemplate", null ); 54 if( template == null ) 55 { 56 template = this.getPortletConfig().getInitParameter( "vtlTemplate" ); 57 } 58 59 Context context = TurbineVelocity.getContext(); 61 context.put( "portlet", this ); 62 context.put( "vtlTemplate", template ); 63 rundata.getTemplateInfo().setTemplateContext( "VTLPortletContext", context ); 64 65 try 68 { 69 ActionLoader.getInstance().exec( rundata, "portlets." + template.replace(',', '.') ); 70 } 71 catch( Exception e) 72 { 73 } 75 76 String s = ""; 78 if( isButtonMaximize( rundata ) || isButtonConfigure( rundata ) || !isMinimized( rundata ) ) 79 { 80 template = ( (String )context.get( "vtlTemplate" ) ).replace(',', '/'); 82 83 try 85 { 86 s = TurbineVelocity.handleRequest(context, "portlets/" + template + ".vm"); 87 } 88 catch( Exception e) 89 { 90 s= e.toString(); 91 } 92 } 93 94 return new StringElement( s ); 95 } 96 97 98 } 99 100 | Popular Tags |