1
19
20 package com.liferay.portlet.pollsdisplay.action;
21
22 import com.liferay.portal.kernel.portlet.BaseConfigurationAction;
23 import com.liferay.portal.kernel.servlet.SessionErrors;
24 import com.liferay.portal.kernel.servlet.SessionMessages;
25 import com.liferay.portal.kernel.util.Constants;
26 import com.liferay.portal.kernel.util.ParamUtil;
27 import com.liferay.portlet.PortletPreferencesFactoryUtil;
28 import com.liferay.portlet.polls.NoSuchQuestionException;
29 import com.liferay.portlet.polls.service.PollsQuestionServiceUtil;
30
31 import javax.portlet.ActionRequest;
32 import javax.portlet.ActionResponse;
33 import javax.portlet.PortletConfig;
34 import javax.portlet.PortletPreferences;
35 import javax.portlet.RenderRequest;
36 import javax.portlet.RenderResponse;
37
38
44 public class ConfigurationActionImpl extends BaseConfigurationAction {
45
46 public void processAction(
47 PortletConfig portletConfig, ActionRequest actionRequest,
48 ActionResponse actionResponse)
49 throws Exception {
50
51 try {
52 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
53
54 if (!cmd.equals(Constants.UPDATE)) {
55 return;
56 }
57
58 long questionId = ParamUtil.getLong(actionRequest, "questionId");
59
60 PollsQuestionServiceUtil.getQuestion(questionId);
61
62 String portletResource = ParamUtil.getString(
63 actionRequest, "portletResource");
64
65 PortletPreferences preferences =
66 PortletPreferencesFactoryUtil.getPortletSetup(
67 actionRequest, portletResource);
68
69 preferences.setValue("question-id", String.valueOf(questionId));
70
71 preferences.store();
72
73 SessionMessages.add(
74 actionRequest, portletConfig.getPortletName() + ".doConfigure");
75 }
76 catch (NoSuchQuestionException nsqe) {
77 SessionErrors.add(actionRequest, nsqe.getClass().getName());
78 }
79 }
80
81 public String render(
82 PortletConfig portletConfig, RenderRequest renderRequest,
83 RenderResponse renderResponse)
84 throws Exception {
85
86 return "/html/portlet/polls_display/configuration.jsp";
87 }
88
89 }