Thanks a lot, Timo, for the advice. With your suggestion I got it
working without problems.
Kaspar
--
add(imageDiv.add(new AjaxEventBehavior("onmouseover")
{
private boolean called;
@Override
protected void onEvent(AjaxRequestTarget target)
{
// Show
div.setVisible(true);
// Only do it once (to save bandwith)
called = true;
// Update affected components
target.addComponent(div);
target.addComponent(imageDiv);
}
@Override
public boolean isEnabled(Component component)
{
return !called;
}
}));
On 19.08.2008, at 04:37, Timo Rantalaiho wrote:
On Mon, 18 Aug 2008, Kaspar Fischer wrote:
I suppose that Wicket postpones the second request and when it is
exectured
later on, the behaviour has already been removed.
This sounds likely, as the requests are processed
serially.
What is the best way to have a JS behaviour executed only once?
It is not so common to remove behaviours, but to toggle
their "enabled" property. So maybe you can do something
like this
add(imageDiv.add(new AjaxEventBehavior("onmouseover")
{
private boolean called;
@Override
protected void onEvent(AjaxRequestTarget target)
{
div.setVisible(true);
imageDiv.remove(this);
target.addComponent(div);
target.addComponent(imageDiv);
called = true;
}
@Override
protected boolean isEnabled()
{
return !called;
}
}));
or if it doesn't do the trick, just do the check in onEvent().
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]