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