I am pleased to announce that a new version Portal Pack 3.0.4 is now available for download. There was a long gap between Portal Pack 3.0.3 and 3.0.4 release because of various reasons.  But this new version is aimed to be compatible with NetBeans 6.9, Liferay 6 and also latest version of Portlet Container.

So here are some key features

Many thanks to Deepak for helping me for this release.

If you want to contribute any new feature or doc, you can leave a message here in this blog or send a mail to  portalpack at contrib.netbeans.org

FYI, This project is no longer sponsored by Sun/Oracle.

My First Blog here …

Posted: June 6, 2010 by satya in Personal

After leaving from Sun, now here you can find me blogging about technology and myself. I have imported some of my old blog posts here. But you can still access my old blog posts at http://blogs.sun.com/satya (Hope Oracle will keep it live…) and my liferay’s blogs at http://www.liferay.com/web/satyaranjan/blog

As you know Portal Pack 3.0.1 provides a nice service builder editor where you can add/remove services and also generate service classes from NetBeans IDE. These services can be deployed on Liferay/Web Space server. To know more about how the services can be generated using Portal Pack, check this blog.

If all your portlets are deployed on the same liferay instance, then they can consume those services through normal java calls. But what about exposing a service as remote service, so that it can be consumed by remote clients. But currently the service builder plug-in in Portal Pack doesn’t generate SOAP, JSON classes which are required to expose a remote service as SOAP and JSON and hence can not be consumed by remote clients.

So if you are using service builder plugin in NetBeans,  here are some steps provided by Ilya Zverev in this forum post to generate soap/http/json classes for the services in your service.xml . I am just doing the copy paste of those steps here in this blog

  • Create service using ServiceBuilder.
  • Create new package apart from your portlet and create an interface there with all service methods.
  • Use Apache Axis’ Java2WSDL and WSDL2Java to create all soap classes and deploy.wsdd .(You can also manually call the build-wsdd target)
  • Find YourServiceSoapBindingImpl.java and write implementations for all methods to call corresponding YourServiceUtil methods, generated by ServiceBuilder.
  • Build this package and put it into tomcat/webapps/ROOT/WEB-INF/lib folder;
  • Take <service> tag from generated deploy.wsdd file and copy-paste it into tomcat/webapps/tunnel-web/WEB-INF/server-config.wsdd near other services.
  • Copy the jar generated with ServiceBuilder into tomcat/common/lib/ext
  • Stop, then start tomcat, deploy your portlet.
  • Check http://localhost:8080/tunnel-web/axis for your service. It should be there.

Thanks to Ilya Zverev for these steps.
Meanwhile we are trying to automate these steps in Portal Pack Service Builder and hope you won’t need to follow all these manual steps in next update release of Portal Pack.

There is an issue with JSF Portlet (Woodstock portlet) with page navigation created by Portal Pack 3.x and running on Liferay or Web Space Server. So if you have page navigation inside jsf portlet, then no component in the portlet is shown when try to navigate to the a second page.But if you reload the page, the portlet is shown properly. This behaviour is there only with Firefox, but it works fine with IE.

So the detail steps to reproduce this issue  are
1)Create a JSF portlet app using portal pack that uses page naviagation (say from page1 to page2)

2)Deploy the portlet app


3)Click on some botton in page1 to naviagate to page

Issue:Page2 of the JSF portlet is not rendered untill a referesh.Issue not seen in IE..

So now the good news is, there’s a workaround

From the jsf jsp page remove webuiAll="true" attribute from <webuijsf:themeLinks……/> tag. Everything works perfectly in Firefox & IE after removing this attribute.

Portal Pack 3.0 : Makes Portlet Development Easy !!!

Posted: February 13, 2009 by satya in NetBeans

Portal pack 3.0The Portal Pack 3.0 is now available for download. With lots of new features and bug fixes, the Portal Pack 3.0 is out there to make portlet development easier than before. This version is compatible with NetBeans 6.5 IDE. This version of Portal Pack supports the recently released Sun GlassFish Web Space Server 10.0 which is part of the GlassFish Portfolio.
WebSpace
Sun GlassFish Web Space Server is Sun’s next generation aggregation and presentaion platform.  It enables businesses large and small to pull together applications and content from a variety of Web-based and internal sources and present them as a unified, customizable portal on Web browsers, kiosks, and mobile devices. For more info you can check this blog written by James.

Some of the Key Features in Portal Pack 3.0

  • Support for New JSR 286 specification
  • Eventing Storyboard for JSR 286 Eventing
  • Visual Portlet Builder plug-in to build JSF portlet using WYSIWYG editor.
  • Portlets with Spring MVC framework
  • Write Portlets with different languages like Ruby/PHP/Groovy which can be deployed on Sun GlassFish Web Space Server and Liferay Portal Server.
  • Use Web Space/Liferay’s service builder framework inside your portlet. A new advanced Service XML editor is introduced to help you define and generate services.
  • Use Web Space/Liferay’s service apis directly to write advanced portlets.
  • Use Taglibs provided by Web Space/Liferay directly inside your Portlet. For example : You can use rich ui taglibs provided by Liferay/Web Space inside your Portlet, so that your portlet will look similar to other UI in the portal page.
  • Directory deployment : Using new directory deployment feature, you can quickly develop and test your application without redeploying your portlet application again and again. So no need to deploy your portlet when you are changing JSPs, HTML, javascripts etc etc… Also if you are developing portlets using PHP/Ruby/Groovy languages then you need to deploy the portlet only once during development cycle. During development, just change the PHP/Ruby/Groovy script and refesh the browser to see the output.

The deployment support in this release has been extended to support the following servers

Here’s the link to the  quick start guide for Portal Pack 3.0 . So try out this new Portal Pack 3.0  !!!

We have already started working on the next update for Portal Pack. Your feedback for the existing features and suggestions for any new features are most welcome. So you may see your suggested feature in the next update release of Portal Pack.

WebSynergy & Portal Pack at Devoxx’08

Posted: December 28, 2008 by satya in Personal

I attended this year’s Devoxx conference which was held between 8th – 12th Dec at Antwerp, Belgium. This was my first trip to Devoxx conference and also to Belgium. I got an opportunity to talk about WebSynergy and Portal Pack  in a 30 min session. It was mostly driven by the demos around WebSynergy and Portal Pack. I covered different kind of Portlet Developments using NetBeans and Portal Pack plug-ins.

Devoxx was definitely a success. It’s one of the biggest Java Community Conference in Europe.

There were some very good talks on JavaFX, JRuby, Flex, JBoss Seam. The videos of all those sessions of Devoxx’08 will be available at http://parleys.com/  sometime during Jan’ 09.

(at Devoxx)

The recently released Portal Pack 2.0 has a new feature called Eventing StoryBoard.The Eventing StoryBoard feature in Portal Pack 2.0 simplifies the task of creating portlet application that uses JSR-286 eventing. It provides a simple drag drop feature to link the portlets involved in eventing. Automatic code generation functionality in the storyboard adds the necessary interfaces, methods and xml elements needed during eventing.

Here’s a tutorial  contributed by Sriram K,  which explains about JSR 286 eventing using Eventing StoryBoard

 http://portalpack.netbeans.org/tutorials/eventing/EventingStoryBoardTutorial.html

There is also a screencast available for the same. Thanks to Hemadri, Anjana, Sriram for their help for this screencast

http://portalpack.netbeans.org/demos/evtstoryboard/eventing-story-board.htm 


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.


In Portal Pack Plug-ins, earlier Velocity template engine was used for all type of code generations and templating. But after going through some NetBeans doc I found that NetBeans 6 (Currently under development) bundles FreeMarker template engine with it. But FreeMarker apis are not exposed directly rather those can be used through JSR 223 Library Integration (JSR223: Scripting for Java Platform) in NetBeans.

You can follow the below steps for a easy migration from Velocity to Freemarker template engine in your module

  • Convert all your velocity templates to equivalent Freemarker templates. There is a command line utility to convert velocity templates to Freemarker templates automatically. For more details click here.
  • Change your module’s layer.xml as below to mention the "javax.script.ScriptEngine" attributes as "freemarker" for your template.

                            <folder name="mytemplatefolder">
                                  <folder name="templates">
                                         <file name="mytemplate.java" url="nbresloc:templates/mytemplate.template">
                                            <attr name="position" intvalue="0"/>
                                            <attr name="javax.script.ScriptEngine" stringvalue="freemarker"/>
                                        </file>
                                  </folder>
                            </folder>

  • Add JSR 223 Integration to Module Dependencies
  •  To get the template FileObject  add/use following two methods in your module’s code

                      public static FileObject getTemplateFile(String name) {
                            FileObject fo = getFolder() != null ? getFolder().getFileObject(name) : null;
                            return fo;
                      }

                      public static FileObject getFolder() {
                            if (folder == null) {
                                folder = Repository.getDefault().getDefaultFileSystem().findResource(templateFolder);
                            }
                            return folder;
                    }

         In the above example templateFolder value should be "mytemplatefolder/templates"

  •  Call following method on template FileObject to merge and create the new file

            public final DataObject createFromTemplate(DataFolder f, String name, Map  parameters)

  • You can also directly use the JSR 223 API for template processing and merging

New Feature: Resource Serving in JSR 286

Posted: August 13, 2007 by satya in Technology

ranjansatya.wordpress.comresource.jpg Recently the JSR 286 draft was available for public review which can be downloaded from this link. It includes some of  the major features which were missed in the JSR 168 spec. You can visit Deepak’s blog to  get a list  of  all those major changes.  One of the major feature introduced  in this  new Portlet  specification is “Resource Serving“  .  In this blog I will  explain  this  feature in detail.

In one line “The resource serving feature provides the ability for a portlet to serve a resource”.

Why it is needed ?

Direct links to the resources in the same portlet web application  are not guaranteed to pass through the portal server and will not have portlet context available. So direct link should be used for the use case where access to the portlet context and access through portal server is not needed.

But the resource url link points back to the portlet. A new interface “ResourceServingPortlet” is introduced in the JSR 286 spec. Via these resource url links serveResource method of ResourceServingPortlet interface is called and portlet can serve the resource which may be protected by the portal security and can leverage portlet context. Portlet container does not render any output in addition to the content returned by the serveResource call. Thus this new life cycle method serveResource() provides more
control to the portlet developer by giving access to write directly on the response object where portal server just acts as a proxy.

The serveResource call can also be used to implement AJAX use cases by invoking resourceURL through XMLHttpRequest in client side javascript. The client side code of the portlet is then responsible for inserting either the markup or otherwise update the page DOM in a non disruptive manner for the other components on the page.

How to Create a Resource URL ?

A resource url can be generated by invoking createResourceURL() method of the RenderResponse object  in render phase of the portlet or doView() method of the Generic Portlet.

The resouce url can also be created inside serveResource() method of the ResourceServingPortlet. In that case portlet developers need to call createResourceURL() method on ResouceResponse object passed to the serveResource() method.

In the following code snippet we will create a resource url inside the doView() and then we will set that url as a IMG source in the rendered output.

public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {

response.setContentType(“text/html”);
PrintWriter writer = response.getWriter();

ResourceURL resURL = response.createResourceURL();
resURL.setResourceID(“image”);
writer.println(“<IMG src=”" + resURL+ “” >”);

//Render other markups

}

So when the browser loads the portal page to show the view mode of the portlet, it automatically sends the request for the resURL which goes through portal and finally serveResouce() of  GenericPortlet is called to serve the resource (in this case “image”).

The serveResource() for this example should look like below

public void serveResource(ResourceRequest resRequest, ResourceResponse resResp) throws PortletException, IOException {

resResp.setContentType(“image/png”);
byte[] b = getImage(“MyImage.PNG”);  //Returns image bytes
resResp.getPortletOutputStream().write(b);

}

I have taken the above image example to explain the usefulness of this new feature properly. But  you may also want to create a link for a resource url in your doView() and then on clicking on that link, serverResource() will be called which will only show the output returned from the serveResource().

You can also set a resource id of the resourceURL to enable same serveResource() serving multiple resources. You can also create new resource urls inside serveResource().

The cache level of a resource url can be set through setCacheability() of ResourceURL class though there are certain restrictions in setting cache level. Possible values are: FULL, PORTLET
or PAGE. This helps for Caching of Resouces. To know more about caching in JSR 286 check Karthik’s blog.

You can check out the sources of OpenPortal Portlet Container which has the implementation for serve resource feature of JSR 286. Try it out.