AbstractAjaxBehavior and missing unbind(Component) method

2012-02-21 Thread Dirk Forchel
Similar to this topic
(http://apache-wicket.1842946.n4.nabble.com/Possible-AbstractAjaxBehavior-Bug-tp1867734p1867734.html)
I'm running into trouble adding a Behavior to a Component dynamically with
an Ajax request.
I have a test page for jQuery UI Effects similar to this example
(http://jqueryui.com/demos/effect/) 
where AbstractEffect extends AbstractAjaxBehavior. If I wanna replace the
old selected behavior with the new one, previously attached to a
WebMarkupContainer, I get an IllegalStateException thrown at
org.apache.wicket.behavior.AbstractAjaxBehavior.bind(AbstractAjaxBehavior.java:62).
 
I know, the Behavior was not designed with the adding/removing in mind, but
as this issue (https://issues.apache.org/jira/browse/WICKET-713) has been
fixed, it would be quite easy to solve this problem.
I reckon the AbstractAjaxBehavior should just overwrite the unbind(Component
component) method, to set the component the handler is currently bound to to
null. Unfortunately the component attribute is private.
Or do I miss the point and there is another solution I'm currently not aware
of.


Here is the exception thrown:

java.lang.IllegalStateException: this kind of handler cannot be attached to
multiple components; it is already attached to component [ [Component id =
effectContainer]], but component [ [Component id = effectContainer]] wants
to be attached too
 at
org.apache.wicket.behavior.AbstractAjaxBehavior.bind(AbstractAjaxBehavior.java:62)

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AbstractAjaxBehavior-and-missing-unbind-Component-method-tp4407049p4407049.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: AbstractAjaxBehavior and missing unbind(Component) method

2012-02-21 Thread Martin Grigorov
Hi,

Why do you want to reuse the behavior instance ?
Can't you just create a new instance and assign it to the new component ?
You can remove the old behavior from the old component with
Component#remove(Behavior)

On Tue, Feb 21, 2012 at 2:44 PM, Dirk Forchel dirk.forc...@exedio.com wrote:
 Similar to this topic
 (http://apache-wicket.1842946.n4.nabble.com/Possible-AbstractAjaxBehavior-Bug-tp1867734p1867734.html)
 I'm running into trouble adding a Behavior to a Component dynamically with
 an Ajax request.
 I have a test page for jQuery UI Effects similar to this example
 (http://jqueryui.com/demos/effect/)
 where AbstractEffect extends AbstractAjaxBehavior. If I wanna replace the
 old selected behavior with the new one, previously attached to a
 WebMarkupContainer, I get an IllegalStateException thrown at
 org.apache.wicket.behavior.AbstractAjaxBehavior.bind(AbstractAjaxBehavior.java:62).
 I know, the Behavior was not designed with the adding/removing in mind, but
 as this issue (https://issues.apache.org/jira/browse/WICKET-713) has been
 fixed, it would be quite easy to solve this problem.
 I reckon the AbstractAjaxBehavior should just overwrite the unbind(Component
 component) method, to set the component the handler is currently bound to to
 null. Unfortunately the component attribute is private.
 Or do I miss the point and there is another solution I'm currently not aware
 of.


 Here is the exception thrown:

 java.lang.IllegalStateException: this kind of handler cannot be attached to
 multiple components; it is already attached to component [ [Component id =
 effectContainer]], but component [ [Component id = effectContainer]] wants
 to be attached too
     at
 org.apache.wicket.behavior.AbstractAjaxBehavior.bind(AbstractAjaxBehavior.java:62)

 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/AbstractAjaxBehavior-and-missing-unbind-Component-method-tp4407049p4407049.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: AbstractAjaxBehavior and missing unbind(Component) method

2012-02-21 Thread Dirk Forchel
I have a static list of pre-configured instances (my Effects). On the
page is a select box (a DropDownChoiceAbstractEffect component) which uses
this list of instances to select an effect. Within the onClick() method of
an additional AjaxLink, the WebMarkupContainer (effectContainer) is
updated and the selected Behavior is added to this one. The old attached
effect is removed.
It would be possible to create every time new instance, but it was
straightforward to me to just use a static list to choose from.


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AbstractAjaxBehavior-and-missing-unbind-Component-method-tp4407049p4407159.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: AbstractAjaxBehavior and missing unbind(Component) method

2012-02-21 Thread Dirk Forchel
Yes, I mean Java's static. Actually it was not meant to re-use this list due
to concurrent requests. It's just a test page. But I've got it. I'll chance
the page and use new instances instead.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AbstractAjaxBehavior-and-missing-unbind-Component-method-tp4407049p4409371.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org