<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Liferay 7.2 - Refreshing view.jsp</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=114667754" />
  <subtitle>Liferay 7.2 - Refreshing view.jsp</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=114667754</id>
  <updated>2026-04-03T19:09:04Z</updated>
  <dc:date>2026-04-03T19:09:04Z</dc:date>
  <entry>
    <title>RE: Liferay 7.2 - Refreshing view.jsp</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114699498" />
    <author>
      <name>Fabio Carvalho</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114699498</id>
    <updated>2019-08-09T10:54:24Z</updated>
    <published>2019-08-09T10:54:24Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;You are a lifesaver Mohammed!&lt;br&gt;&lt;br&gt;It is working! I ended with something like this:&lt;br&gt;&lt;pre&gt;&lt;code&gt;@Override
public void processAction(ActionRequest request, ActionResponse response) throws IOException, PortletException {
&amp;amp;nbsp; &amp;amp;nbsp; request.setAttribute("start-date", ParamUtil.getLong(request, "startDate"));
&amp;amp;nbsp; &amp;amp;nbsp; request.setAttribute("end-date", ParamUtil.getLong(request, "endDate"));
&amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;super.processAction(request, response);
}
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;And in my view.jsp:&lt;pre&gt;&lt;code&gt;&amp;lt;portlet:defineobjects /&amp;gt;
&amp;lt;portlet:actionurl var="filterURL" /&amp;gt;

&amp;lt;aui:form name="filterForm" action="${filterURL}" method="post"&amp;gt;
&amp;amp;nbsp; &amp;amp;nbsp; &amp;lt;aui:input id="startDate" name="startDate" type="hidden" /&amp;gt;
&amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;&amp;lt;aui:input id="endDate" name="endDate" type="hidden" /&amp;gt;
&amp;lt;/aui:form&amp;gt;
​​​​​​​
&amp;lt;input type="text" name="dateFilter"&amp;gt;
&amp;lt;script type="text/javascript"&amp;gt;
&amp;nbsp; &amp;nbsp; $(function() {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $('input[name="dateFilter"]').daterangepicker({
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; endDate: moment(),
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; maxDate: moment()
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });
&amp;nbsp;&amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $('input[name="dateFilter"]').on('apply.daterangepicker', function(ev, picker) { &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var startDate = new Date(picker.startDate.toString());
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $("#&amp;lt;portlet:namespace/&amp;gt;startDate").val(startDate.getTime());
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var endDate = new Date(picker.endDate.toString());
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $("#&amp;lt;portlet:namespace/&amp;gt;endDate").val(endDate.getTime());
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $("#&amp;lt;portlet:namespace/&amp;gt;filterForm").submit();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });
&amp;nbsp; &amp;nbsp; });
&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Fabio Carvalho</dc:creator>
    <dc:date>2019-08-09T10:54:24Z</dc:date>
  </entry>
  <entry>
    <title>RE: Liferay 7.2 - Refreshing view.jsp</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114689382" />
    <author>
      <name>Mohammed Yasin</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114689382</id>
    <updated>2019-08-08T22:07:58Z</updated>
    <published>2019-08-08T22:07:58Z</published>
    <summary type="html">You can have that date picker inside a form and have a submit button  something like&lt;br /&gt;&lt;br /&gt;&amp;lt;aui:form action=&amp;#34;${filterURL}&amp;#34;&amp;gt;&lt;br /&gt;   &amp;lt;aui: input type=&amp;#34;text&amp;#34; id=&amp;#34;daterange&amp;#34; /&amp;gt;&lt;br /&gt;   &amp;lt;aui:button type=&amp;#34;submit&amp;#34; value=&amp;#34;save&amp;#34; /&amp;gt;&lt;br /&gt;&amp;lt;/aui:form&amp;gt;&lt;br /&gt; &lt;br /&gt;If you want to have start and end date you can have hidden input which you can set in javascript and then submit from javascript also.</summary>
    <dc:creator>Mohammed Yasin</dc:creator>
    <dc:date>2019-08-08T22:07:58Z</dc:date>
  </entry>
  <entry>
    <title>RE: Liferay 7.2 - Refreshing view.jsp</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114668198" />
    <author>
      <name>Fabio Carvalho</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114668198</id>
    <updated>2019-08-08T16:38:33Z</updated>
    <published>2019-08-08T16:38:33Z</published>
    <summary type="html">Hi Mohammed,&lt;br /&gt;&lt;br /&gt;Thanks for your answer. Yes, I am calling action method through ajax. How can I submit the form?</summary>
    <dc:creator>Fabio Carvalho</dc:creator>
    <dc:date>2019-08-08T16:38:33Z</dc:date>
  </entry>
  <entry>
    <title>RE: Liferay 7.2 - Refreshing view.jsp</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114666708" />
    <author>
      <name>Mohammed Yasin</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114666708</id>
    <updated>2019-08-08T16:18:17Z</updated>
    <published>2019-08-08T16:18:17Z</published>
    <summary type="html">Hi,&lt;br /&gt;  I think your calling action method through ajax that why its not refreshing , you can submit the form and try</summary>
    <dc:creator>Mohammed Yasin</dc:creator>
    <dc:date>2019-08-08T16:18:17Z</dc:date>
  </entry>
  <entry>
    <title>Liferay 7.2 - Refreshing view.jsp</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114667753" />
    <author>
      <name>Fabio Carvalho</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114667753</id>
    <updated>2019-08-08T14:04:17Z</updated>
    <published>2019-08-08T14:04:17Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi,&lt;br&gt;&lt;br&gt;I have the following code in my java class for my portlet:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;@Override
public void doView(RenderRequest request, RenderResponse response) throws IOException, PortletException {
    ThemeDisplay theme = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
		
    long start = 0;
    if (request.getAttribute("start-date") != null) start = (long) request.getAttribute("start-date");
    request.removeAttribute("start-date");
	
    long end = 0;
    if (request.getAttribute("end-date") != null) end = (long) request.getAttribute("end-date");
    request.removeAttribute("end-date");

    List&amp;lt;object&amp;gt; objects = new ArrayList&amp;lt;object&amp;gt;();
    if (start == 0 &amp;amp;amp;&amp;amp;amp; end == 0) objects.addAll(getObjects());
		
    System.out.println(objects.toString());
    super.doView(request, response);
}

@ProcessAction(name="filterByDate")
public void filterByDate(ActionRequest request, ActionResponse response) throws ReadOnlyException {
    request.setAttribute("start-date", ParamUtil.getLong(request, "start-date"));
    request.setAttribute("end-date", ParamUtil.getLong(request, "end-date"));
}&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Now in my view.jsp I have the following:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;pre&amp;gt;&amp;lt;code&amp;gt;&amp;lt;portlet:defineobjects /&amp;gt;
&amp;lt;portlet:actionurl name="filterByDate" var="filterURL" /&amp;gt;

&amp;lt;input type="text" id="daterange"&amp;gt;
&amp;lt;script&amp;gt;
    $(function () {
        $('#daterange').daterangepicker({
	    endDate: moment(),
	    maxDate: moment(),
	    locale: {
                "format": "DD/MM/YYYY",
                "separator": " - ",
            }, function (start, end) {
                var startDate = new Date(start.toString());
                var endDate = new Date(end.toString());
   			
                $.ajax({
                    url : '${filterURL}',
                    type : 'POST',
                    data : {
                        "&amp;lt;portlet:namespace/&amp;gt;start-date": startDate.getTime(),
                        "&amp;lt;portlet:namespace/&amp;gt;end-date": endDate.getTime()
                    }
                });
            });
	
	$('#daterange').on('apply.daterangepicker')
    });
&amp;lt;/script&amp;gt;&amp;lt;/code&amp;gt;&amp;lt;/pre&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Now, this is doing the following: when I start my portlet, the values for the "start" and "end" variables are 0, so I add all my objects and System.out.println them. Then I open my Date Picker, click on submit and the "filterByDate" method is called. After that the "doView" is called again and now the "start" and "end" variables are not 0 and the System.out.println prints an empty list. So this is working until here.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;My problem is that the view.jsp is not refreshed with the new "doView". It is not supposed to refresh? How can I refresh my view with the new information after I submit an ActionURL?&amp;lt;/object&amp;gt;&amp;lt;/object&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Fabio Carvalho</dc:creator>
    <dc:date>2019-08-08T14:04:17Z</dc:date>
  </entry>
</feed>
