KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > core > portlet > PortletHelper


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.core.portlet;
10
11 import java.util.Locale JavaDoc;
12 import java.util.ResourceBundle JavaDoc;
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 /**
21  * @author <a HREF="theute@jboss.org">Thomas Heute </a> $Revision: 1.5 $
22  */

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 JavaDoc key, String JavaDoc value)
35    {
36       if (value != null)
37       {
38          resp.setRenderParameter(key, value);
39       }
40    }
41
42    public void setI18nRenderParameter(JBossActionRequest req, JBossActionResponse resp, String JavaDoc key, String JavaDoc value)
43    {
44       if (value != null)
45       {
46          Locale JavaDoc locale = req.getLocale();
47          ResourceBundle JavaDoc bundle = portlet.getResourceBundle(locale);
48          try
49          {
50             resp.setRenderParameter(key, bundle.getString(value));
51          }
52          catch (Exception JavaDoc e)
53          {
54             log.error("Cannot find language key: " + key);
55             resp.setRenderParameter(key, value);
56          }
57       }
58    }
59 }
Popular Tags