KocsisDaniel/liferay-portal — pull request #116 by vilmospapp (2012-09-05 09:17:24+00:00)
Title: [TECHNICAL SUPPORT] LPS-27343 Added currentURL as fallback when redirect URL is not specified

Hi Dani,

As we discussed I review the solution and found it suitable. I've tested it against navigation from the Dockbar and from the My Account Control Panel menu item as well. Also verified that Users and Organization still works as before so the fix doesn't have any negative affect on it.

Just to remind you here are my notes from the former pull request:

If user navigates to Control Panel > My Account and edits a field e.g. Phone Number with invalid data, after pressing Save he receives an error. After the error message shown, if Cancel is pressed, a PrincipalException is thrown in the log, and the portlet becomes unavailable.

This is not the case if we navigate from Users and Organization.

The problem is that the "redirect" is not set in My Account so backURL gets an empty string as a value. If this is the case liferay-ui:form-navigator generates a link for Cancel button which tries to uses location.href and updates it with removed part started with '#'. Since saving rewrites the URL there's no # in it the location.href won't be changed but called again instead of navigate back to the portlet's default view.

I simply check whether backURL remains empty after reading it's value and if it's still empty, I set currentURL to it so backURL will always have a valid redirect to navigate back.

Please let me know if you have any concerns.

Regards,
Vili