Profile

Recent Bloggers

Juan Fernández Posts: 2
Stars: 4
Date: 2/9/10
Aaron Delani Posts: 3
Stars: 8
Date: 2/8/10
James Min Posts: 23
Stars: 41
Date: 2/8/10
Jonas Yuan Posts: 12
Stars: 30
Date: 2/8/10
Ronald Sarayudej Posts: 83
Stars: 226
Date: 2/8/10
Julio Camarero Posts: 6
Stars: 18
Date: 2/8/10
David Truong Posts: 9
Stars: 29
Date: 2/3/10
Neil Griffin Posts: 22
Stars: 57
Date: 2/3/10
Paul Hinz Posts: 1
Stars: 7
Date: 2/3/10
Bryan Cheung Posts: 19
Stars: 84
Date: 1/27/10

Blogs

Where's Portal Pack Project site !!!

The Portal Pack project site (http://portalpack.netbeans.org) is down for last few days because of the netbeans.org migration. But in case you need Portal Pack's binaries urgently,  here is the new location for Portal Pack project http://contrib.netbeans.org/portalpack/. We have filed a bug to set the redirect for http://portalpack.netbeans.org to this new location. Once that bug is fixed, you should be able to access the Portal Pack project site using the old url http://portalpack.netbeans.org .

For more details check this issue

https://netbeans.org/bugzilla/show_bug.cgi?id=176226
Portal Pack JSF Portlet (Woodstock) Page Navigation Issue - workaround

There is an issue with JSF Portlet (Woodstock portlet) with page navigation created by Portal Pack 3.x and running on Liferay 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.

Try out Portal Pack 3.0.1

The Portal Pack 3.0.1 final is now available for download. Though this is a minor release, but there are few key new features added in this release. Also for this release, we got a valuable contribution from community ( "Liferay 5.2.x on JBOSS 5.x support" ) and thanks to John Platts for this contribution.

Here are the list of new features added in this release :

  • Directory Deployment & Deploy on Save for Portlet Application

Using "Directory Deployment and Deploy on Save" feature, you don't need to redeploy your application any more during development time. Any change in any file, you just need to save it and the rest is taken care by the IDE. If a java file is  changed and saved, it is automatically compiled and the application is reloaded to reflect the new change. So just refresh your browser and see the change. This is also true for jsp, javascript, html and even portlet.xml .

You can enable/disable Directory Deployment in the Server Config Panel. By default  Directory Deployment  is not enabled. You need to enable "Directory Deployment" to use "Deploy on Save" feature. You can also disable only "Deploy on Save" feature.

  • Liferay Theme Development

Now using Portal Pack, you can create and edit Liferay Theme plug-ins. You need to select the "Run In Developer Mode" check box in server config panel in NetBeans. By doing so NetBeans will be able to start the Liferay server in developer mode which is required during theme development.

To create a a Liferay Theme Application

> Create a Web App

> Right click on the project > New > Others > WebSpace/Liferay Plugins > Import/Create New Theme . This will import the classic theme files from the liferay server installation to your project.

> Enable the directory deployment in the server config panel and deploy the theme. 

CSS Editing

NetBeans provides a good CSS editor for developers. You can see the preview of the style inside NetBeans only. To use css editing feature effectively in NetBeans, open Windows > Others > CSS Preview ,  Windows > Other > CSS Style Builder and Windows > Navigating > Navigator windows while editing a css file.

> Change CSS using NetBeans CSS builder.

> No need to redeploy the theme again and again if the "Directory Deployment enabled" is selected. Deploy it once and select it in Liferay Portal. Then just change the CSS in NetBeans CSS editor , save it and refresh your browser to see the output.

Velocity (VM) templates editing

Portal Pack 3.0.1 provides code completion for VM variables defined by Liferay Portal Server. In any vm files in a theme application, you can use "ctrl + space" to get the code completion help for vm variables. 

  • Liferay Hook Plug-ins Support

Portal Pack 3.0.1 also provides support for different type of Hooks application. Check out  Chetan's blog for more details on Hook Plug-in Support

  • Liferay 5.2.x on JBOSS 5 Support

Now if you are using Liferay 5.x bundle on JBOSS 5 then you can use Portal Pack for the portlet development. This plug-in supports portlet deployment and server start/stop in both normal & debug mode from IDE. But the "Directory Deployment" is not yet supported with JBOSS bundle.

Portal Pack now supports Liferay Tomcat/GlassFish/JBOSS bundle.

 

Portal Pack : Write Database Portlet using Service Builder Plug-in

The service builder framework in Liferay represents the database layer and all the interactions with database are done through service builder infrastructure. So in this blog, I will explain how you can use service builder framework inside your custom portlet using NetBeans 6.5 & Portal Pack 3.0. To use service builder framework, you first need to create a service xml and then generate the required code. The Portal Pack here helps you by providing a nice GUI editor for service.xml file where you can define the entities or database structures and from the same GUI you can generate the services code which can be used inside your portlet.

I have taken an example of Simple Form Submission Portlet here. Using this portlet you can submit customer details which will be stored inside liferay's database and the same portlet will also show the no of customer records present in the database.

First create a Webapplication with "Portlet Support" framework and add a new Portlet to it. Now you need to create the service.xml file. Let's create the portlet application as "CustomerApp" and a portlet "CustomerPortlet" inside it.

Creating the service.xml File

After creating a portlet application, you need to create a service.xml file inside the portlet application.

To Create a service.xml File

  1. From the CustomerApp application, right click on Web Pages and select New > Others > Web Space/Liferay Plugins > Service Builder XML

  2. Enter the file name as service. Make sure the "Folder" is selected as web. Then click Finish.

  3. The service.xml file is created inside the web directory and the IDE opens the service.xml inside the editor area.

You can see two tabs "Design" and "XML" in the editor. The "Design" tab helps the user to add/modify entities through GUI and using "XML", user can directly modify the xml.

Fig: 1


Now we are ready to add entities to our service xml.

To Create Entity

  1. Click on "Add" button.

    The Service Definition window appears. 

  2. Specify the Entity Name as "CustomerDtls" and table name as "CustomerDtls". The Entity name and table name doesn't need to be same.

  3. Now Click "Add". So a new entity called "CustomerDtls" is now created.
  4. Change the default Package Path name to com.sample.customer and namespace to "customer". The namespace should be unique for every portlet application. No two portlet applications should have the same namespace.

Add Columns

After creating an entity, you need to add columns for that entity. So to create columns for an entity

  • Select an entity. 
  • Click "Add" under the Columns tab as shown in the Fig : 3.
 

Fig : 3
  • The Column Details window appears. 
  • Specify the Name of the column as "id" and the column type as long. You can choose the column type as String, Double, and Date from the drop down list. 
  • Select the Primary Key checkbox and click Add. So for this entity, id is the primary key. A column is created with the Column Name as id and type as long
  • Add two more columns with column name name, age with types String, int respectively. 
  • You can see that there are three columns created for the "CustomerDtls" entity. (Fig: 4)
Note: There should be atleast one primary key defined for an entity.
 

                                                    Fig : 4

Add Finder Methods

You can also add your custom finder methods to the entity from "Finders" tab. In "Finders" tab, click "Add Finder" to add finder methods. It provides a GUI where you can select different columns required for your finder methods.(Fig. 5)



Fig. 5

Generating Services

  • From the service.xml GUI editor, click the "Generate Services" button. 
  • You can see the creation of classes, services, and data models that are required for the database interaction. The service api classes are generated under $project/services directory and added to the project classpath. You should not do any modification in those classes as those will be overwritten next time when you run "Generate Service". But the implementation classes which can be modified by the user, are added to the project source path and you can modify them as you want. But after modifying anything in the service implementation classes, you need to run "Generate Service" again.
  • By default the generated service api jar will be bundled inside the portlet war file. But if you want other applications to access your services then the service api jar file needs to be there in the server classpath. You can do that by changing the preference which can be accessed by clicking on "Preferences" button. (Fig: 6)

Fig: 6
  • Now in the GUI editor, click the Local Methods tab. This tab lists local method defined in the local service implementation. Now you can select "Go to Source"  to go the local service implementation. In our example this is "CustomerDtlsLocalServiceImpl.java" file. But we don't need to add any local method for our current example.

Creating the View Page for Customer Portlet

  • From the Projects pane, click the CustomerPortlet_view.jsp file. 
  • Add code to the CustomerPortlet_view.jsp file to create a HTML form to specify the id,name and age of a customer. This jsp also shows the no of customers in the database. Replace the CustomerPortlet_view.jsp code with following code snippets.
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

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

<portlet:defineObjects />
<%PortletPreferences prefs = renderRequest.getPreferences();%>
<table>
<form method="POST" action="<portlet:actionURL/>">

    <tr>
        <td>Customer ID:</td>
        <td><Input type="text" name="id"/></td>
    </tr>
    <tr>
        <td>Name:</td>
        <td><Input type="text" name="name"/></td>
    </tr>
    <tr>
        <td>Age:</td>
        <td><Input type="text" name="age"/></td>
    </tr>
    <tr>
        <td><Input type="submit"/></td>
    </tr>
</form>
</table>
<H3> No of Customers in Database :
    <%
        out.println(CustomerDtlsLocalServiceUtil.getCustomerDtlsesCount());
    %>
</H3>

 

  • From the Projects pane, click the CustomerPortlet.java file under the com.test package. Add the following code to processAction method. This method gets the data from the browser and add customer details to the database.
public void processAction(ActionRequest request, ActionResponse response) throws PortletException,IOException {
     
        try {
            long id = Long.parseLong(request.getParameter("id"));
            String name = request.getParameter("name");
            int age = Integer.parseInt(request.getParameter("age"));
            CustomerDtls customer = CustomerDtlsLocalServiceUtil.createCustomerDtls(id);
            customer.setId(id);
            customer.setName(name);
            customer.setAge(age);
            CustomerDtlsLocalServiceUtil.addCustomerDtls(customer);
            System.out.println("Added");
        } catch (Exception ex) {
            ex.printStackTrace();
           
        }
    }

 

Deploy And Test

So we are now ready to deploy the portlet application. Right click on the portlet project and select "Deploy" to deploy the portlet on Liferay Portal Server. I am assuming you have selected "Liferay Portal Server"  as runtime for the portlet application. The required table is created automatically during the deployment time, so ideally you don't need to create the table manually. But incase you get "Table not Found Exception" while accessing the portlet, you can run the generated table.sql manually to create the required tables. The table.sql can be found under "WEB-INF/sql" directory.

Now access your liferay portal from the browser and add the new "CustomerPortlet" to a page. You can see a simple form for customer data and below that no of customers in database which is initially "0". Now try to add a customer and after successful addition of data to the database, the "No of Customers in Database" will be changed to 1.
 
Fig: 7
Portal Pack 3.0 : Available for download !!!

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.

 

Some of the Key Features in Portal Pack 3.0
  • Support for 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 Liferay Portal Server and Sun GlassFish Web Space Server 10.0.
  • Use Liferay's service builder framework inside your portlet. A new advanced Service XML editor is introduced to help you define and generate services.
  • Use Liferay's service apis directly to write advanced portlets.
  • Use Taglibs provided by Liferay directly inside your Portlet. For example : You can use rich ui taglibs provided by Liferay 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.

Showing 1 - 5 of 7 results.
Items: 5
Page: of 2