myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wyder, Michael (GMX)" <michael.wy...@gmx.ch>
Subject Re: [Trinidad] Page flow scope and Back button
Date Tue, 12 Jun 2007 20:10:34 GMT
This strategy/pattern is also known under the name "Synchronizer Token" 
or "Deja vu Token". It detects:
-Multiple form submit (doubleclick)
-Browser back button pressed and resubmit
-Browser stop button pressed and resubmit

Time ago i have made a little servlet/jsp-prototype implementig this 
pattern. You can find the source here (it's real quick and dirty):
https://svn.intelli.ch/fh/trunk/Diverses/michael/

My question is, doesn't JSF support this already innately? Do i really 
to write my own code to detect for example a multiple form submit?

Michael

Adam Winer schrieb:
> Sure, what you do is:
> - Store a token - Integer, String, enum, anything you want, that 
> indicates what page you're on, just like you're doing now.  As you know, 
> this will be restore when the back button is hit.
> 
> - In addition to storing that token right on the pageFlowScope, also set 
> it into a one-element array on the pageFlowScope - but don't create a 
> new array each time, just keep writing into that first element.
> 
> The one-element array will *not* be restored to its prior state, because 
> it's still the same instance.  Consequently, when you go back a page, 
> you'll see that the token directly on the page won't match the token 
> within the array.  Back button detected!
> 
> You could encapsulate this strategy into a reusable object if desired.
> 
> -- Adam
> 
> 
> 
> On 6/11/07, *D. Cardon* < my_trash_mail@yahoo.com 
> <mailto:my_trash_mail@yahoo.com>> wrote:
> 
>     Thanks, that clarifies the documentation.
> 
>     So, my follow-up question would be: Is there any way that I can
>     detect in Trinidad that the user
>     has gone from one page to the next one and then back again?
> 
>     Thank you for your help,
> 
>     --David
> 
>     --- Adam Winer < awiner@gmail.com <mailto:awiner@gmail.com>> wrote:
> 
>      > On 6/8/07, D. Cardon <my_trash_mail@yahoo.com
>     <mailto:my_trash_mail@yahoo.com>> wrote:
>      > > Hi *,
>      > >
>      > > I'm a little uncertain about how the pageFlowScope interacts
>     with the browser's Back button.
>      > The
>      > > documentation states:
>      > >
>      > >   "...clicking the Back button will automatically reset the
>     page flow scope to its original
>      > > state."
>      > >
>      > > Which 'original state' is this referring to?
>      > >
>      > > For example, suppose I have this situation:
>      > >
>      > > I have a wizard application.  On the first page of the wizard,
>     the user should enter a
>      > username
>      > > and password and then proceed to the next page of the wizard.
>      > >
>      > > When the first page of the wizard loads, the username and
>     password fields may be entered into.
>      > > The page that takes the user to the first wizard page creates a
>     "mode" variable in the page
>      > flow
>      > > scope and sets it to "create".
>      > >
>      > > After entering valid information, the user presses the "next"
>     button on the wizard.  In
>      > processing
>      > > the command button, the code sets the page flow scope variable
>     "mode" to "wizard".
>      > >
>      > > When on the second page of the wizard, the user then presses
>     the "back" button.  What is the
>      > value
>      > > of the "mode" variable in the page flow scope? "create" or
>     "wizard"?
>      >
>      > It's "create".
>      >
>      > -- Adam
>      >
>      > >
>      > > I would like to prevent the user from re-entering the username
>     and password after browsing
>      > "back"
>      > > to the first page of the wizard.  I thought I could use the
>     pageFlowScope to do that, but
>      > maybe
>      > > there is a better way.  Any suggestions?
>      > >
>      > > Thanks,
>      > >
>      > > --David
>      > >
>      > >
>      > >
>      > >
>     ____________________________________________________________________________________
>      > > Get the free Yahoo! toolbar and rest assured with the added
>     security of spyware protection.
>      > > http://new.toolbar.yahoo.com/toolbar/features/norton/index.php
>      > >
>      >
> 
> 
> 
> 
>     ____________________________________________________________________________________
> 
>     Don't pick lemons.
>     See all the new 2007 cars at Yahoo! Autos.
>     http://autos.yahoo.com/new_cars.html
> 
> 

Mime
View raw message