Hi Andrea,

Stateful is fine, stateless is not. A component cannot keep a stable
id when it's stateless. I'm trying out a change that forbids
getBehaviorId() for stateless behaviors, and I'm hitting a few tests
with stateless ajax. I don't see how this is supposed to work anyway.
We request the component to store the id of a certain behavior, but it
must do so in a stateless way. IMHO that's impossible. The component
will be discarded, along with its state and the stored id at the end
of the request. No way of guaranteeing that the same component with
the same behavior at the same index will exist at the next request.

This brings me back to my suggested change in the documentation: only
stateful behaviors have guaranteed stable ids. You can request the id
of a stateless behavior, but (in my current implementation) it may
change when you remove behaviors from the component.


On Wed, May 6, 2020 at 5:41 PM Andrea Del Bene <an.delb...@gmail.com> wrote:
> On 06/05/20 16:52, Emond Papegaaij wrote:
> > Hi all,
> >
> > During my refactoring of the component state (WICKET-6774) I noticed
> > that behavior ids are currently stored in a very inefficient way: an
> > ArrayList is added to Component data to store references to behaviors
> > with a stable id. On my branch I have eliminated this ArrayList,
> > greatly reducing the size of components with stateful behaviors (such
> > as AjaxLink).
> >
> > A behavior gets a stable id when it is stateful to be able to render
> > this id in an URL. However, at the moment, it also gets a stable id
> > when Component.getBehaviorId is called for that particular behavior.
> > This is also documented in the method's javadoc. Do we really need
> > this last part? It complicates the code a lot. In our code base nor in
> > Wicket can I find a single place where this is actually used.
> Actually I see that Component.getBehaviorId is used in
> AbstractAjaxTimerBehavior.getTimerId() and
> AbstractDefaultAjaxBehavior.onBind() which are however stateful behaviors.
> > I would like to suggest a change in the javadoc to state that stable
> > ids are only guaranteed for stateful behaviors and change this in
> > Wicket 9. The actual change in the implementation is not yet finished
> > and does not need to ship in 9.0.0, but feel I cannot change the
> > contract of a method in a minor release.
> >
> > Best regards,
> > Emond

Reply via email to