new Version of WebElement>>onClickDo:andUpdateMany:

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

new Version of WebElement>>onClickDo:andUpdateMany:

Herbert König
Hi Aiders,

a friendly debugger stopped by and told me that I might need
WebElement>>onClickDo: aBlock andUpdateMany: anElementOrIdCollection
inside components which sometimes have to update noting at all while
they usually update several elements.

So I changed for category events-ajax:

onClickDo: aBlock andUpdateMany: anElementOrIdCollection
        | |
        self registerId;
                otherAt: #onClickBlock put: aBlock;
                onClick: (self dependentInformation: anElementOrIdCollection)

all the ugly details are now in private-Ajax:

dependentInformation: anElementOrIdCollection
        "necessary information of elements to update is collected here."
        | dependentIds url dependentParms onClickStream |
        anElementOrIdCollection ifNil: [^''].
        url := self ajaxCallUrl.
        dependentIds := anElementOrIdCollection collect:
                                        [:each |
                                        each isSymbol
                                                ifTrue: [each]
                                                        [each registerId.
                                                        each id]].
        dependentParms := anElementOrIdCollection
                                collect: [:each | self ajaxCallUrlParametersFor: each].
        dependentParms := dependentParms collect:
                                        [:parm |
                                        parm , '&blockElementId=' , self id , '&blockName=onClickBlock'].
        onClickStream := WriteStream on: String new.
        1 to: dependentParms size
                        [:index |
                                nextPutAll: 'new Ajax.Updater(''';
                                nextPutAll: (dependentIds at: index) asString;
                                nextPutAll: ''', ''';
                                nextPutAll: url;
                                nextPutAll: ''', {method: ''post'', postBody: ''';
                                nextPutAll: (dependentParms at: index);
                                nextPutAll: ''', evalScripts: true});'].
        ^onClickStream contents


Herbert                          mailto:[hidden email]

Aida mailing list
[hidden email]