BLOG: Web Content Management

Welcome to Oshyn’s Web Content Management Blog where our experts discuss the latest developments and best practices in the Content Management industry with a focus on several leading platforms: Drupal, EPiServer, Jahia, Open Text and Sitecore.

Jahia WCM JSR-168 Portlets Development

Jahia WCM JSR-168 Portlets Development

Juan Pablo Albuja... - Tuesday, December 22, 2009

In this post I will explain a way to develop portlets, compile with Maven 2, and deploy to Jahia Version 6. A Portlet is a web based application described by the Java specification JSR168. Jahia has the capability of integrating portlets by using their powerful Mashups Manager Tool. The idea of this integration is to run web applications embedded in a Jahia site without accessing another website to create dynamic content.

Portlet Development

  1. The first step is to create a standard Maven 2 project structure. To create that structure we need to run the archetype mvn archetype:generate, chose option 13 for portlets and fill the group id, artifactid, version and package.
  2. Change your pom.xml and make it look similar to this one.
  3. Open the portlet.xml and fill the portlet info section with your own data. Here Sample.
  4. Modify web.xml and makes it look like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    </web-app>


    For this example we are not using more additional web resources than portlets.

  5. Rename the file MyPortlet.java existing in src/main/java to HelloPortlet.java and paste the following code:
  6. package com.mycompany.portlet;

    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.Locale;
    import java.util.ResourceBundle;

    import javax.portlet.ActionRequest;
    import javax.portlet.ActionResponse;
    import javax.portlet.GenericPortlet;
    import javax.portlet.PortletConfig;
    import javax.portlet.PortletException;
    import javax.portlet.RenderRequest;
    import javax.portlet.RenderResponse;

    /**
     * Hello World Portlet
     */
    public class HelloPortlet extends GenericPortlet {

        public void doView(RenderRequest req, RenderResponse res)
            throws IOException, PortletException {

            PrintWriter out = res.getWriter();
            out.println("<h2>");
            out.println("Hello World");
            out.println("</h2>");
        }

        public void processAction(ActionRequest req, ActionResponse res)
            throws IOException, PortletException {
        }
        
    }

  7. Compile the project using Maven with the command mvn install
  8. Copy the generated war in the deploy folder of you application server, in case of tomcat paste the generated war into webapps folder.

Portlet Configuration in Jahia 6

  1. Login into Jahia administration and open the Mashup Manager Tool.
  2. Press the button Add new mushup and the following screen will appear.

  3. Click the HelloPortlet and press next.
  4. In the next step add a Title, Description, Keywords, Categories and a Thumbnail.
  5. Continue the wizard till complete it.
  6. Now the Portlet is ready and can be used in any portlet field created in your project.

Portlet.xml Configuration File

Let’s take a deeper view to the Portlet.xml file. This file is a deployment descriptor file that contains configuration details about portlets. Following is an example of this file with an explanation of it.

<portlet-app>
<portlet>
        <description>Write here a short description about your portlet.</description>
        <portlet-name>HelloPortlet</portlet-name>
        <display-name>HelloPortlet Portlet</display-name>

        <portlet-class>com.mycompany.portlet.HelloPortlet</portlet-class>

        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>VIEW</portlet-mode>
        </supports>

        <supported-locale>en</supported-locale>

        <portlet-info>
            <title>Hello Portlet</title>
            <short-title>Hello Portlet</short-title>
            <keywords>Hello Portlet</keywords>
        </portlet-info>
</portlet>
</portlet-app

  • The tag portlet contains the portlet definition.
  • The description tag is an information tag that contains the description of the portlet.
  • The portlet-name tag identifies the portlet within the portlet application.
  • The display-name tag is the name of the portlet in our portal; this name is going to appear in the Mashup Manager Tool in Jahia.
  • The portlet-class tag represents the fully qualified class name of the portlet. This class contains all the logic of the portlet.
  • The tag supports provide information about which portlets modes are supported.
  • The portlet-info tag contains information of the portlet and can be overridden in the resource boundle. The keywords are used by portals for searching and locating portlets.

Click here to download the complete source code.

ajax rotator
Recent Posts

RSS feeds
Tag cloud
scalability cookie-free domain management ajax push profile box template design Dynamic Data CMS usability Ubuntu Server postgis web content management java software design reddot deployment search engine industry challenges open source editing content Ubercart asp opentext web marketing VB E-commerce configuration management sitecore layout consulting design frontend optimization ipc mobile sitecore devices sales 2.0 theming google search appliance jsp command line HubSpot open text liveserver EPiServer inbound marketing .net AS3 Acquia profile tab ui web development los angeles Active Directory fbml mashups mashup mashware release management content management white paper content authors print Delivery Server APC ubuntu web2.0 Sitecore Active Directory campaigns communicating Live Server oms open-source patterns lead generation dynament target dynament web design los angeles open text delivery server ajax GSA sitecore meetup cluster CRM icefaces geo cloud computing sitecore ECM LiveServer reddot cms higher education rdbs marketing enterprise code design VS2010 google maps optimization cms white paper google analytics web design call to action Database concrete5 data access SEO memcache search suggest reddot cms twitter friendly url performance social media webcomponent Navigation reddot whitepaper web marketing for dummies web evolution MVC Actionscript 3 location Visual Studio web3.0 sitecore user group html CTA cms los angeles Maven social 2.0 tools url jahia cms facebook content authoring design patterns OO Development sitecore email campaign manager modules LDAP jahia wcm SMM portal Sharepoint javascript VPP oshyn reddot higher education ASP.NET sitecore online marketing suite, online marketing suite Marketing Automation IIS tuckey lucene Jahia website design los angeles open text cms development redundant database structure iphone Velocity multilingual thoughts drush boost architecture IT Investment tuning css cloud liferay JSR-168 WCM Design Patterns jquery facebook app, OS 3.0, three20 CMS cms whitepaper content management systems content mangement presentation layer wcm drools Sitecore linux facebook developers open text web solutions sitecore oms keyword selection Web development spatial php social network project management online marketing keywords google open text LS cms los angeles, content management los angeles, web development los angeles, website design los angeles, web design los angeles, sitecore meetup, sitecore user group Flash web services geographical new sites RFP portlets EPiServer Active Directory plugin ASP.NET MVC jquery, jquery plugin multisite reddot white paper open text management server lead management licencing content management los angeles mysql integration higher education content management whitepaper missing images google appEngine Business Users GIS php5 foursquare Solr Visual Basic CMS Training Drupal templating
2010 Copyright Oshyn. All rights reserved.