Implementation of the "Synchronizer Token Pattern" for Grails that handles duplicate form submissions by inspecting a token stored in the user session.
Type | Name and description |
---|---|
protected boolean |
isTokenValid(GrailsWebRequest webRequest) Checks whether the token in th request is valid. |
protected java.lang.Object |
resetToken(GrailsWebRequest webRequest) Resets the token in the request |
TokenResponseHandler |
withForm(GrailsWebRequest webRequest, groovy.lang.Closure callable) |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Checks whether the token in th request is valid.
request
- The servlet requestResets the token in the request
Main entry point, this method will check the request for the necessary TOKEN and if it is valid will call the passed closure.
For an invalid response an InvalidResponseHandler is returned which will invoke the closure passed to the handleInvalid method. The idea here is to allow code like:
withForm {
// handle valid form submission
}.invalidToken {
// handle invalid form submission
}