In Liferay, How to display control date in page JSP?

thumbnail
5971289, modified 15 Years ago. Junior Member Posts: 80 Join Date: 9/24/10 Recent Posts
I send attachment file.






please help me to solve this problem.

Thanks

Kientt
thumbnail
3775075, modified 15 Years ago. Expert Posts: 427 Join Date: 8/12/09 Recent Posts
Hi Kien,

Can you explain in some more detail.So, that i can help you.

Thanks
Anil Sunkari
thumbnail
5971289, modified 15 Years ago. Junior Member Posts: 80 Join Date: 9/24/10 Recent Posts
I have a JSP page. I want to display the date on it and then saved to the database.

like page below



Thanks,
Kientt
thumbnail
1284716, modified 15 Years ago. Regular Member Posts: 124 Join Date: 9/9/08 Recent Posts
Hi,

In your jsp you can use

<liferay-ui:input-date
formName='<%= "<portlet:namespace />fm" %>'
dayParam='<%= "startDate" + "Day" %>'
dayValue="<%=startDateDayValue%>"
dayNullable="<%= true %>"
monthParam='<%= "startDate" + "Month" %>'
monthValue="<%=startDateMonthValue%>"
monthNullable="<%= true %>"
yearParam='<%= "startDate" + "Year" %>'
yearValue="<%=startDateYearValue%>"
yearNullable="<%= true %>"
yearRangeStart="<%= 2000 %>"
yearRangeEnd="<%= 2040 %>"
firstDayOfWeek="<%= Calendar.SUNDAY - 1 %>"
imageInputId='<%= "ceremonyDate"%>'
disabled="false"
/>


you can set dayValue, monthValue and yearValue according to your requirement.


in Action file you can get like that

int startDateMonth = ParamUtil.getInteger(actionRequest, "startDateMonth");
int startDateDay = ParamUtil.getInteger(actionRequest, "startDateDay");
int startDateYear = ParamUtil.getInteger(actionRequest, "startDateYear");
Date startDate = null;
if (Validator.isNotNull(startDateMonth) && Validator.isNotNull(startDateDay)
&& Validator.isNotNull(startDateYear) && startDateDay > 0
&& startDateYear > 0) {
Calendar startDateCC = Calendar.getInstance();
startDateCC.set(startDateYear, startDateMonth, startDateDay, 0, 0, 0);
startDate= startDateCC.getTime();
}


Regards,

Mohd Masroor
thumbnail
3775075, modified 15 Years ago. Expert Posts: 427 Join Date: 8/12/09 Recent Posts
Have you already taken date in jsp.If yes then you can get the vale in your action class & you can set into DB as per your requirement.If not let me know??

Regards
Anil Sunkari