We've hacked a good bit around the double submit problem. Redirect after post
is certainty a must, but they can still click the button twice and send 2
requests, which will still cause problems.
Javascript is probably the best way to do it, syncing server-side like that
scares me and prevents 2 windows. We block anyone without js turned on, via a
<meta refresh in a <noscript> - fortunately we are able to do this. A web app
that has to work for users without javascript would really suck to do.. ugggh..
We have this code with prototype & jquery that seems to work quite well:
anything that causes a post has class="trigger", id="somethingUnique", and the
submit happens in the onclick function.
Lock.js:
// a map of form submitting trigger elements that are locked. ($H is
prototype's hash)
var lockedTriggers = $H();
// lock all visible triggers on the page and stash their event handlers
// called when a submit happens
function lock() {
$j('.trigger:visible').each(function() {
lockedTriggers.set(this.id, this.onclick);
this.onclick = function() { return false; };
});
}
// clean out the map, find the element on the page and restore the onclick
// only called from the onComplete callback for ajax, not needed if the page is
wiped out
function unlock() {
lockedTriggers.each(function(entry) {
var id = entry.key;
var trigger = $(id);
if (trigger) {
trigger.onclick = entry.value;
}
lockedTriggers.unset(id);
});
}
<input type="button" value="Submit" class="trigger red" id="submitButton_1"
onclick="this.form.submit();" />
Footer page:
<script type="text/javascript">
$j('form').submit(function(event){ // whenever any form
submits, lock any trigger on the page so they can't click it again
lock();
showLoadingIndicator();
return true;
});
</script>
=)
-----Original Message-----
From: Laurent Perez [mailto:[email protected]]
Sent: Monday, May 25, 2009 7:44 PM
To: Stripes Users List
Subject: Re: [Stripes-users] [stripes-users] synchronized Resolution ?
Thanks for the clarifications.
We finally figured out the problem, there was a thread safety issue
caused by an unhandled double submit.
laurent
2009/5/25 Ben Gunter <[email protected]>:
> Normally, each request gets its own instance of an ActionBean class so you
> don't have to worry about synchronization in the ActionBean itself. It is
> possible that your ActionBean uses another class that is not thread-safe.
>
> If you use @SessionScope, then one instance of the ActionBean class is
> created per session so thread-safety is a bit of a concern there.
>
> -Ben
>
> On Mon, May 25, 2009 at 9:13 AM, Laurent Perez <[email protected]> wrote:
>>
>> Hi
>>
>> I'm trying to figure out an error "randomly" repeating itself on a
>> production system, which I can't reproduce locally. Stripes version is
>> 1.5.
>>
>> I believe this may be linked to concurrency issues, however, I'm not
>> sure if this could happen : are ActionBean expected to be thread-safe
>> ? By thread-safe, I mean can I run into unexpected problems whenever
>> two different browsers hit the same method of an ActionBean ? Is the
>> ActionBeanContext safe, too ?
>>
>> If so, is it meaningfull to synchronize "sensitive" Resolutions, as in
>> public synchronized Resolution process() {....}, or would it make no
>> difference ?
>>
>> Thanks
>> laurent
>
>
> ------------------------------------------------------------------------------
> 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
>
>
--
<a href="http://in-pocket.blogspot.com">http://in-pocket.blogspot.com
- Mobile world, technology and more</a>
------------------------------------------------------------------------------
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 as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users