Saturday, November 30, 2013

How to upgrade to PrimeFaces 4 from PrimeFaces 3.x

It is simple to upgrade from PrimeFaces 3.x to PrimeFaces 4.0
What need to do is only remove the primefaces-3.x.jar, then add the primefaces-4.0.jar into application lib folder.


Wednesday, November 27, 2013

How to export database with Oracle SQL Developer

1. Open Oracle SQL Developer

2. Tools > Database Export...

3. -Browse for the export file location
    -Choose configured database connection to export
    -If wish to proceed to summary directly, then check Proceed to summary
    -Click Next

Sunday, November 24, 2013

Thursday, November 21, 2013

Adding JBoss AS7 Server Plugin in Eclipse

Add JBoss Server Runtime

1. Open Server Runtime Environments
    Window > Preferences > Server > Runtime Environments

2. Click Add to open New Server Runtime Environment dialog > Next

Monday, November 18, 2013

Portlet localization in Liferay

There is no question that Liferay portal supports localization.
But how the localization support for Portlet deployed in Liferay When locale changed?

To support localization for our own developed portlet.
1. Produce different resource bundle for different languages.
    a) By default, Portlet developed with Liferay Plugin SDK comes with a resource bundle named as
    b) duplicate, then rename it to suit other locale. eg,

    c) replace all the bundle keys with new bundle description.

2. add the new resource bundle into liferay-hook.xml


Friday, November 15, 2013

How to create runnable/executable jar with Eclipse

Assuming I have the following project structure in Eclipse

and following code for
package test;

import javax.swing.JFrame;
import javax.swing.JLabel;

public class RunnableJarFrame extends JFrame {

 private static final long serialVersionUID = 1L;
 public static void main(String args[]) {
  new RunnableJarFrame();
 RunnableJarFrame() {
  JLabel jlb = new JLabel("Runnable Test");
  this.setSize(200, 100);

Tuesday, November 12, 2013

How to get Liferay portlet id from URL

For users with Administrator authority, the portlet id could be retrieve from Plugins Configuration.

For users without Administrator authority, portlet id still can be retrieved from the browser URL.

1. Click on the maximized icon of the target portlet

2. Then copy the URL from the browser address bar into a text editor, eg. notepad

3. search for the following text

    and we get the Portlet id value is 116.


Saturday, November 9, 2013

How to get HttpServletRequest and HttpServletResponse from JSF Portlet context in Liferay

// get PortletRequest from JSF Portlet context
PortletRequest portletRequest = (PortletRequest) FacesContext

// convert the PortletRequest object to HttpServletRequest object
HttpServletRequest servletRequest = PortalUtil

// get PortletResponse from JSF Portlet context
PortletResponse portletResponse = (PortletResponse) FacesContext

// convert PortletResponse object to HttpServletResponse object
HttpServletResponse servletResponse = PortalUtil

Thursday, November 7, 2013

How to get HttpServletRequest and HttpServletResponse from a JSF context

// Servlet request from JSF context
HttpServletRequest request = FacesContext.getCurrentInstance()

// Servlet response from JSF context
HttpServletResponse response = FacesContext.getCurrentInstance()

Tuesday, November 5, 2013

How to get parameter's value from URL in Liferay Portlet

To get a parameter's value from URL, eg
from a normal web application.
We just need to get the parameter from the request.
String myName = request.getParameter("myName");  // value is kian

But in Liferay web application, It is unable to get the parameter easily with the above code.
Because the request object in Liferay is a modified PortletRequest insted of HttpServletRequest.

Thus, the first step to request a parameter value from Liferay URL, is to convert the PortletRequest object to HttpServletRequest.
HttpServletRequest request = PortalUtil
 .getHttpServletRequest((PortletRequest) FacesContext

HttpServletRequest oriRequest = PortalUtil

Then we can get parameter's value like the above code.
String myName = oriRequest.getParameter("myName");  // value is kian


Saturday, November 2, 2013

How to invoke action before a view is rendered

There is a new component since JSF2.0 & JSF2.1 that can invoke a listener at the defined type of JSF event.
If is <f:event />

To invoke action/listener before a view is rendered,
The type event to be used is preRenderView
and this event type is available since JSF2.1

<f:event type="preRenderView" listener="#{myBean.preRenderViewListener}" />

with the above sample code, #{myBean.preRenderViewListener} will be invoked before the view is rendered.


Related Posts Plugin for WordPress, Blogger...