Developing Portlets with Netbeans 6.0 and Woodstock VWP
This blog discusses about developing a simple portal application with
woodstock (VWP) and deploy that in glassfish in netbeans 6.0.
Getting started:
The first step is to install the portlet container driver for
glassfish. You should find them at:
https://portlet-container.dev.java.net/public/Download.html
You should then install it in your glassfish server location.
In *nix systems, the command would be:
java -jar
portlet-container-configurator.jar /usr/local/glassfish
/usr/local/glassfish/domains/domain1
where:
/usr/local/glassfish - glassfish install location
/usr/local/glassfish/domains/domain - domain that is being used for
glassfish.
Next, download and install the portat plugin pack for netbeans.
You can download them at:
http://portalpack.netbeans.org/download.html
There are four downloadable plugins available out of which if you are
going to deploy the application in glassfish, you wouldnt need to download the fourth plugin meant for sun java
system portal server 7.x
Creating a portal app
Create a new JavaEE5 web project. You should choose the target
container as glassfish (since we are using that for this example and not tomcat). In the final step of project
creation, where you have a list of frameworks to choose from, you should select VWP and Portal support. Select portlet version
as 2.0 and check the "create portlet" and "create JSP" checkboxes.
(Click on the image for a larger view)
The project should now be created. The Visual web designer screen
though shows up as a white blank screen. You should be still able to drag and drop components initially and set
properties on them.
Drag and drop a text field and a button on to the screen. Let us try to show this simple page on a portal server.
Configuring the application
The following changes needed to be made at present to make a portlet
work properly with woodstock components.
i) Download jsf portlet bridge from
https://jsfportletbridge.dev.java.net/ and make sure you include that
in your application library's classpath.
ii) Make sure you have the following six libraries imported to your
application.
(Click on the image for a larger view)
iii) Edit your portlet.xml file so that it contains the following line.
<portlet-class>com.sun.faces.portlet.FacesPortlet</portlet-class>
Once you do this, there should be some error shown on the visual
designer page and you wouldnt be able to make visual edits on the components. However you should be able to edit
the JSP pages.
iv) Include a <webuijsf:themeLinks> tag in the JSP page so that
the woodstock theme is included for the app.
v) Right click on the jsp page -> set as initial -> view mode.
(or edit/help mode). Alternatively, you can go to portlet.xml and append it as an init-param. Something like:
<init-param>
<name>com.sun.faces.portlet.INIT_EDIT</name>
<value>/Page1.jsp</value>
</init-param>
Deploying your application
i) Start the glassfish server. Check whether the portlet container
driver is installed for glassfish by going to
http://localhost:8080/portletdriver
ii) Build your web application
iii) Go to the admin tab of the portlet page and upload the web
application's war file.
iv) You should now see the text field and button in all its glory!
For more information on portlets and woodstock you can take a look at Dmitry's blog on Running Woodstock JSF Components in Portlet environment

