Out of sync id of WebApplication

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

Out of sync id of WebApplication

Alex Baran
Hello Aida community,

My apologies if my conclusions are not correct, I'm new to the Aida.
I stumbled at a situation which is better to describe by a simple
example. Counter seems like a good candidate.
Each time we press on a link ajax is fired and counter is incremented.
Whole application supposed to be redrawn.

        | e link |
        e := WebElement new.
        link := e
                        addLinkTo: self observee
                        text: 'Counter: ' , counter displayString.
        link onClickUpdate: self.
                pageFrameWith: e
                title: ''

        self method: #inc.
        counter := 0.

        counter := counter + 1.

The code doesn't work properly. The problem is that WebApplication
_id_ inside of WebApplication and in WebForm goes out of sync. So ajax
request go to illegal element. This happens because of WebApplication
clearing(WebApplication>>cleanup) at html printing nilify id inside of
WebApplication, and later WebApplication get generated id instead of
old one stored in the form.

My fix is pretty straitforward:

WebForm>>registerIdFor: anElement
        anElement id isNil ifTrue:
                [(self isRegistered: anElement) ifTrue:
                                [^anElement id: (self ids keyAtValue: anElement)]. "Using of old key"
                ^anElement id: self nextId]. "auto id if not manually defined! "

Hope this can be useful,
Alex Baran
Aida mailing list
[hidden email]