You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by tu...@jakarta.apache.org on 2005/01/21 04:04:33 UTC
[Jakarta Turbine Wiki] New: Turbine2/UsersGuide/TurbineActionDoubleSubmit
Date: 2005-01-20T19:04:33
Editor: ScottEade
Wiki: Jakarta Turbine Wiki
Page: Turbine2/UsersGuide/TurbineActionDoubleSubmit
URL: http://wiki.apache.org/jakarta-turbine/Turbine2/UsersGuide/TurbineActionDoubleSubmit
Migrated page.
New Page:
#pragma section-numbers off
= Turbine 2.x User's Guide: Preventing Double Submit of Forms =
In your Turbine''''''Resources.properties you define a session validator that is processed before your action is. This allows you to force only logged in users to be able to execute a session, or do things like preventing double submission of forms.
Look for:
{{{ action.sessionvalidator=sessionvalidator.TemplateSessionValidator }}}
There are others as well, including a Template''''''Secure''''''Session''''''Validator. You can create your own by just subclassing Session''''''Validator and updating your Turbine''''''Resources.properties file.
To prevent the double submission of forms, you must put into form a hidden field like this:
{{{ <input type="hidden" name="_session_access_counter" value="$data.getUser().getTemp("_session_access_counter")"/> }}}
This will allow the Template''''''Session''''''Validator to check the current session_access_counter with the one stored in the user object. If it hasn't incremented, then the user has hit the back button or refresh button.
You must specify where to send the user if an invalid state happens. You can specify either a template or a screen, but if you specify both then only the template will be used (along with the appropriate screen class according to the normal screen loader algorithm):
{{{ template.invalidstate=InvalidState.vm }}}
or
{{{ screen.invalidstate=error.InvalidState }}}
On this page you can put an error message allowing the user to recover from hitting the wrong button. Look at the class org.apache.turbine.modules.screens.error.Invalid''''''State to see a more complex example that allows the user to undo their mistake.
-- EricPugh
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org