|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ervacon.springframework.web.servlet.mvc.webflow.WebFlowUtils
Static utility methods used by the Spring web flow system and applications that use it.
This class provides web transaction token handling methods similar to those available in the Struts framework. In essense an implementation of the synchronizer token pattern. You can use this to prevent double submits in the following way:
WebFlowUtils.saveToken(model, "token")
to put a unique transaction token in the flow model.
<INPUT type="hidden" name="_token" value="<%=request.getAttribute("token") %>">
WebFlowUtils.isTokenValid(model, "token", request, "_token", true)
in the action that processes the transactional data. If the token
is valid you do real processing, otherwise you return some event
to indicate an alternative outcome (e.g. an error page).
| Method Summary | |
static java.lang.String |
generateUniqueId()
Generate a pseudo unique id. |
static WebFlowMementoStack |
getWebFlowMementoStack(javax.servlet.http.HttpServletRequest request,
java.util.Map model)
Retreive the web flow memento stack for the currently executing flow. |
static WebFlowMementoStack |
getWebFlowMementoStack(javax.servlet.http.HttpServletRequest request,
java.util.Map model,
java.lang.String flowIdModelName)
Retreive the web flow memento stack for the currently executing flow. |
static boolean |
isTokenValid(java.util.Map model,
java.lang.String tokenName,
javax.servlet.http.HttpServletRequest request,
java.lang.String requestTokenName,
boolean reset)
Return true if there is a transaction token stored in
given model, and the value submitted as a request
parameter with this action matches it. |
static void |
resetToken(java.util.Map model,
java.lang.String tokenName)
Reset the saved transaction token in given model. |
static void |
saveToken(java.util.Map model,
java.lang.String tokenName)
Save a new transaction token in given model. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static java.lang.String generateUniqueId()
Generate a pseudo unique id. This implementation uses the system time and a random number to generate an id. The generated id should be unique enough for flow ids or tokens, but it is certainly not a globally unique id.
public static WebFlowMementoStack getWebFlowMementoStack(javax.servlet.http.HttpServletRequest request,
java.util.Map model)
Retreive the web flow memento stack for the currently executing flow.
This method will first obtain the id of the currently executing flow from
given model using the WebFlowController.FLOW_ID_MODEL_NAME name.
With this id, it will get the flow memento stack from the session
associated with given request.
request - current HTTP requestmodel - model of the flow
public static WebFlowMementoStack getWebFlowMementoStack(javax.servlet.http.HttpServletRequest request,
java.util.Map model,
java.lang.String flowIdModelName)
Retreive the web flow memento stack for the currently executing flow. This method will first obtain the id of the currently executing flow from given model using the given name. With this id, it will get the flow memento stack from the session associated with given request.
Use this method if you changed the name of the flow id in the model
using the WebFlowController.setFlowIdModelName(String) method.
request - current HTTP requestmodel - model of the flowflowIdModelName - name of the flow id in the model
public static void saveToken(java.util.Map model,
java.lang.String tokenName)
Save a new transaction token in given model.
model - the model map where the generated token should be savedtokenName - the key used to save the token in the model map
public static void resetToken(java.util.Map model,
java.lang.String tokenName)
Reset the saved transaction token in given model. This indicates that transactional token checking will not be needed on the next request that is submitted.
model - the model map where the generated token should be savedtokenName - the key used to save the token in the model map
public static boolean isTokenValid(java.util.Map model,
java.lang.String tokenName,
javax.servlet.http.HttpServletRequest request,
java.lang.String requestTokenName,
boolean reset)
Return true if there is a transaction token stored in
given model, and the value submitted as a request
parameter with this action matches it. Returns false when
model - the model map where the token is storedtokenName - the key used to save the token in the model maprequest - current HTTP requestrequestTokenName - name of the request parameter holding the tokenreset - indicates whether or not the token should be reset after checking it
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||