Subtle bug on updating WebElements

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Subtle bug on updating WebElements

Alex Baran
Hello Aida community,

I stumbled at a bug, which I think is dangerous and hard to reproduce,
because bug appearance is close to random (depend on order of elements
in a Set).

As a result of the bug one can get updating of wrong element. For
example, when a page have two grids and you want to update first you
can get in a trouble, because sometimes in place of the first grid you
will see contents of the second.

Let's start with some architectural points of Aida inner working. When
ajax request comes to Aida, Aida find oldElement, than ask oldElement
to update which produce newElement. newElement can be the same object
as oldElement, or can be different from oldElement. When newElement is
newly created object, it must take place of oldElement and get
oldElement id. But this not always happen. Why?
Because Aida does search of oldElement by method name only
(WebElement>>method). So Aida suppose that each element was created by
a method with unique name (unique inside of a WebForm).
But this assumption is not correct. For example WebGrid has his own
method (look at WebGrid>>initialize) to update yourself, the method
name is "ajaxUpdateWith:". So if form has two grids, how the form can
find one of them if they have the same method names? It will choose
the first one. Which can be the correct choice or not, depending on
the order.

In my case I got updating of wrong grid.

WebGrid is not the only one which can suffer, any WebElement with
redefined method (WebElement>>method:) can be in trouble. Right now
this is only WebGrid, but if you write your own components and set
"method" to your value, your can have the problem.

I see several solutions to the problem:
1. Searching of element id should not rely on method name, but instead
one should search oldElement id by, hm.., oldElement. So we can find
time when we know both objects: oldElement and newElement and have
access to id->element mapping dictionary. This time is

2. Enforce uniqueness of method names. So, No tricks like redefining
methods in  WebGrid.
But how to do such things like sorting inside grid. Well, this is the
case when my proposal to add new kind of event handling can be of use.
Look at the examples of using WebElement>>onClickDo:andUpdate:  at

Alex Baran
Aida mailing list
[hidden email]