1 16 17 package org.apache.jetspeed.modules.actions.portlets; 18 19 import org.apache.jetspeed.portal.portlets.VelocityPortlet; 20 21 import org.apache.turbine.util.RunData; 23 24 import org.apache.velocity.context.Context; 26 27 28 36 public class HelloAction extends VelocityPortletAction 37 { 38 39 44 protected void buildMaximizedContext( VelocityPortlet portlet, 45 Context context, 46 RunData rundata ) 47 { 48 buildNormalContext( portlet, context, rundata); 49 50 String text = (String )context.get("text"); 51 52 if (text == null) 53 { 54 text = "Hello World "; 55 } 56 57 context.put("text", text+" (Maximized !)"); 58 } 59 60 65 protected void buildConfigureContext( VelocityPortlet portlet, 66 Context context, 67 RunData rundata ) 68 { 69 70 buildNormalContext( portlet, context, rundata); 71 72 setTemplate(rundata, "hello-customize"); 73 74 } 75 76 80 protected void buildNormalContext( VelocityPortlet portlet, 81 Context context, 82 RunData rundata ) 83 { 84 context.put("text",portlet.getPortletConfig().getInitParameter("text")); 85 } 86 87 public void doUpdate(RunData data, Context context) 88 { 89 String text = data.getParameters().getString("text"); 90 91 if (text!=null) 92 { 93 VelocityPortlet portlet = (VelocityPortlet)context.get("portlet"); 94 portlet.setAttribute("text",text,data); 95 context.put("text",text); 96 context.put("message", "Text successfully updated"); 97 } 98 else 99 { 100 context.put("message", "You must specify a new text"); 101 } 102 } 103 } 104 | Popular Tags |