Hi,

The if(!isEnabled()) will happen though, because the link is not really disabled on the client side, but it does prevent doSomeHeavyWeightProcessing to be called the second time which is what I need. What are the pros / cons of (ab)using setEnabled for this instead of just a member variable)?

Thanks,
Matthijs

Timo Rantalaiho 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



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to