This section describes the steps to incorporate your own portlets in to JBoss Portal. You can download a HelloWorld Portlet example from here.
Assumptions:
/helloworld.war /WEB-INF /classes /lib /portlet.xml /web.xml /META-INF
<?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> <portlet-name>HelloWorldPortlet</portlet-name> <portlet-class>com.myapp.portlet.HelloWorldPortlet</portlet-class> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> <portlet-mode>help</portlet-mode> </supports> <supported-locale>en</supported-locale> <portlet-info> <title>Hello World Portlet</title> </portlet-info> </portlet> </portlet-app>
There are three files you will need to add under /WEB-INF for your portlet to work in Jboss Portal. The first is a very short one, it should look like:
<portlet-app> <app-name>helloworld</app-name> </portlet-app>
This is used to define the first element in the dotted notation of an instance reference (see in helloworld-pages.xml for example).
Then you need to create helloworld-pages.xml. The portal will scan this file to find out which portal instance to target and what page name it will be in. In this case, we can access our portlet by going to http://localhost:8080/portal/index.html?page=hello
<pages> <portal-name>default</portal-name> <page> <page-name>hello</page-name> <window> <window-name>HelloWorldPortletWindow</window-name> <instance-ref>helloworld.HelloWorldPortlet.HelloWorldPortletInstance</instance-ref> <default>true</default> <region>user1</region> <height>0</height> </window> </page> </pages>
The second file needed under /WEB-INF is a portlet-instances.xml. This file maps the portlet name in your portlet.xml file to the portlet instance in your helloworld-pages.xml.
<?xml version="1.0" standalone="yes"?> <instances> <instance> <instance-name>HelloWorldPortletInstance</instance-name> <component-name>HelloWorldPortlet</component-name> </instance> </instances>
Now add these two files to your war and you should be able to access the helloworld portlet by going to http://localhost:8080/portal/index.html?page=hello.