1 9 package org.jboss.portal.core.portlet; 10 11 import java.util.Locale ; 12 import java.util.ResourceBundle ; 13 14 import org.jboss.logging.Logger; 15 import org.jboss.portal.core.servlet.jsp.PortalJsp; 16 import org.jboss.portlet.JBossActionRequest; 17 import org.jboss.portlet.JBossActionResponse; 18 import org.jboss.portlet.JBossPortlet; 19 20 23 public class PortletHelper 24 { 25 private Logger log = Logger.getLogger(PortalJsp.class); 26 27 private JBossPortlet portlet; 28 29 public PortletHelper(JBossPortlet portlet) 30 { 31 this.portlet = portlet; 32 } 33 34 public void setRenderParameter(JBossActionResponse resp, String key, String value) 35 { 36 if (value != null) 37 { 38 resp.setRenderParameter(key, value); 39 } 40 } 41 42 public void setI18nRenderParameter(JBossActionRequest req, JBossActionResponse resp, String key, String value) 43 { 44 if (value != null) 45 { 46 Locale locale = req.getLocale(); 47 ResourceBundle bundle = portlet.getResourceBundle(locale); 48 try 49 { 50 resp.setRenderParameter(key, bundle.getString(value)); 51 } 52 catch (Exception e) 53 { 54 log.error("Cannot find language key: " + key); 55 resp.setRenderParameter(key, value); 56 } 57 } 58 } 59 } | Popular Tags |