this code doesn't work at all. the onclick method isn't called at the same time by 2 request (2 link clicks) They are synchronized by wicket itself.
So what happens with the code below is that the first request sets the enabled to false then does the processing, then wicket blocks the second request in the mean time then the processing is finished, the link is enabled again. That request does its processing rendering after it is finished wicket will release the second request and that does exactly the same thing as the first. So the heavy stuff is always done twice, but it is done twice in sequence If you don't want that then the only solution is to block the second click in the browser using javascript magic. johan On Feb 6, 2008 5:12 PM, Timo Rantalaiho <[EMAIL PROTECTED]> wrote: > On Wed, 06 Feb 2008, Matthijs Wensveen wrote: > > I have a Link (not Ajax) on a component that does some heavyweight > > processing in onClick. During this processing I want to block other > > clicks from the same user. Is there a generic way to block multiple > > requests on the same link? I would prefer a solution without Ajax / > > JavaScript, but if that's impossible then that's okay. > > Components are stateful, so maybe you could just keep the > state in your Link? > > @Override onClick() { > if (!isEnabled()) { > return; // this shouldnt happen though? > } > try { > setEnabled(false); > doSomeHeavyWeightProcessing(); > } finally { > setEnabled(true); > } > } > > This creates a little race condition but if you can produce > it you could try using a real lock mechanism. > > Best wishes, > Timo > > -- > Timo Rantalaiho > Reaktor Innovations Oy <URL: http://www.ri.fi/ > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >