Fórum

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

John Lulich, modificado 7 Anos atrás.

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

New Member Postagens: 10 Data de Entrada: 19/04/16 Postagens Recentes
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
David H Nebinger, modificado 7 Anos atrás.

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

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
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.
John Lulich, modificado 7 Anos atrás.

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

New Member Postagens: 10 Data de Entrada: 19/04/16 Postagens Recentes
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>