...
In addition to the regular portlet.xml and web.xml descriptors, JBoss Portal 2.2 requires us to add a couple of JBoss specific descriptor files. On of these descriptor files is named according to the name of the context root of our application, which in this case is the name of the exported war file itself. We will later create a war file named MyPortlet.war, so the name of the JBoss descriptor becomes 'MyPortlet-object.xml'. So we create this file in the WEB-INF folder, and insert the following text:
Code Block | ||
---|---|---|
| ||
<?xml version="1.0" encoding="UTF-8"?>
<deployments>
<deployment>
<if-exists>overwrite</if-exists>
<parent-ref>default</parent-ref>
<properties />
<page>
<page-name>MyPortlet Tutorial</page-name>
<properties />
<window>
<window-name>MyPortletWindow</window-name>
<instance-ref>MyPortletInstance</instance-ref>
<region>center</region>
<height>0</height>
</window>
</page>
</deployment>
<deployment>
<if-exists>overwrite</if-exists>
<instance>
<instance-name>MyPortletInstance</instance-name>
<component-ref>MyPortlet.MyPortlet</component-ref>
</instance>
</deployment>
</deployments>
|
In addition, we need two other files, jboss-app.xml and jboss-portlet.xml which looks like this:
Code Block | ||
---|---|---|
| ||
<jboss-app>
<app-name>MyPortlet</app-name>
</jboss-app>
|
Code Block | ||
---|---|---|
| ||
<portlet-app>
<portlet>
<portlet-name>MyPortlet</portlet-name>
<security>
</security>
</portlet>
</portlet-app>
|
Deployment
Now we have a project structure that looks like this:
Project structure
Now it's time to try our incredible HelloWorld portlet. In a windows explorer session, we select the WEB-INF folder and zip it up and name the file 'MyPortlet.war'. Drop this war file in the server/default/deploy folder of JBoss Portal, and start the server. By default, the URL for JBoss portal is http://localhost:8080/portal, so point your browser to this address, and you will get to the front page of the portal, where you should get a "MyPortlet Tutorial" menu entry, as shown in the screenshot below. When pressing this menu link, you will get to our fantastic "Hello World" page!
JBoss Portal front page
MyPortlet portlet page