Wednesday, August 27, 2014

How to define Default Action in PrimeFaces

This is to define what action to be executed when the "Enter" is press.

There is easy-to-use component in PrimeFaces to get this done.

<p:defaultCommand target="btn2" />

<p:commandButton id="btn1" action="#{myBean.action1}" />
<p:commandButton id="btn2" action="#{myBean.action2}" />
<p:commandButton id="btn3" action="#{myBean.action3}" />

with the above code, when user press on "Enter", action to be executed is #{myBean.action2} that bind to <p:commandButton id="btn2" />


Thursday, August 14, 2014

How to quickily clone an object in java

To quickly clone an java object, including all the children and relationships.
may consider to use SerializationUtils in Apache Commons Lang.

it's just easy with  1 line of code

MyObject newObject = (MyObject) SerializationUtils.clone(objectToClone);


Thursday, August 7, 2014

Liferay admin password used in Liferay Web Service

Recently discovered that the Liferay admin's password used for the Liferay remote services.
must be without "@".

Liferay API will extract from "@" until the "/" to be the target service host.

eg. adminPassword@
meaning from the above example, will be extracted as the target host.

somehow if the adminPassword contains "@", the API will extract from the adminPassword.

eg: adminP@ssword@
now the host becomes @ssword@

with this adminP@ssword, Liferay API will throw an unknownHostException.

conclusion, @ not allowed in the Liferay Admin password to be used in Liferay web service.


Wednesday, August 6, 2014

Soft Delete with JPA and EclipseLink

Assuming I have the following table.

And my entity
public class Item {
    private Long itemId;
    private String itemName;
    private Integer itemStatus;

    // getter and setter

for AUDITING purpose, hard delete is not encouraged.
thus, when deleting a record, the ITEM_STAUS changes to 2 (deleted).

and I have the following status code
0 - active
1 - inactive
2 - deleted

Monday, August 4, 2014


There is a new feature introduced in JSF2.x,
Which is the javax.faces.PROJECT_STAGE in the web.xml.

When creating a new JSF2.x project, the default value is “Development”.
When going into Production environment, the value should be changed to “Production”
To reduce logs, and avoid re-download of static resources (js, css, images, etc), and all the static resources will be cached in the client machine.

Besides, if this parameter remove from web.xml, the default value is "Production"




Related Posts Plugin for WordPress, Blogger...