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 @Override
037 public void processAction(
038 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
039 ActionRequest actionRequest, ActionResponse actionResponse)
040 throws Exception {
041
042 ModuleConfig moduleConfig = getModuleConfig(actionRequest);
043
044 mapping = (ActionMapping)moduleConfig.findActionConfig(
045 getPath(actionRequest));
046
047 PortletAction action = (PortletAction)InstancePool.get(
048 mapping.getType());
049
050 action.processAction(
051 mapping, form, portletConfig, actionRequest, actionResponse);
052 }
053
054 @Override
055 public ActionForward render(
056 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
057 RenderRequest renderRequest, RenderResponse renderResponse)
058 throws Exception {
059
060 ModuleConfig moduleConfig = getModuleConfig(renderRequest);
061
062 mapping = (ActionMapping)moduleConfig.findActionConfig(
063 getPath(renderRequest));
064
065 PortletAction action = (PortletAction)InstancePool.get(
066 mapping.getType());
067
068 return action.render(
069 mapping, form, portletConfig, renderRequest, renderResponse);
070 }
071
072 protected String getPath(PortletRequest portletRequest) throws Exception {
073 return null;
074 }
075
076 }