001
014
015 package com.liferay.portlet.pollsdisplay.action;
016
017 import com.liferay.portal.kernel.portlet.BaseConfigurationAction;
018 import com.liferay.portal.kernel.servlet.SessionErrors;
019 import com.liferay.portal.kernel.servlet.SessionMessages;
020 import com.liferay.portal.kernel.util.Constants;
021 import com.liferay.portal.kernel.util.ParamUtil;
022 import com.liferay.portlet.PortletPreferencesFactoryUtil;
023 import com.liferay.portlet.polls.NoSuchQuestionException;
024 import com.liferay.portlet.polls.service.PollsQuestionServiceUtil;
025
026 import javax.portlet.ActionRequest;
027 import javax.portlet.ActionResponse;
028 import javax.portlet.PortletConfig;
029 import javax.portlet.PortletPreferences;
030 import javax.portlet.RenderRequest;
031 import javax.portlet.RenderResponse;
032
033
036 public class ConfigurationActionImpl extends BaseConfigurationAction {
037
038 public void processAction(
039 PortletConfig portletConfig, ActionRequest actionRequest,
040 ActionResponse actionResponse)
041 throws Exception {
042
043 try {
044 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
045
046 if (!cmd.equals(Constants.UPDATE)) {
047 return;
048 }
049
050 long questionId = ParamUtil.getLong(actionRequest, "questionId");
051
052 PollsQuestionServiceUtil.getQuestion(questionId);
053
054 String portletResource = ParamUtil.getString(
055 actionRequest, "portletResource");
056
057 PortletPreferences preferences =
058 PortletPreferencesFactoryUtil.getPortletSetup(
059 actionRequest, portletResource);
060
061 preferences.setValue("question-id", String.valueOf(questionId));
062
063 preferences.store();
064
065 SessionMessages.add(
066 actionRequest, portletConfig.getPortletName() + ".doConfigure");
067 }
068 catch (NoSuchQuestionException nsqe) {
069 SessionErrors.add(actionRequest, nsqe.getClass().getName());
070 }
071 }
072
073 public String render(
074 PortletConfig portletConfig, RenderRequest renderRequest,
075 RenderResponse renderResponse)
076 throws Exception {
077
078 return "/html/portlet/polls_display/configuration.jsp";
079 }
080
081 }