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