Martijn Dashorst wrote:
On 2/7/08, Matthijs Wensveen <[EMAIL PROTECTED]> wrote:
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.
The problem is that the href of the link points to the old version of
the page, and that has the link still enabled.
Martijn
Okay, so that won't prevent doSomeHWProc. Would a private member
variable do the trick? Following the same logic, I'd say no.
Any ideas as to how this could be done? A session scope variable
probably, but that would be *very* ugly. Is there a scope beyond the
versioned page but smaller than the session? Page-global or something
like that?
Hmm... does the version of the page that the link points to really have
the link enabled? Isn't that version the same version that is doing the
processing? And before that, setEnabled(false) is called... The same
goes for the private member variable trick. I'm wondering...
Thanks,
Matthijs.
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]