portals-jetspeed-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Platts <john_pla...@hotmail.com>
Subject Developing portlets for Jetspeed 2.1.3 using NetBeans 6.0
Date Tue, 11 Mar 2008 16:47:58 GMT
I have used NetBeans 6.0 to develop portlets for Jetspeed 2.1.3. I have even used NetBeans
6.0 with the Maven plugin to build the portal.

NetBeans 6.0 can be downloaded from the following website:
http://www.netbeans.org/

To install portlet development support in NetBeans 6.0, do the following:
1. Start NetBeans IDE 6.0.
2. Select Plugins from the Tools Menu.
3. Select the Available Plugins tab.
4. Ensure that the Generic Portlets plugin is checked under the Available Plugins tab.
5. Click on the Install button.

To develop an Hello portlet application that will work with Jetspeed using NetBeans 6.0, do
the following:
1. Start NetBeans IDE 6.0.
2. Select New Project from the File menu.
3. Select Web under Categories and then select Web application under Projects.
4. Click on the Next button.
5. Under Project Name, enter helloportletdemoapp. Under Server, select the server that the
Jetspeed 2 portal is running on. Under Java EE version, select J2EE 1.4. You can leave Set
Source Level to 1.4 unchecked if you will be running this portlet application with a Java
5 or Java 6 VM. You should have Set Source Level to 1.4 checked if you need to run this portlet
application with a Java 1.4 VM.
6. Click Next.
7. Under Frameworks, select Portlet Support and ensure that Portlet Support is checked.
8. In the Portlet Support Configuration Pane, set the following settings:
- Portlet Version: 1.0
- Check the Create Portlet and Create Jsps check boxes
- Set package to com.example
- Set portlet class name to HelloPortlet
- Under Portlet Mode, ensure that View is checked and that Edit and Help are unchecked
9. Click Finish.
10. Edit the HelloPortlet_view.jsp file that is created. The HelloPortlet_view.jsp file should
now contain the following:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ page import="javax.portlet.*"%>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>

<portlet:defineObjects />

<%
String userName = renderRequest.getRemoteUser();

if((userName == null) || (userName.isEmpty())) {
    userName = "World";
}
%>
<p>Hello, <%= userName %>.</p>

11. In the Projects pane, right click on helloportletdemoapp and select Properties.
12. In the Project Properties - helloportletdemoapp dialog box, select the Compiling category
under Categories, and then check the Test compile all JSP files during builds. This ensures
that the JSP files that will be included in the portlet application are valid JSP files.
13. Click OK.
14. In the Projects pane, right click on helloportletdemoapp and select Build to build the
project and create the WAR file.
15. When the project is built, you should get a line similar to this if the build is successful:
Building jar: C:\NetBeans6Projects\helloportletdemoapp\dist\helloportletdemoapp.war
This line contains the path of the portlet application WAR file.
16. The WAR file that is created by the build needs to be copied manually to the <path
of Jetspeed portal web application>/WEB-INF/deploy folder in order to successfully deploy
the WAR to the Jetspeed portal.

I have built projects that use the Jetspeed-2 API and other APIs that are used by applications
that are included in the Jetspeed-2 j2-admin and demo applications.

To include these APIs in NetBeans portlet application projects, the steps below need to be
followed:
1. Under Files, select the helloportletdemoapp application (or another portlet application).
2. Select the nbproject folder under the helloportletdemoapp application.
3. Open the project.properties file.
4. Add these lines to your project.properties file:
file.m2.repo.dir=<directory of your Maven 2 repository>
file.reference.jetspeed-api-2.1.3.jar=${file.m2.repo.dir}/org/apache/portals/jetspeed-2/jetspeed-api/2.1.3/jetspeed-api-2.1.3.jar
file.reference.jetspeed-commons-2.1.3.jar=${file.m2.repo.dir}/org/apache/portals/jetspeed-2/jetspeed-commons/2.1.3/jetspeed-commons-2.1.3.jar
file.reference.pluto-1.0.1.jar=${file.m2.repo.dir}/org/apache/pluto/pluto/1.0.1/pluto-1.0.1.jar
file.reference.portals-bridges-common-1.0.4.jar=${file.m2.repo.dir}/org/apache/portals/bridges/portals-bridges-common/1.0.4/portals-bridges-common-1.0.4.jar
5. Change the javac.classpath line in your project.properties file to the following:
javac.classpath=\
    ${libs.Portlet-1.0-Lib.classpath}:\
    ${file.reference.jetspeed-api-2.1.3.jar}:\
    ${file.reference.jetspeed-commons-2.1.3.jar}:\
    ${file.reference.pluto-1.0.1.jar}:\
    ${file.reference.portals-bridges-common-1.0.4.jar}

Note that your javac.classpath line might contain additional libraries. If your javac.classpath
contains additional libraries, you should add them after the ${file.reference.portals-bridges-common-1.0.4.jar}
line, and each line except for the last line needs to be delimited with :\. For example, if
your project depends on commons-dbcp-1.2.2.jar, commons-pool-1.2.jar, and commons-collections-3.2.jar,
your javac.classpath should look like this:
javac.classpath=\
    ${libs.Portlet-1.0-Lib.classpath}:\
    ${file.reference.jetspeed-api-2.1.3.jar}:\
    ${file.reference.jetspeed-commons-2.1.3.jar}:\
    ${file.reference.pluto-1.0.1.jar}:\
    ${file.reference.portals-bridges-common-1.0.4.jar}:\
    ${file.reference.commons-dbcp-1.2.2.jar}:\
    ${file.reference.commons-pool-1.2.jar}:\
    ${file.reference.commons-collections-3.2.jar}

Note that commons-dbcp-1.2.2.jar, commons-pool-1.2.jar, and commons-collections-3.2.jar need
to be included in your portlet application WAR. To do this, right-click on the helloportletdemoapp
application or your other portlet application in the Projects window, and then select Properties.
Select Libraries under Categories. Be sure that the Compile tab on the right hand side of
the Project Properties dialog box is selected, and then be sure that Package is checked for
commons-dbcp-1.2.2.jar, commons-pool-1.2.jar, and commons-collections-3.2.jar, and be sure
that package is unchecked for Portlet 1.0(JSR 168) Library, jetspeed-api-2.1.3.jar, jetspeed-commons-2.1.3.jar,
pluto-1.0.1.jar, and portals-bridges-common-1.0.4.jar. Click OK after these settings are set.

I have had success using NetBeans IDE 6.0 with its Generic Portlets plugin.

Using NetBeans IDE 6.0 with its Generic Portlets plugin provides the following advantages:
1. JSP files can be test compiled during the build process to ensure that they do not contain
syntax errors.
2. The NetBeans IDE 6.0 has a nice UI for creating new portlets.
3. NetBeans IDE 6.0 allows you to easily debug portlet applications by attaching the debugger
to the Tomcat instance that Jetspeed 2 is running on.

Has anyone else used NetBeans IDE 6.0 to develop portlets for Jetspeed 2.1.3?

The NetBeans IDE is extensible and has support for Ant build scripts, and even has support
for Maven 2 projects with the Maven plugin.

_________________________________________________________________
Climb to the top of the charts! Play the word scramble challenge with star power.
http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_jan
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message