You could track the calls to site with an interceptor, storing the
last requested page and access time in the session. If the same action
bean is called twice within 1 second, return a ForwardResolution to a
page explaing that the user should not double klick. I would not
synchronize access to the session before I have fully understood the
the issue und can think of all possible problems... Multithreading is
a very complex topic and relating to web apps most people try to avoid
synchronized access to a resource. Personally I would discard users
who disabled java script and solve the problem using js.

On Mon, May 25, 2009 at 6:52 PM, Michael Day <[email protected]> wrote:
> Ah, I did not know that the browsers consider a double-click to be a
> single action.  That's smart!  I have a similar piece of javascript,
> but I am also looking for a server-side solution for users who have
> javascript disabled.
>
> On May 25, 2009, at 12:33 PM, Oscar Westra van Holthe - Kind wrote:
>
>> On 25-05-2009 at 12:13, Michael Day wrote:
>>> I would like to prevent optimistic locking exceptions when a user
>>> double-clicks a link or double-submits a form.  Is there anything
>>> wrong with accomplishing this by synchronizing the HTTP session in my
>>> ActionBean as shown below?
>>>
>>>     public Resolution execute() {
>>>         synchronized (getContext().getRequest().getSession()) {
>>>             ...
>>>         }
>>>     }
>>
>> Double-clicking would not cause a problem, as it's still a single
>> action.
>> However, it is possible that a users is just a tad too slow to
>> double-click:
>> the browser then sees it as two single-clicks, and submits the form
>> twice.
>>
>> Personally, I've solved this with a bit of javascript in the onsubmit
>> attribute of the form, and a bit of page-wide javascript (it can be
>> made
>> form-specific):
>>
>> var alreadySybmitted = false;
>> function maySubmit()
>> {
>>       var result = !alreadySybmitted;
>>       alreadySybmitted = true;
>>       return result;
>> }
>>
>>
>> <stripes:form ... onsubmit="return maySubmit();">
>>       ...
>> </stripes:form>
>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
>>> is a gathering of tech-side developers & brand creativity
>>> professionals. Meet
>>> the minds behind Google Creative Lab, Visual Complexity,
>>> Processing, &
>>> iPhoneDevCamp asthey present alongside digital heavyweights like
>>> Barbarian
>>> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
>>> _______________________________________________
>>> Stripes-users mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
>> --
>>   ,-_  Oscar Westra van holthe - Kind      http://www.xs4all.nl/~kindop/
>>  /() )
>> (__ (  A: Because people normally read from top to bottom.
>> =/  ()  Q: Why is top-posting such a bad thing?
>>
>> ------------------------------------------------------------------------------
>> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
>> is a gathering of tech-side developers & brand creativity
>> professionals. Meet
>> the minds behind Google Creative Lab, Visual Complexity, Processing, &
>> iPhoneDevCamp asthey present alongside digital heavyweights like
>> Barbarian
>> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
>> _______________________________________________
>> Stripes-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
>>
>
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
> iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to