Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -36,7 +36,7 @@ 36 36 {{code language="velocity"}} 37 37 #handleRequest($success) 38 38 #if ($success) 39 - #if ($request.action == 'get' || $request.xpage== 'plain') 39 + #if ($request.action == 'get' || $request.xpage == 'plain') 40 40 ## JavaScript call here. 41 41 Action was successful. 42 42 #elseif ("$!request.xredirect" != '') ... ... @@ -63,6 +63,7 @@ 63 63 ... 64 64 #elseif ("$!request.xredirect" != '') 65 65 ## No-JavaScript here. Redirect and forward error message. 66 + #set ($errorMessageKeyPrefix = "myModule.error.") 66 66 $request.session.setAttribute("${errorMessageKeyPrefix}${request.xredirect}", 'Action was NOT successful') 67 67 $response.sendRedirect($request.xredirect) 68 68 #end ... ... @@ -74,6 +74,7 @@ 74 74 {{code language="velocity"}} 75 75 ... 76 76 #set ($xredirect = $doc.getURL($context.action, $!{request.queryString})) 78 + #set ($errorMessageKeyPrefix = "myModule.error.") 77 77 #set ($errorMessage = $request.session.getAttribute("${errorMessageKeyPrefix}${xredirect}")) 78 78 #if ("$!errorMessage" != '') 79 79 ## Clean the error and display the message. ... ... @@ -88,4 +88,6 @@ 88 88 1. it's already there in both the UI (for sending it as parameter) and the background service (received as parameter) 89 89 1. it acts like a namespace, ensuring that the error will only be displayed for the current page/request. 90 90 93 +Using a prefix as above allows you to have multiple components (wiki macros, gadgets, etc.) in the same page using the same mechanism without collisions. 94 + 91 91 This method works together with the whole purpose for which we are doing the redirect in the first place (so that the user can refresh the page without re-sending the action or re-posting a form), ensuring that after the first display, on a refresh, the error goes away.