KocsisDaniel/liferay-portal — pull request #114 by vilmospapp (2012-08-31 11:10:08+00:00)
Title: [TECHNICAL SUPPORT] LPS-27343 Properly set backURL to make cancel button work even after validation errors

Hi Dani,

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