[aida] new Version of WebElement>>onClickDo:andUpdateMany:

Herbert König herbertkoenig at gmx.net
Sun Apr 19 17:41:25 CEST 2009


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]
                                                ifFalse: 
                                                        [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
                do: 
                        [:index | 
                        onClickStream
                                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



Cheers,

Herbert                          mailto:herbertkoenig at gmx.net



More information about the Aida mailing list