struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Chandra.Ravinith...@gxs.com>
Subject RE: Example needed for saveToken
Date Tue, 02 May 2006 09:01:50 GMT
Some useful code:

The action code may look like this.

// Check for a valid token
if(isTokenValid(request)){
// If the token is valid, reset it and perform the business logic
	resetToken(request);
	insertRecord(request);//Business logic call.
	return mapping.findForward(Globals.FORWARD_SUCCESS);
}
else{
	// If not valid, save a new token and forward appropriately
	saveToken(request);
	return mapping.findForward(Globals.FORWARD_INSERT);
}

If the Token is not found in the request, the request will go through
the else block, a Token will be saved, and the user will be directed to
the appropriate page for inputting new data . Assuming a Struts
<html:form> tag is used on that page, the Token will be added
appropriately to the request. When the form is submitted, the request
goes through the if block. By resetting the Token here, we ensure that
if the user clicks back and tries to resubmit the form, the <record>
will not be re-created. 


Chandra

-----Original Message-----
From: starki78 [mailto:starki78@libero.it] 
Sent: Tuesday, May 02, 2006 2:24 PM
To: user
Subject: Example needed for saveToken

Ciao!

I need some mechanism for preventing a user of starting several long
database queries by clicking a submit button.
Therefor I' would like to use the save token of struts.
If the token is not valid the user should get a message and be
redirected to the inputPage.

Where do I have to use saveToken?

Can someone give me an example that works properly?

Thanks!
Starki








---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message