Hello World Portlet

Now that you have set up Eclipse, create a portlet in the Eclipse Java perspective. Go to the jetexpress-pa project, click on the org.apache.portals.tutorials package, and create a new Java class BonjourMonde:

You will see a new portlet in Eclipse named BonjourMonde. Go ahead and implement the following methods:

Each one of these methods is associated with a portlet mode. Lets make these methods actually do something. Since we are in the render phase when doView/doEdit/doHelp are called, its probably best to render something. The RenderResponse renders content to the output stream of the portlet. Set the content type on the response, and then print a hello world message using a Java Writer:

protected void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
    response.getWriter().println("<b>Bonjour: View Mode</b>");

Repeat the same process for Edit and Help modes.

Now lets edit the file portlet.xml (located in src/main/webapp/WEB-INF), and create a portlet descriptor entry for our portlet. Notice that the <supports> element contains that same portlet modes that we support in our do methods.

    <description>Bonjour Monde Portlet</description>    
    <display-name>Bonjour Monde</display-name>
        <title>Bonjour Monde</title>


Now that you have created a new portlet, let's add a page to hold that portlet.

Previous - Next