Skip to content Skip to sidebar Skip to footer

In Prg Pattern How To Remove Actionmessage On Refreshing Success Page

To avoid the form resubmission I used POST-Redirect-GET pattern and it is working fine. Now on my registration page(success page) it is showing the ActionMessage 'Review Inserted s

Solution 1:

Use Message Store Interceptor to store action message in your insertReview and retrieve it in your insertReviewDone action. Add action message in insertReview method when you are returning insertReviewDone result.

Also use redirectAction result to redirect to action instead of redirect.

<actionname="insertReview"class = "com.tenkinfo.streamlinedmapnsav.ui.action.WriteReviewAction"method="insertReview"><interceptor-refname="store"><paramname="operationMode">STORE</param></interceptor-ref><interceptor-refname="defaultStack" /><resultname="insertReviewDone"type="redirectAction">insertReviewDone</result><resultname="input"type="tiles">display.writeReview.page</result></action><actionname="insertReviewDone"class = "com.tenkinfo.streamlinedmapnsav.ui.action.WriteReviewAction"method="insertReviewDone" ><interceptor-refname="store"><paramname="operationMode">RETRIEVE</param></interceptor-ref><interceptor-refname="defaultStack" /><resultname="success"type="tiles">display.writeReview.page</result></action>

Solution 2:

Another way, less technical than the (good) one proposed by @AleksandrM, but suitable for every framework out there, not only Struts2, is to place this

<script>
    $(document).ready(function() {
        window.history.pushState("","", location.href);
    });
</script>

in your <head> section. It won't work on old browser with no HTML5 capabilities, though.

Note: jQuery part is not mandatory, it is used just to ensure it is run after the page is loaded, you can run HTML5 pushState() without it.

Post a Comment for "In Prg Pattern How To Remove Actionmessage On Refreshing Success Page"