JSF has no built-in support for multiple submit detection. We (the EG) looked at doing it for 1.2, but couldn't agree that there was One True pattern for doing this. IMO, there's a greater penalty for putting something wrong in the standard than for doing nothing at all.
My biggest concern about the Synchronizer Token pattern (especially as I remember it implemented in Struts) is that it fails to match user expectations. The user expectation is that the second click is somehow "ignored", so that it's as if only the first click happened. Instead, because an error is returned for the second click, the real processing is hidden. Imagine if the user double-clicked on "Place my Order": the user sees an error page, even though in reality, the order was properly placed! BTW, a nice thing about using pageFlowScope instead of the session for this pattern is that you detect back button across multiple windows, instead of getting confused when multiple windows are present. -- Adam On 6/12/07, Wyder, Michael (GMX) <[EMAIL PROTECTED]> wrote:
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* < [EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> 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 < [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote: > > > On 6/8/07, D. Cardon <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> 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 > >

