Infoglue supports the Portlet standard also known as JSR 168. Infoglue has incorporated Apache Pluto which is the reference implementation of the portlet API. Portlets are covered on the Internet extensively why we will not leave a lot of room here.
We will state however that for an organisation that has competence in such development this option is probably one of the best integration options as it will allow you to build a completely decoupled web application but seamlessly integrate it in an Infoglue page and having interaction etc. taken care of. In a later section we will show you how to build a simple portlet and deploy it in Infoglue. Then you will have to read more on the subject yourself.
This section will guide you through creating a simple Hello World portlet and deploying it in InfoGlue 2.3. It will not show you how to build portlets with more sophisticated frameworks like Struts or Webwork as that is not a question for InfoGlue.
Step 1 – Create a Hello World Portlet.
Create a new Java project called HelloPortlet in your favourite development environment.
Create a file called org/infoglue/portlets/HelloPortlet.java and fill it with this:
* HelloWorld Portlet
public class HelloPortlet extends GenericPortlet
public void doView(RenderRequest req, RenderResponse res) throws PortletException, IOException
PrintWriter out = res.getWriter();
The file needs portlet-api-1.0.jar in its class path to compile. Get it from tomcat/shared/lib if InfoGlue is installed, from the Pluto distributions or from any other official site.
Next we create a portlet.xml:
Next we create a web.xml for this portlet:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
<description>Hello Portlet Wrapper</description>
Step 2 – Package the portlet as a WAR-file.
I just create a war-file with the following contents.
That is it really.
You can download the example war from http://www.infoglue.org/downloads.
Step 3 – Deploy the portlet in InfoGlue.
Now we deploy the portlet in InfoGlue. Open up the management tool and press the ”New Portlet”-button. Then state HelloPortlet and browse to the war-file. Finish by pressing ”Save”.
The result should be that the new portlet is listed.
Step 4 – Use the portlet on a page though a component.
Before you can use the new portlet often you have to restart tomcat after this stage. Also remove the deployed war-file from the catalina webapps directory as the webapp should now unpacked and the war is just interfering. Do this before you continue.
Create a component/template with the following code:
# set($portletName = "HelloPortlet.HelloPortlet")
# set($calendarPortlet = $portalLogic.getPortletWindow($portletName, "p$templateLogic.componentLogic.infoGlueComponent.id"))
Now just add this component to a page and you should see ”Hello World” in large letters.
This was the crash course to creating your very first portlet. Now you probably have to read a portlet-book to know what to do next.
comments powered by Disqus