Saturday, September 28, 2013

Liferay Portlet Displaying AUI Date Time

Liferay  Portlet Displaying  AUI Date Time.

Objective:

Display date time and date with different ways in liferay development.
I have displayed date and date time using life ray dete picker. Liferay date picker display date with minimal code in jsp so that we can display date or calendar in different ways.
I have created different dates or calendar in different ways and in back end means action class I collected selected date.
I have collected date in different ways like direct date format, date as string format and date as mille seconds,

Download the liferay portlet from following URL


I am providing war file and source code portlet. You can directly place war file your liferay portal deploy folder it will be deployed.
The port let available in sample category as Display Date Action.
The following is sample code to display date:
The following is jsp code


<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<div id="myDatePicker" class="aui-datepicker aui-datepicker-display aui-helper-clearfix">
</div>
<aui:input name="startDateHidden" id="startDateHidden" type="hidden"  value="" ></aui:input>
<aui:script>
var startDatePicker;
AUI().use(
  'aui-datepicker',
  function(A) {
    startDatePicker=new A.DatePickerSelect(
      {
     appendOrder: ['m', 'd', 'y'],
        calendar: {
        dateFormat: '%m/%d/%Y',
         
        }
      }
    ).render('#myDatePicker');

 function submitForm(){
       var startDate;
       var endDate;   
    A.one("#<portlet:namespace/>startDateHidden").
set('value',startDatePicker.calendar.getFormattedSelectedDates ()[0]); 
  document.<portlet:namespace/>date.submit();
}
</aui:script>


Action class getting date:


DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
Date startDate=ParamUtil.getDate(actionRequest,"startDateHidden", dateFormat);
String startDateString=ParamUtil.getString(actionRequest,"startDateHidden");


Important Points:


  •        Display only date using AUI library
  •     Display Date in different formats
  •        Display date and time using AUI and liferay Time tag.
  •     Get the date in action class in different formats.
  •        Validate two dates.
Note:

  •  I have done this in liferay 6.1 CE. If you are using other version simple use my code.
  • All out put you can see in console. In console you can see all information.
  •  For more details you can walk through jsp code and action class code.

Screen Shots:



The following are reference links



1 comment :

  1. Prepare for ServiceNow CIS-RCI exam with our preparation material with full confidence. We offer you 100% real Certified Implementation Specialist – Risk and Compliance Exam ServiceNow CIS-RCI exam dumps for your better results. Prepare4Test’s CIS-RCI pdf dumps are verified by ServiceNow Gurus.

    ReplyDelete

Recent Posts

Recent Posts Widget

Popular Posts