001
014
015 package com.liferay.portlet.blogsaggregator.action;
016
017 import com.liferay.portal.kernel.portlet.BaseConfigurationAction;
018 import com.liferay.portal.kernel.servlet.SessionMessages;
019 import com.liferay.portal.kernel.util.Constants;
020 import com.liferay.portal.kernel.util.ParamUtil;
021 import com.liferay.portlet.PortletPreferencesFactoryUtil;
022
023 import javax.portlet.ActionRequest;
024 import javax.portlet.ActionResponse;
025 import javax.portlet.PortletConfig;
026 import javax.portlet.PortletPreferences;
027 import javax.portlet.RenderRequest;
028 import javax.portlet.RenderResponse;
029
030
033 public class ConfigurationActionImpl extends BaseConfigurationAction {
034
035 public void processAction(
036 PortletConfig portletConfig, ActionRequest actionRequest,
037 ActionResponse actionResponse)
038 throws Exception {
039
040 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
041
042 if (!cmd.equals(Constants.UPDATE)) {
043 return;
044 }
045
046 String selectionMethod = ParamUtil.getString(
047 actionRequest, "selectionMethod");
048 String organizationId = ParamUtil.getString(
049 actionRequest, "organizationId");
050 String displayStyle = ParamUtil.getString(
051 actionRequest, "displayStyle");
052 int max = ParamUtil.getInteger(actionRequest, "max");
053 boolean enableRssSubscription = ParamUtil.getBoolean(
054 actionRequest, "enableRssSubscription");
055 boolean showTags = ParamUtil.getBoolean(
056 actionRequest, "showTags");
057
058 String portletResource = ParamUtil.getString(
059 actionRequest, "portletResource");
060
061 PortletPreferences preferences =
062 PortletPreferencesFactoryUtil.getPortletSetup(
063 actionRequest, portletResource);
064
065 preferences.setValue("selection-method", selectionMethod);
066 preferences.setValue("organization-id", organizationId);
067 preferences.setValue("display-style", displayStyle);
068 preferences.setValue("max", String.valueOf(max));
069 preferences.setValue(
070 "enable-rss-subscription", String.valueOf(enableRssSubscription));
071 preferences.setValue("show-tags", String.valueOf(showTags));
072
073 preferences.store();
074
075 SessionMessages.add(
076 actionRequest, portletConfig.getPortletName() + ".doConfigure");
077 }
078
079 public String render(
080 PortletConfig portletConfig, RenderRequest renderRequest,
081 RenderResponse renderResponse)
082 throws Exception {
083
084 return "/html/portlet/blogs_aggregator/configuration.jsp";
085 }
086
087 }