You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Scott Eade <se...@backstagetech.com.au> on 2001/08/02 12:38:02 UTC
Re: actions and redirect - [PATCH]
From: "John McNally" <jm...@collab.net>
> One way is to keep a session counter and embed the current count in the
> form. Then check the request count parameter with the session counter
> to see if it is stale. There is code in the default session validators
> to help with the later and a session counter is incremented in
> $data.User.AccessCounterForSession.
>
> This can be used to internally redirect the user to an error screen
> asking them to refrain from using the back/reload button and does not
> require a redirect for every action that is requested.
John,
This is pretty cool. To make it woek all you ned to do is include:
<input type="hidden" name="_session_access_counter" value="$data.User.AccessCounterForSession"/>
in your form (easier still I use a macro) and specify the error
page(s) in TR.props:
#screen.invalidstate=error.InvalidState
screen.invalidstate=/RepostError.vm
template.invalidstate=/RepostError.vm
(Note the commented line above is in TR.props by default)
Incidentally, I think the
org.apache.turbine.modules.actions.sessionvalidator.TemplateSessionValidator
supplied with tdk 2.1 has a bug in that the values stored in User.Temp as
prev_screen and prev_template will be the values just set rather than the
intended previous values (which you can then use on your error page). It
appears that this has been fixed in the HEAD code.
I also found that I couldn't use the saved values unless the '/' characters
were replaced by ',' characters (I figured it was better to be doing this
in TemplateSessionValidator than on my error page). Lastly, I thought it
better to use getAccessCounterForSession() than the existing line of code.
My patch below contains all three of these changes - let me know if one
or both of my additional changes are unappropriate.
Here is a patch for the version 1.4.10.2 taken from T_2_1_BRANCH:
--- src/java/org/apache/turbine/modules/actions/sessionvalidator/TemplateSession
Validator.java Thu Aug 02 20:01:10 2001
+++ webapps/cmes/WEB-INF/src/java/org/apache/turbine/modules/actions/sessionvali
dator/TemplateSessionValidator.java Thu Aug 02 20:12:39 2001
@@ -120,22 +120,23 @@
{
// See comments in screens.error.InvalidState.
if ( data.getParameters().getInt("_session_access_counter") <
- (((Integer)data.getUser().getTemp("_session_access_counter"))
- .intValue()-1) )
+ (data.getUser().getAccessCounterForSession() - 1))
{
if (data.getTemplateInfo().getScreenTemplate() != null)
{
+ data.getUser().setTemp( "prev_template",
+ data.getTemplateInfo().getScreenTemplate()
+ .replace('/', ',') );
data.getTemplateInfo().setScreenTemplate(
TurbineResources.getString(
TurbineConstants.TEMPLATE_INVALID_STATE) );
- data.getUser().setTemp( "prev_template",
- data.getTemplateInfo().getScreenTemplate() );
}
else
{
+ data.getUser().setTemp( "prev_screen",
+ data.getScreen().replace('/', ',') );
data.setScreen( TurbineResources.getString(
TurbineConstants.SCREEN_INVALID_STATE) );
- data.getUser().setTemp( "prev_screen", data.getScreen() );
}
data.getUser().setTemp("prev_parameters", data.getParameters())
;
data.setAction( "" );
I've been using turbine for a number of weeks now and I confess to
being unsure of the distinction between a template and a screen. It
seems that the most recent CVS code now only handles prev_template
using getTarget() (must be new in 3.0) so somehing in this area has
obviously changed. I'm not sure if getTarget() replaces the slashes
with commas, the only other change for 3.0 would be to use:
data.getUser().getAccessCounterForSession()
instead of:
((Integer)data.getUser().getTemp("_session_access_counter")).intValue()
The same changes may also be necessary in TemplateSecureSessionValidator.
Please let me know if you want a patch for that also.
Can you please apply the above patch to the CVS code for 2.1.
Thanks,
Scott
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: actions and redirect - [PATCH]
Posted by Jon Stevens <jo...@latchkey.com>.
on 8/2/01 3:38 AM, "Scott Eade" <se...@backstagetech.com.au> wrote:
> I've been using turbine for a number of weeks now and I confess to
> being unsure of the distinction between a template and a screen.
Template == Velocity
Screen == Java code
Pull Model dictates that Screens tied to Templates are no longer necessary.
-jon
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org