Hi, thanks for your code snippet. It is really helpful, but the getInteger methods in the portlet all return "0".
This is my JSP Code, which is quite the same as your
1
2<table>
3 <tr>
4 <td align="left" class="greyText" style="padding-top:10px; vertical-align:top;">From Date</td>
5 <td align="left" style="padding-left:23px;">
6 <aui:fieldset>
7 <aui:field-wrapper>
8 <liferay-ui:input-date
9 dayParam="fromDateDay"
10 dayValue="<%= cal.get(Calendar.DATE) %>"
11 disabled="<%= false %>"
12 firstDayOfWeek="<%= cal.getFirstDayOfWeek() - 1 %>"
13 monthParam="fromDateMonth"
14 monthValue="<%= cal.get(Calendar.MONTH) %>"
15 yearParam="fromDateYear"
16 yearValue="<%= cal.get(Calendar.YEAR) %>"
17 yearRangeStart="<%= cal.get(Calendar.YEAR) - 60 %>"
18 yearRangeEnd="<%= cal.get(Calendar.YEAR) + 60 %>"
19 />
20 </aui:field-wrapper>
21 </aui:fieldset>
22 </td>
23 </tr>
24 </table>
25 <table>
26 <tr>
27 <td align="left" class="greyText" style="padding-top:10px; vertical-align:top;">To Date</td>
28 <td align="left" class="greyText" style="padding-left:36px;">
29 <aui:fieldset>
30 <aui:field-wrapper>
31 <liferay-ui:input-date
32 dayParam="toDateDay"
33 dayValue="<%= cal.get(Calendar.DATE) %>"
34 disabled="<%= false %>"
35 firstDayOfWeek="<%= cal.getFirstDayOfWeek() - 1 %>"
36 monthParam="toDateMonth"
37 monthValue="<%= cal.get(Calendar.MONTH) %>"
38 yearParam="toDateYear"
39 yearValue="<%= cal.get(Calendar.YEAR) %>"
40 yearRangeStart="<%= cal.get(Calendar.YEAR) - 60 %>"
41 yearRangeEnd="<%=cal.get(Calendar.YEAR) + 60 %>"
42 />
43 </aui:field-wrapper>
44 </aui:fieldset></td>
45 </tr>
46 </table>
Portlet Code:
1
2package com.test;
3
4import java.io.IOException;
5import java.util.Date;
6
7import javax.portlet.ActionRequest;
8import javax.portlet.ActionResponse;
9import javax.portlet.PortletException;
10
11import com.liferay.portal.kernel.exception.PortalException;
12import com.liferay.portal.kernel.util.ParamUtil;
13import com.liferay.portal.util.PortalUtil;
14import com.liferay.util.bridges.mvc.MVCPortlet;
15
16public class VeranstaltungsPortlet extends MVCPortlet {
17
18 public void machen(ActionRequest actionRequest, ActionResponse actionResponse)
19 throws IOException, PortletException{
20 // Getting the Date Range
21 int fromDay = ParamUtil.getInteger(actionRequest, "fromDateDay");
22 int fromMonth = ParamUtil.getInteger(actionRequest, "fromDateMonth");
23 int fromYear = ParamUtil.getInteger(actionRequest, "fromDateYear");
24 int toDay = ParamUtil.getInteger(actionRequest, "toDateDay");
25 int toMonth = ParamUtil.getInteger(actionRequest, "toDateMonth");
26 int toYear = ParamUtil.getInteger(actionRequest, "toDateYear");
27 System.out.println("FromDay: "+fromDay+" FromMonth: "+fromMonth+" FromYear: "+fromYear);
28 System.out.println("FromDay: "+toDay+" FromMonth: "+toMonth+" FromYear: "+toYear);
29// Get Date Range
30 Date fromDate = getDate(fromMonth, fromDay, fromYear);
31 Date toDate = getDate(toMonth, toDay, toYear);
32 }
33
34//To get the Actual Date Make a Call to the Method Below:
35
36public static Date getDate(int month, int day, int year){
37
38 Date finalDate = null;
39
40
41 try {
42 finalDate = PortalUtil.getDate(month, day, year, new PortalException());
43 } catch (PortalException e) {
44 // TODO Auto-generated catch block
45 e.printStackTrace();
46 }
47
48
49 return finalDate;
50}
51 }
Do you have any idea why?
I am using LR 6.1 RC.
Please sign in to flag this as inappropriate.