1
22
23 package com.liferay.portlet.myglobaltags.action;
24
25 import com.liferay.portal.kernel.util.Constants;
26 import com.liferay.portal.kernel.util.ParamUtil;
27 import com.liferay.portal.kernel.util.StringUtil;
28 import com.liferay.portal.struts.PortletAction;
29 import com.liferay.portal.util.PortletKeys;
30 import com.liferay.portlet.PortalPreferences;
31 import com.liferay.portlet.PortletPreferencesFactoryUtil;
32 import com.liferay.util.servlet.SessionMessages;
33
34 import javax.portlet.ActionRequest;
35 import javax.portlet.ActionResponse;
36 import javax.portlet.PortletConfig;
37 import javax.portlet.RenderRequest;
38 import javax.portlet.RenderResponse;
39
40 import org.apache.struts.action.ActionForm;
41 import org.apache.struts.action.ActionForward;
42 import org.apache.struts.action.ActionMapping;
43
44
50 public class EditPreferencesAction extends PortletAction {
51
52 public void processAction(
53 ActionMapping mapping, ActionForm form, PortletConfig config,
54 ActionRequest req, ActionResponse res)
55 throws Exception {
56
57 String cmd = ParamUtil.getString(req, Constants.CMD);
58
59 if (!cmd.equals(Constants.UPDATE)) {
60 return;
61 }
62
63 PortalPreferences prefs =
64 PortletPreferencesFactoryUtil.getPortalPreferences(req);
65
66 String[] entries = StringUtil.split(
67 ParamUtil.getString(req, "entries"));
68
69 prefs.setValues(PortletKeys.MY_GLOBAL_TAGS, "entries", entries);
70
71 SessionMessages.add(req, config.getPortletName() + ".doEdit");
72 }
73
74 public ActionForward render(
75 ActionMapping mapping, ActionForm form, PortletConfig config,
76 RenderRequest req, RenderResponse res)
77 throws Exception {
78
79 return mapping.findForward("portlet.my_global_tags.edit");
80 }
81
82 }