Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
In Liferay, How to display control date in page JSP?
I send attachment file.


please help me to solve this problem.
Thanks
Kientt


please help me to solve this problem.
Thanks
Kientt
Hi Kien,
Can you explain in some more detail.So, that i can help you.
Thanks
Anil Sunkari
Can you explain in some more detail.So, that i can help you.
Thanks
Anil Sunkari
I have a JSP page. I want to display the date on it and then saved to the database.
like page below

Thanks,
Kientt
like page below

Thanks,
Kientt
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
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
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
Regards
Anil Sunkari