Monday Mar 17, 2008

http://blogs.sun.com/satya/resource/jsf-small.PNG         A new plug-in called "Visual Portlet Builder" has been added to the recently released Portal Pack Beta 3 plug-ins list. Sometime back I had written a blog entry on how to create a JSF based portlet using NetBeans 6 + Portal Pack through some manual steps. This new plug-in eliminates all those manual steps and provides JSF portlet building capability inside Netbeans. It uses the existing VisualWeb's WYSWYG editor and enables portlet developers to design their JSF portlet through drag & drop components. You can use OpenPortal Portlet Container 2.0 RC1 to test your jsf based portlets.

Steps to create a JSF Portlet :

  • Create a Web Application with "Portlet Support" framework.
  • Right click on the project node, select New > Visual Web JSF Portlet Page
  • Enter page detail and press Finish.
  • Now you can drag & drop jsf components and design your jsf portlet page.
  • You can create more than one jsf portlet pages in the project and set them as VIEW/EDIT/HELP mode page for the jsf portlet.

To select jsf portlet pages for different modes of the portlet

  • Right click on the visual web jsf portlet page.
  • Select "Set as Initial" and select VIEW/EDIT/HEP mode page

Now you can build and deploy your project on OpenPortal Portlet Container from your NetBeans IDE.

The Portal Pack Beta 3 plug-ins are now available on both Portal Pack project site and NetBeans Beta Auto Update Center.

Comments:

hey,

thx for this guide. I tried it out like it says,but when i deploy my portlet,i get the portlet window but in the inside ,nothing is displayed ,no components or whatsoever.
any idea ?

<jsp:root version="2.1" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:p="http://java.sun.com/jsf/portlet/components" xmlns:webuijsf="http://www.sun.com/webui/webuijsf">
<jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
<f:view>
<p:portletPage>
<div style="-rave-layout: grid; position: relative; height: 400px; width: 400px;">

<webuijsf:themeLinks binding="#{PortletPage1.themeLinks1}" id="themeLinks1"/>
<webuijsf:form binding="#{PortletPage1.form1}" id="form1">

<webuijsf:button binding="#{PortletPage1.button1}" id="button1" style="position: absolute; left: 72px; top: 168px" text="Button"/>
</webuijsf:form>

</div>
</p:portletPage>
</f:view>
</jsp:root>

this is the jsf file(does this fall under html syntax ? :s)

Posted by bjorn on March 18, 2008 at 04:45 AM IST #

Which version of OpenPortal Portlet Container are you using? You should use OpenPortal Portlet Container RC1 to test your application. Anyway I will try your jsf file and let you know.

Posted by satya on March 18, 2008 at 12:38 PM IST #

Satya,

I see the same behaviour as Björn. The portlet container used is 2.0 RC 1.

Posted by Christian on April 03, 2008 at 06:20 PM IST #

Christian,

There was an issue related to context-root in Portet Container 2.0 RC1 due to which PC is not able to resolve resources like js though this works with PC 2.0 Beta . This issue has already been fixed and will be available in the next version of Portlet container. The workaround for PC 2.0 RC1 is, add a <display-name> in your application's web.xml same as application name. Otherwise you can use PC 2.0 Beta 2 for jsf portlet.

Posted by satyaranjan on April 04, 2008 at 09:45 AM IST #

It's a bug introduced in NB 6.0.1 woodstock runtime.

You can set webuiAll="true" parseOnLoad="false" attribute of <webui:themeLinks> manually in your jsf page to make it work.

<webuijsf:themeLinks id="themeId" webuiAll="true" parseOnLoad="false"/>

FYI, here's the bug filed for this issue
https://woodstock.dev.java.net/issues/show_bug.cgi?id=1168

Posted by satya on April 16, 2008 at 09:50 AM IST #

Hey,

same problems here, i can deploy the portlet but get an empty portlet at the portlet-container.

I use NB 6.1 (final) and portlet-container 2.0 rc 2.

thanks for help!

Posted by Wolfgang on May 05, 2008 at 06:05 PM IST #

Are you using multiple jsf portlet on the same page ? There was an issue with Portal Pack 2.0 Beta version/woodstock component.
http://www.netbeans.org/issues/show_bug.cgi?id=132409

This issue is fixed in the latest Portal Pack 2.0 Final version. It works on NetBeans 6.1 and Portlet Container 2.0 RC2 & Final.

Posted by satyaranjan on May 05, 2008 at 07:39 PM IST #

Hey,

i just try to create an "Hello, World!" Portlet.

Im using the latest version of Portal Pack + NB + OpenPortal Portlet Server + GlassFish V2.

Everything seems to be fine, i dont get any errors while deploying, but the "Hello, World!" is not showing up. (Only the head of the portlet, with the default buttons)

I try to post some more infos soon!
Thanks for help!

Posted by Wolfgang on May 05, 2008 at 07:50 PM IST #

It works pretty seamlessly. Here are my basic steps:

1.) Install the NetBeans 6.1 / GlassFish bundle.
2.) Run the GlassFish Updater (right click the server in NetBeans).
3.) Install portlet support (OpenPortal).
4.) Run the NetBeans plug-in updater.
5.) Click the "Refresh" button to refresh the catalog.
6.) Choose all the Portal components and install them.
7.) Right click the server node in the services tab, and chose "Add Server". Select OpenPortal, and point it to the same location as GlassFish. Start GlassFish (NOT the portal server -- there seems to be a bug, at least on my machine).
8.) Create a new web application and enable portlet support. Choose the OpenPortal
9.) Right click the application project and choose "New...", then Visual Web JSF Portlet Page. It will be assigned to the "View" by default.
10.) Drop a static text component on the page.
11.) Run the application.

It should show up with the static text in the window. Now you can go back and change the portlet page to actually do something.

Posted by Paedagogus on May 13, 2008 at 10:26 PM IST #

"Visual Web JSF Portlet Page"
and "drag & drop components ..."

perfect

but when I drag a Table on it, and in a next step a database-table to the Table header, I get
"Target server does not support automatic Data Source creation" ...

do I miss something ??
is there a workaround ?

thx

Posted by Pierre on May 24, 2008 at 02:23 AM IST #

I'm working with netbeans 6.0, and everything works ok, my doubt is that I must use a template (dwt with his css file), Wich xml I must modify and how can I modify it to keep the template of my site?

Posted by Carlos Galvis on June 16, 2008 at 08:12 PM IST #

Hi,
I am trying this out. I am able to get form elements displayed, but it looks like images and css which are supposed to come from (context)/theme/com/sun/rave/web/ui/* are not being served. I copy the path from "view source" and put it directly in the browser and get a 403 from my app server. Is there something I need to configure?
I get this message with the 403
"Direct access to this Portlet Application's resources has not been authorized"
Thanks

Posted by Peter on June 18, 2008 at 09:56 PM IST #

Hi, I'm building a portlet using the Visual JSF Framework and Woodstock components in Netbeans 6.1. My portlet just displays a table with the data collected from a MySQL database (a basic 'Select All' from a table). I am using Liferay 5.1.2 bundled with Tomcat 6.0 on Windows 2000. The portlet deploys fine in Liferay (after a server restart), my problem is that the data is not displayed in the table. My guess is that I have a problem connecting to the MySQL database inside my portlet. I have tried several things like including the Database Resource definition in the context.xml for Tomcat and also in the Root.xml, but I get the same results. My table keeps displaying "No items found". The table is displayed correctly as a web application, the problem comes when deploying as a portlet. Am I missing something? Any help is appreciated, thanks.

Posted by Tony on October 23, 2008 at 09:18 PM IST #

Could you please explain, how do you accessing database to get data ?

FYI, automatic data binding through drag and drop of database table to visualweb jsf table is not possible for the portlet. You have to do it manually.

Posted by satya on October 24, 2008 at 12:26 PM IST #

Thanks for the reply. To answer, yes, I was doing it by dragging and dropping the database table to the JSF table. How can I bind the data manually? Thank you very much for the help.

Posted by Tony on October 24, 2008 at 10:40 PM IST #

I have developed two Portals in one page and I set the view/edit/help on each JSF page, now my problem is when want to set another JSF page as view/edit or help on the other portal is not working it works for the first one. Please help guys. Thank you

Posted by Elley on October 26, 2008 at 09:59 PM IST #

Tony,

It looks like the _init() method is not getting called in the Page.java(page java file) file. And user_DataProvider.setCachedRowSet() is called in _init() to set the CachedRowSet for the dataprovider. That's why you are not able to see any data.

Try calling _init() inside constructor of Page.java.
But make sure you have added the datasource properly in your server.

Looks like a bug in jsfportletbridge.

Posted by Satya on October 27, 2008 at 12:17 AM IST #

Hello Satya, thank you very much for the help. I finally got my table to retrieve the data from the MySQL Database inside my portlet with your method. I tested it and worked fine, but I encountered another small problem. It seems that Liferay is not displaying the Woodstock table properly. It displays most of it, but some areas of the background of the table are not being rendered. I have uploaded an example for you to see: http://img216.imageshack.us/my.php?image=mybitmaphx1.png. Is this a problem with Liferay displaying Woodstock components? Any help is greatly appreciated as always. Thank you.

Posted by Tony on October 27, 2008 at 09:13 PM IST #

I have created my portal on NetBeans 6.1 and is running, now i want to remove the picture and the name (Portlet Container Driver) that appears on the browser when I’m running the project.

Posted by Elley on October 29, 2008 at 05:52 PM IST #

thank you for your effort explaining how to create jsf portlet, however I followed the instructions and I got an class cast exception while deploying to Liferay 5.1.2 on tomcat 5.5

can you please help me on that please? I hope that you can send me something using email

Posted by Fahd Helwani on December 16, 2008 at 06:16 PM IST #

I will try that and let you know. But can you send me the exception stack you are getting during deployment ?

Posted by satya on December 16, 2008 at 07:43 PM IST #

Liferay on Tomcat appears to be a problem for JSR-286 (ie, IPC) and Visual JSF Portlet Pages. Download the Glassfish/Liferay bundle. That seems to work as expected.

Posted by Paedagogus on December 16, 2008 at 09:06 PM IST #

Thank you Paedagogus! I'll try Glassfish/Liferay...
I have a problem of reload with Tomcat/Liferay, it's means I need reload page for display my portlet...
What's your problem?

Posted by yi on April 17, 2009 at 07:39 PM IST #

Hi, Thanks for this guid, I have problem in displaying jsf controls, like table in a jsf portlet, error "webui is undefined" appears. My Environment is:
1- Netbeans 6.5.0.
2- Glassfish V2.0.
3- Webspace 10.x.
4- PortalPack 3.0.
5- JSF Portlet Bridge Library.
Please, any help will be so appreciated.
Thank You.

Posted by Mohammed Ali on June 24, 2009 at 01:35 PM IST #

Post a Comment:
  • HTML Syntax: NOT allowed