1 16 24 package org.apache.jetspeed.modules.actions.portlets; 25 26 import org.apache.jetspeed.portal.Portlet; 27 import org.apache.jetspeed.portal.portlets.GenericMVCPortlet; 28 import org.apache.jetspeed.util.PortletSessionState; 29 import org.apache.turbine.util.RunData; 30 import org.apache.velocity.context.Context; 31 32 33 34 35 49 50 51 59 public abstract class PortletAction 60 extends PortletActionEvent 61 { 62 63 64 public PortletAction() 65 { 66 } 67 68 public void doPerform(RunData data) 69 throws Exception 70 { 71 72 doPerform(data, getContext(data)); 75 } 76 77 85 public abstract void doPerform(RunData data, Context context) 86 throws Exception ; 87 88 94 protected Context getContext(RunData data) 95 { 96 97 return (Context) data.getTemplateInfo().getTemplateContext("VelocityPortletContext"); 98 } 99 100 108 public void setTemplate(RunData data, String template) 109 { 110 setTemplate(data, template, false); 111 } 112 113 129 public void setTemplate(RunData data, String template, boolean persistent) 130 { 131 Portlet portlet = getPortlet(getContext(data)); 132 133 if (template != null) 134 { 135 if (persistent) 136 { 137 PortletSessionState.setAttribute( 138 portlet, 139 data, 140 GenericMVCPortlet.TEMPLATE, 141 template); 142 } 143 else 144 { 145 resetTemplate(data); 147 } 148 149 getContext(data).put("template", template); 152 } 153 154 } 155 156 160 protected void resetTemplate(RunData data) 161 { 162 Portlet portlet = getPortlet(getContext(data)); 163 PortletSessionState.clearAttribute(portlet, data, GenericMVCPortlet.PORTLET); 164 } 165 166 167 168 public Portlet getPortlet(Context context) 169 { 170 return (Portlet) context.get(GenericMVCPortlet.PORTLET); 171 } 172 184 public String getTemplate(Context context) 185 { 186 187 return (String ) context.get(GenericMVCPortlet.TEMPLATE); 188 } 189 190 protected abstract void buildConfigureContext(Portlet portlet, Context context, RunData data) 191 throws Exception ; 192 193 protected abstract void buildMaximizedContext(Portlet portlet, Context context, RunData data) 194 throws Exception ; 195 196 protected abstract void buildNormalContext(Portlet portlet, Context context, RunData data) 197 throws Exception ; 198 } 199 | Popular Tags |