Saturday, August 31, 2013

How to hide Liferay's portlet border

This post is to show how to hide the Portlet border.
In certain cases, hiding the Portlet border could beautify the page especially when the page layout is single column.

1. Login to Liferay as Administrator or Super user.

2. on any portlet, click on the Options button, then Look and Feel.

3. In the Look and Feel dialog, change the Show Borders to NO, then Save.

4. Refresh the current page.


Wednesday, August 21, 2013

Self_Note: Weblogic remote EJB lookup string

<remote_interface> beanRemote = (<remote_interface>) context.lookup("mappedName#qualified_name_of_businessInterface");

NumberService service = (NumberService)context.lookup("NumberCreator#coreservlets.bean.NumberService");

for the below 

package coreservlets.bean;
import javax.ejb.*;
public class NumberServiceBean implements NumberService {
    public double getNumber(double range) {
        return(Math.random() * range);

Tuesday, August 20, 2013

How to generate Alphanumeric with Apache commons-id

Instead of numeric sequence number, alphanumeric sequence may more occurrences.
Because a single number has only 10 occurrences (0-9), but a single alphanumeric sequence has 36 occurrences (0-9 + a-z).

It is a tedious work if we write our own codes to generate the alphanumeric sequence.
There is an easy way with Apache commons id.

Apache commons id is not release yet, but we can download it here.
Although using a pre-release library is not a good practice, but use only 1 class/function should be not a big issue.

Saturday, August 17, 2013

How to display meaningful element name when exception

During form validation in JSF, by default exception(s) thrown will display the element's client id. 

But that is meaningless to the system users, because the client id is not tally with the corresponding element label. 

How to open Liferay Plugins sdk in Eclipse

During Liferay development with Eclipse, it is better to open Liferay Plugin SDK in Eclipse.
Thus it is good to tick the checkbox "Open in Eclipse" when adding Liferay Plugin SDK.

But, when adding Liferay Plugins sdk into Eclipse, we might missed out the checkbox to Open the plugins in Eclipse.

Export/Import Liferay Portlet project in Eclipse

sometimes, we might want to export our portlet project to backup or share it with friends/colleagues.

The export of portlet project is straight forward. We can use the Eclipse export project as archive to achieve this purpose, for more details please refer here.

But the import is not that straight forward.

following are the steps to import a Liferay portlet project.
1. Start the Import wizard
    File > Import... > General > Archive File > Next

Tuesday, August 13, 2013

Obfuscation with yGuard and Ant

Obfuscation is the action to create source code that is difficult for human to understand.
It is very important for enterprise java applications to protect project's source code easily viewed by others.

After trying ProGuard and yGuard, found that yGuard is pretty simple compare to ProGuard.

Below are the simplest steps to obfuscate a JAR with with yGuard.
1. download yGuard here.

2. extract and locate the yguard.jar at the same folder with Ant build.xml.

3. add the following target into the Ant build file.
<target depends="pakage-jar" name="yguard">
  <taskdef name="yguard" classname="com.yworks.yguard.YGuardTask"
    <inoutpair in="PROJECT_NAME.jar" out="PROJECT_NAME_OBJ.jar"/>
     <shrink />

change the PROJECT_NAME.jar that generated from the package-jar.
change the PROJECT_NAME_OBJ.jar to target destination.

4. more complicated example could refer yguard_ant_howto.html that comes with the yguard download.


Friday, August 9, 2013

How to use Spring in a Liferay Portlet

This post shows how add Spring into a Liferay portlet.
In certain cases, we might need to have IoC in our existing application. eg, lookup configuration from xml.
adding Spring in our application might ease the xml lookup.

1. add Spring jar from Liferay classpath
    a) add the following Spring libraries into an existing Liferay portlet project from Liferay Portal
    refer this post to know how to add Liferay Portal libraries into a portlet.

Sunday, August 4, 2013

Adding liferay libraries to customized portlet classpath

When developing customized portlet in Liferay, a lot of libraries might be needed, especially open-source library. eg jstl, commons-fileupload, commons-collection, etc

Some of these libraries are being used in Liferay Portal, thus we can actually reusing it.
this can reduce the memory usage and possibilities of conflict.

1. Make sure Liferay development properly setup.

How to generate javadoc with Eclipse

This post shows how to generate javadoc for projects created in Eclipse.
Before the javadoc could be generated, comments must be available in class level and method level.
otherwise, we can only see the class and available methods without any description.

1. insert comments
    a) key in /**
    b) press Enter
    c) insert comments inside the commented area for class and method.
creating comments for class and method

Thursday, August 1, 2013

How to quickly unlock expired Oracle database users

This post is a self note on unlocking an expired oracle database user.

OS: window

1. Open command prompt, and execute the following command
sqlplus sys/[PASSWORD] @ [SID] as sysdba

2. View expired users with the following command
Select username, account_status from dba_users where account_status like 'EXPIRED';

3. Activate user with the following command
Alter user [USERNAME] identified by [PASSWORD];



Related Posts Plugin for WordPress, Blogger...