掲示板

Need to Preserve Parameters for Browser Back Button or Refresh in Liferay 7

7年前 に John Lulich によって更新されました。

Need to Preserve Parameters for Browser Back Button or Refresh in Liferay 7

New Member 投稿: 10 参加年月日: 16/04/19 最新の投稿
Does anybody know if there is a way to preserve request params in a portlet in Liferay 7 so that if the user clicks the browser back or refresh buttons, the parameters persist and allow the pages to load correctly?

I've got a custom portlet that provides the user with a text field for searchCriteria. The page submits to an MVCRenderCommand which gets the searchCriteria via ParamUtil.getString(renderRequest, "searchCriteria") in the render method. A lookup is performed, and results are displayed in the view_results.jsp. However, if the user clicks the browser back button, the data is wiped from the searchCriteria field. Worse yet, if they accidentally refresh the view_results page, the params are not preserved, eventually causing the read to fail. We would also like the user to be able to bookmark the search results, but this also fails.

I can't find any decent solution to this, and I'm hoping someone can point me in the right direction.

Many thanks,
John
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Need to Preserve Parameters for Browser Back Button or Refresh in Lifer

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
John Lulich:
Does anybody know if there is a way to preserve request params in a portlet in Liferay 7 so that if the user clicks the browser back or refresh buttons, the parameters persist and allow the pages to load correctly?


This is not a liferay issue, it is the nature of the back button. Browsers do not allow the pages to tamper with the back button in any way as it would be a huge security hole.
7年前 に John Lulich によって更新されました。

RE: Need to Preserve Parameters for Browser Back Button or Refresh in Lifer (回答)

New Member 投稿: 10 参加年月日: 16/04/19 最新の投稿
I figured out my mistake, so I thought I'd include it here in case it could help anybody else.

In my portlet, I only have two pages...view.jsp and view_results.jsp. In my view.jsp, I had set a renderURL with the redirect param; however, in the view_results jsp, I had not included it. Simply including this in my view_results.jsp made everything work the way I had expected.

<portlet:renderurl var="searchRenderURL">
	<portlet:param name="mvcRenderCommandName" value="/my-app/find" />
	<portlet:param name="redirect" value="${currentURL}" />
</portlet:renderurl>