Wednesday, September 2, 2009

Creating Portlets (for Pluto) using Netbeans

Upon my inclusion in this project, I decided to use Netbeans for all my development. I'd had more experience using it than Eclipse, and it seemed to have the right level of simplicity and functionality for what I needed. However, it had no built in project templates for creating portlets. So following the instructions Desmond put on this blog for creating the hello world portlet, I went about using Netbeans to create it.

Firstly create a new project using the Java Web -> Web Application template. Give it a a name in the next screen, keep clicking next leaving most of the settings default. You can delete or modify the created index.jsp under the Web Pages section of the project. Also in this section, in the WEB-INF folder, open web.xml and copy in the information from the tutorial below. Create a new xml file in WEB-INF and call it portlet.xml and copy in the code from below for that file. Right click on the Web Pages section and add a new folder calling it META-INF. Create a new xml file underneath that calling it context.xml or hello.xml and copy in the related code from below as well.

To make this project compile we need into include the portlet-api jar file specified below. You can do this by right clicking on the project, selecting properties and going to the libraries section, and adding the portlet-api jar file to the list of included libraries. However this actually packages the library with the portlet in the WAR file, which we don't want because it will conflict with the already inlcuded library in whatever Portal system your using. So once you've selected the jar file to include, you need to uncheck 'Package' for that libary.

Once that's done you can build the project (don't try and deploy), this will produce a war file in the 'dist' directory of the project, which you can then copy into the webapps folder of your portal driver (Pluto in my case).

No comments:

Post a Comment