1
22
23 package com.liferay.portlet.announcements.action;
24
25 import com.liferay.portal.kernel.language.LanguageUtil;
26 import com.liferay.portal.kernel.util.Validator;
27 import com.liferay.portal.struts.PortletAction;
28 import com.liferay.portlet.announcements.AnnouncementsContentException;
29 import com.liferay.util.LocalizationUtil;
30
31 import javax.portlet.PortletConfig;
32 import javax.portlet.PortletPreferences;
33 import javax.portlet.RenderRequest;
34 import javax.portlet.RenderResponse;
35
36 import org.apache.struts.action.ActionForm;
37 import org.apache.struts.action.ActionForward;
38 import org.apache.struts.action.ActionMapping;
39
40
46 public class ViewAction extends PortletAction {
47
48 public ActionForward render(
49 ActionMapping mapping, ActionForm form, PortletConfig config,
50 RenderRequest req, RenderResponse res)
51 throws Exception {
52
53 try {
54 PortletPreferences prefs = req.getPreferences();
55
56 String languageId = LanguageUtil.getLanguageId(req);
57
58 String content = LocalizationUtil.getPrefsValue(
59 prefs, "content", languageId);
60
61 if (Validator.isNull(content)) {
62 throw new AnnouncementsContentException();
63 }
64
65 return mapping.findForward("portlet.announcements.view");
66 }
67 catch (AnnouncementsContentException ace) {
68 return mapping.findForward("/portal/portlet_not_setup");
69 }
70 }
71
72 }