Wednesday, August 6, 2014

Soft Delete with JPA and EclipseLink

Assuming I have the following table.

And my entity
@Entity
@Table(name="ITEM")
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

javax.faces.project_stage

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"

reference,
https://blogs.oracle.com/rlubke/entry/jsf_2_0_new_feature2
https://weblogs.java.net/blog/driscoll/archive/2009/09/28/jsf-20-reminder-project-stage


Done!!

Wednesday, July 30, 2014

How to pass parameters through URL in JSF

To pass parameters through URL in a web application, is to append the parameters into the base URL.

eg, www.google.com?parameter1=value1&parameter2=value2&parameter3=value3.

in JSF, it is nice to pass only 1 parameter through the URL.
When more than 1 parameter pass through the URL, an exception will happen.
Whenever "&" symbol appears in the URL, the exception will happen.

to resolve this problem, what we need to do is to encode the "&" symbol or manually append with the encoded value "&"

eg, www.google.com?parameter1=value1&parameter2=value2&parameter3=value3.


Done!!

Sunday, July 6, 2014

How to get Company Id in Liferay

To check company Id in Liferay, we can check from Portal Instance

1. Login as Liferay Administrator.

2. Go to > Control Panel > Server > Portal Instance


Last but not least, the default Company ID in Liferay 6.1.x is 1, default Company ID in Liferay 6.2.x is 10157.


Done!!

Sunday, June 8, 2014

How to show wider year range in PrimeFaces Calendar

By default, the year range is 10 years before and 10 years after.

as shown above, this year is 2014, the year range can only in between 2004-2024.

to display wider range, need to enable the yearRange attribute.

<p:calendar id="pfc1"
    yearRange="c-50:c+10"
    showOn="button"
    navigator="true" />

with the above yearRange settings, the year can display up to 50 years before and 10 years after.
Meaning current year -50 and current + 10.


Done!!

LinkWithin

Related Posts Plugin for WordPress, Blogger...