Tuesday, October 28, 2014

Loop index in Apache Velocity

To get the loop index in Velocity template,
we need to initiate a temporary index variable, and increase the variable count by 1 after every occurrence in the loop.

#set( $count = 1 )
#foreach( $customer in $customers )
#set( $count = $count + 1 )

the idea is what we have in the for loop.
int count = 1;
for(Customer c : customerList) {


How to disable row selection in PrimeFaces datatable

This is not a official/proper way to disable the row selection in <p:dataTable />
But a workaround since there is no way to disable the row selection at the moment.

assuming we have the following dataTable.
    ..... />

    <p:column selectionMode="multiple" />
    <p:column .... />


To disable row selection in the above <p:dataTable />
we need to add <p:ajax /> into the <p:dataTable />

Thursday, October 23, 2014

How to check system configured properties in Liferay

There are a lot of  properties/attributes configured in Liferay.
All these configured System Properties and Portal Properties could be accessed through Server Administration.

1. Login as Liferay Administrator

2. Liferay 6.1.x
    Go to > Control Panel > Server > Server Administration > Properties

Wednesday, October 22, 2014

How to set max date and min date in <p:calendar />

The maxdate and mindate attribute is extremely useful for setting available date range for user selection.

-Expiry date of an item should not be less than today.
-Date of birth should not be future date.

So how to set maxdate and mindate in PrimeFaces calendar component?

1. create the java.util.date object in backingBean
private Date currentDate = new Date();

public Date getCurrentDate() {

    return currentDate;

2. set the java.util.date object as mindate or maxdate
<p:calendar value="#{bean.expiryDate}" mindate="#{bean.currentDate}" />

<p:calendar value="#{bean.birthDate}" maxdate="#{bean.currentDate}" />


Tuesday, October 21, 2014

How to display dynamic PDF document with <p:media /> component

From the PrimeFaces showcase, the media component used to display PDF document
But the showcase uses a static PDF document.

In real life, we might want to display different PDF documents by different use cases,
or a runtime generated PDF document.

To achieve the above purpose, we need to use the value attribute in <p:media /> component by passing in a StreamedContent from backingBean.

1. BackingBean method that return StreamedContent.
public StreamedContent getPdfDocument() {  

     // logic to generate the PDF  

    return new DefaultStreamedContent(pdfInByteArrayInputStream, "application/pdf");

2. display the PDF content with <p:media /> component.

<p:media value="#{myBean.pdfDocument}" width="100%" height="500px" player="pdf" />


Tuesday, October 14, 2014

How to shutdown Liferay with warning and timeout to the users

There is a smarter way to shutdown Liferay.
Where Liferay allowed the system administration to enter the shutdown time and warn all logged in users regarding shutdown of the Portal.
Thus, all logged in users can quickly save their works without losing any data.

Platform: Liferay 6.2.x

1. Login as Liferay Admin
2. Admin > Control Panel > Configuration > Server Administration > Shutdown


Related Posts Plugin for WordPress, Blogger...