001
014
015 package com.liferay.portal.struts;
016
017 import com.liferay.portal.kernel.util.InstancePool;
018
019 import javax.portlet.ActionRequest;
020 import javax.portlet.ActionResponse;
021 import javax.portlet.PortletConfig;
022 import javax.portlet.PortletRequest;
023 import javax.portlet.RenderRequest;
024 import javax.portlet.RenderResponse;
025
026 import org.apache.struts.action.ActionForm;
027 import org.apache.struts.action.ActionForward;
028 import org.apache.struts.action.ActionMapping;
029 import org.apache.struts.config.ModuleConfig;
030
031
034 public class DynamicPortletAction extends PortletAction {
035
036 public void processAction(
037 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
038 ActionRequest actionRequest, ActionResponse actionResponse)
039 throws Exception {
040
041 ModuleConfig moduleConfig = getModuleConfig(actionRequest);
042
043 mapping = (ActionMapping)moduleConfig.findActionConfig(
044 getPath(actionRequest));
045
046 PortletAction action = (PortletAction)InstancePool.get(
047 mapping.getType());
048
049 action.processAction(
050 mapping, form, portletConfig, actionRequest, actionResponse);
051 }
052
053 public ActionForward render(
054 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
055 RenderRequest renderRequest, RenderResponse renderResponse)
056 throws Exception {
057
058 ModuleConfig moduleConfig = getModuleConfig(renderRequest);
059
060 mapping = (ActionMapping)moduleConfig.findActionConfig(
061 getPath(renderRequest));
062
063 PortletAction action = (PortletAction)InstancePool.get(
064 mapping.getType());
065
066 return action.render(
067 mapping, form, portletConfig, renderRequest, renderResponse);
068 }
069
070 protected String getPath(PortletRequest portletRequest) throws Exception {
071 return null;
072 }
073
074 }