2 Replies Latest reply on Oct 4, 2005 4:25 PM by alex2807

    Portlet initialization problem

    alex2807

      Hi,
      maybe this is a silly question, but I'm a newbie on portlets and JBoss portal. I have a simple portlet for database queries. In this portlet I will init the URLs of the related JSPs via init params in the portlet.xml.

      This is my portlet.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
       version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
      
       <portlet>
       <description>A portlet for DB queries.</description>
       <portlet-name>query_portlet</portlet-name>
       <display-name>Query Portlet</display-name>
       <portlet-class>org.mindquarry.portal.portlets.QueryPortlet</portlet-class>
      
       <init-param>
       <name>view_url
       </name>
       <value>/jsp/view.jsp
       </value>
       </init-param>
      
       <init-param>
       <name>edit_url
       </name>
       <value>/jsp/edit.jsp
       </value>
       </init-param>
      
       <init-param>
       <name>help_url
       </name>
       <value>/jsp/help.jsp
       </value>
       </init-param>
      
       <supports>
       <mime-type>text/html</mime-type>
       <portlet-mode>edit</portlet-mode>
       <portlet-mode>view</portlet-mode>
       <portlet-mode>help</portlet-mode>
       </supports>
      
       <supported-locale>en</supported-locale>
      
       <portlet-info>
       <title>A Query Portlet for execution of DB queries.</title>
       <short-title>Query Portlet</short-title>
       </portlet-info>
      
       <portlet-preferences>
       <preference>
       <name>title</name>
       <value>Query Portlet</value>
       </preference>
      
       ...
       <preferences-validator>org.mindquarry.portal.portlets.QueryPreferencesValidator</preferences-validator>
       </portlet-preferences>
       </portlet>
      </portlet-app>
      


      This is my portlet class:
      public class QueryPortlet extends GenericPortlet {
       private String viewUrl;
       private String editUrl;
       private String helpUrl;
      
       public void init(PortletConfig config) throws PortletException {
       super.init(config);
      
       // after these lines viewUrl ... are NULL
       viewUrl = config.getInitParameter("view_url");
       editUrl = config.getInitParameter("edit_url");
       helpUrl = config.getInitParameter("help_url");
       }
      ...
      }
      


      The portlet itself works fine, but after execution of init() the URL members are NULL. I debugged this problem with the JBossIDE and found out that the init param values and keys are available in the PortletConfig. But the problem remains!

      Because init params are not considered in the HelloWorld example, I looked at the forums portlet. In the forums portlet they use JBossPortlet instead of GenericPortlet as base class for the portlet implementation.

      So finally my question is: Is it necessary to use JBossPortlet instead of GenericPortlet to get the init param values or is there another trick to get this work?

      Best regards,
      Alexxx