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]