Thursday, January 15, 2009

Cleaning a Portlet for Widespread Adoption

The things that need to happen before a portlet is "clean" for widespread adoption are: * Remove portlet.tld file(s) from portlet project (then use uPortal deployPortletApp which will either include it in the war, or pluto-1.0.1-rc3.jar and later include portlet.tld) * Remove any servlet element from web.xml of the portlet that is autogenerated by Pluto (be careful to not remove any other needed ones. it contains the text Automated generated Portlet Wrapper)
<servlet>
    <servlet-name>myportlet</servlet-name>
    <display-name>myportlet Wrapper</display-name>
    <description>Automated generated Portlet Wrapper</description>
    <servlet-class>org.apache.pluto.core.PortletServlet</servlet-class>
    <init-param>
        <param-name>portlet-class</param-name>
        <param-value>org.springframework.web.portlet.DispatcherPortlet</param-value>
    </init-param>
    <init-param>
        <param-name>portlet-guid</param-name>
        <param-value>myportlet.myportlet</param-value>
    </init-param>
</servlet>
* Remove any servlet-mapping from web.xml of the portlet that is autogenerated by Pluto (be careful to not remove any other needed ones. it has a url-pattern like "/warname/*" I think)
<servlet-mapping>
    <servlet-name>myportlet</servlet-name>
    <url-pattern>/myportlet/*</url-pattern>
</servlet-mapping>
* Be sure to remove the following from the web.xml, as it is not needed. (Eric says it is autodiscovered):
<taglib>                                                                                                                                                                                                                                                                      
   <taglib-uri>http://java.sun.com/portlet</taglib-uri>                                                                                                                                                                                                                      
   <taglib-location>/WEB-INF/tld/portlet.tld</taglib-location>                                                                                                                                                                                                               
</taglib>
If you get the following from JSPC (if you use it):
[INFO] [jspc:compile {execution: jspc}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] JSPC Error

Embedded error: File "/WEB-INF/tld/portlet.tld" not found
be sure to remove the following from web.xml:
<taglib>                                                                                                                                                                                                                                                                      
   <taglib-uri>http://java.sun.com/portlet</taglib-uri>                                                                                                                                                                                                                      
   <taglib-location>/WEB-INF/tld/portlet.tld</taglib-location>                                                                                                                                                                                                               
</taglib>
Thanks, Eric! References: * https://issues.apache.org/jira/browse/PLUTO-89

No comments: