Master-details

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
76 messages Options
1234
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Alex Baran
Hi Nicholas,

2009/4/24 Nicholas Moore <[hidden email]>:

> Herbert /Alex
>
> I am following your envestigations with interest!
>
> I have a similar problem. I want to select an object in my grid and see some
> attributes of that object displayed by another component.
> So far I have two phenomena:
>
> 1) the details displayed in the second component are always those of the
> last object in the collection in the grid (as though when the block is
> executed the last 'each' is used).

It looks like a Squeak problem with a capture of variables in a
closure. Do you use fixTemps?
Anyway can you provide code of your block?

>
> 2) after selection, the second component disappears - inspection in a
> debugger shows that the object associated with that component would be the
> last one described above).

As Herbert already mentioned, updateMany had some issue that can lead
to such behavior. Please don't use my new fix right now, I want to
change some part of it. Will post it here when ready.

Alex
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Alex Baran
In reply to this post by Herbert König
Herbert and Nicholas,

2009/4/23 Herbert König <[hidden email]>:

> another data point:
> When producing the errors I sometimes get debuggers:
> "Error: Attempt to evaluate a block that is already evaluated",
> usually more than one.
>
> So I put a 0 halt into the onClickDo: Block and I see I get one
> debugger for the halt + one debugger for each Ajax.Updater -1.
>
> This is expected as every Updater fires a request, the first halts and
> all subsequent ones try to reenter this halted block.

Thank you for finding it!
Now only first Ajax.Update call a block. So now patch look like this:

onClickDo: aBlock andUpdateMany: anElementOrIdCollection
        | stream |
        stream := String new writeStream.
        self dependentInformation: anElementOrIdCollection to: stream isFirst: true.
        self registerId;
                otherAt: #onClickBlock put: aBlock;
                onClick: 'if (!inCall) {inCall = true;', stream contents, '}'.

dependentInformation: anElementOrIdCollection to: aStream isFirst: isFirst
        | url head tail headId parm |
        anElementOrIdCollection ifNil: [^''].
        head := anElementOrIdCollection first.
        tail := anElementOrIdCollection copyFrom: 2 to: anElementOrIdCollection size.
        url := self ajaxCallUrl.
        headId := head isSymbol
                                                ifTrue: [head]
                                                ifFalse: [head registerId. head id].

        parm := (self ajaxCallUrlParametersFor: head).
        isFirst ifTrue:
                        [self registerId.
                        parm := parm, '&amp;blockElementId=' , self id ,
'&amp;blockName=onClickBlock'].
        aStream
                nextPutAll: 'new Ajax.Updater(''';
                nextPutAll: headId asString;
                nextPutAll: ''', ''';
                nextPutAll: url;
                nextPutAll: ''', {method: ''post'', postBody: ''';
                nextPutAll: parm;
                nextPut: $';
                nextPutAll: ', onComplete: function() {'.
        tail isEmpty
                        ifTrue: [aStream nextPutAll: ' inCall = false; ']
                        ifFalse: [self dependentInformation: tail to: aStream isFirst: false].
        aStream
                nextPutAll: '; }';
                nextPutAll: ', evalScripts: true});'.


And add this line to WebPage>>initPageHeaderLinks

       self addJavascript: 'var inCall = false;'


I just want to mention, that we still have an issue with garbage from
elements that we register as blocks holder.


Alex
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Nicholas Moore
In reply to this post by Herbert König
Thanks Herbert,

� wrote:
Hi Nicholas,


NM> Herbert /Alex

NM> I have a similar problem. I want to select an object in my
NM> grid and seesome attributes of that object displayed by another
NM> component. So far Ihave two phenomena:

yes this should work in the end.

NM> 1) the details displayed in the second component are always
NM> those ofthe last object in the collection in the grid (as though
NM> when the blockis executed the last 'each' is used).

Hmm, I don't know if that has the same cause as my remaining problem
where one field gets cleared and the others not changed at all. Maybe
you have to throw some code and a picture of your app into the
discussion.

  
With this code, when an entry is selected the second display becomes blank:

viewAlternate2
    | e f grid  |
    self clear.
    self title: 'CBD'.

    e := WebElement newClass: #condiv.
    f := WebElement new.
    f add: (self display: selectedEntry).   
    grid := ForumWebGrid new.
    grid columnNames: #('' 'Name' );
         setNumbering;
         columnFilters: #(nil true);
         sortOn: 2;
         collection: self observee directory;
         columnAspects: #(nil #name );       
         column: 2
        addBlock: [:each | (WebText new text: each name) onClickDo:[self display: each] andUpdate: f].

    self display: selectedEntry.   
    e cell add: grid.
    e addBreak.
    e newCell add: f.
    ^ self pageFrameWith: e title: self title

display: anEntry
    |e|
    e := WebElement new.
    anEntry isNil
            ifTrue:[^e cell addText: 'No Name Selected']
            ifFalse:[ selectedEntry := anEntry.
                e cell addText: anEntry business defaultEmail; addBreak.
                e newRow.
                e cell addText: anEntry business defaultPhone; addBreak].
        ^e


NM> 2) after selection, the second component disappears -
NM> inspection in adebugger shows that the object associated with that
NM> component would bethe last one described above).

This is solved with Alex latest changes to onClickDo:andUpdateMany:

Do you use it? If so tell me your system and I send you a fileout or a
text for copy and paste with all changes to Aida 5.6.
  
I am using Squeak 3.10 and Aida 6.0 (maybe I should try on 5.6?) I have not used
onClickDo:andUpdateMany: because that needs to receive a collection, rather than one element.

Suggestions welcome, I am scratching my head!  ;-) 

Nicholas
NM> I hope to be able to do some testing this weekend.

Cheers,

Herbert                            [hidden email]

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
  

--
NJM TSR-i

Nicholas J Moore
Limoges
France


_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Herbert König
In reply to this post by Alex Baran
Hi,


AB> Now only first Ajax.Update call a block. So now patch look like this:
<snip>
used it and built an entry component and everything seems fine.

Didn't check for garbage yet and only tried the updating. Only adding
the block call to the first Ajax.Updater again sped things up. Even
with a 600MHz PIII as server the app now behaves like a local app if
the browser is running on a fast computer.

And you're right about the garbage. A minute of constantly switching
between the views (tabs) got me three more MB for Squeak in the
Windows task manager.

My changed methods are at the end.

That's a big step ahead!! Big Thanks!



Cheers,

Herbert                            mailto:[hidden email]

The new component of EllingWebTabsApp in protocol prining positionen:

displayPositionenComponent: collectionElementsToUpdate
        | positionsListe |
        collectionElementsToUpdate do: [:each| each registerId].
        positionsListe := WebGrid new.
        positionsListe
                columnNames: #(
                                        'No.'
                                        'Ind.'
                                        'Positionstext'
                                        'Vorgabemasse'
                                );
                columnAlign: #(#left #left #left #left );
                collection: self observee abrechnung positionen;
                columnAspects: #(
                                        #position
                                        #index
                                        #positionsText
                                        #vorgabeMasseText
                                );
                rowGreenIfTrue: [:each | each idString = self observee selectedPosition idString];
                rowBoldIfTrue: [:each | each idString = self observee selectedPosition idString].
        collectionElementsToUpdate add: positionsListe.
        positionsListe
                column: 3
                        addBlock:
                                [:each |
                                (WebText new text: each positionsText)
                                        onClickDo:
                                                [self observee
                                                        selectedPosition: (self observee abrechnung positionWithId: each idString)
                                                "copy"] fixTemps
                                        andUpdateMany:
                                                collectionElementsToUpdate].
        ^positionsListe


And the changed view, same place:

viewAddPosition
        | e entryComposite|
        self observee
                selectedPosition: (self observee selectedPosition ifNil: [DA53 new]).
        e := WebElement new.
        e addTextH1: 'Elling Abrechnung ohne Schwerpunktsweg'.
        e
                addBreak;
                add: self displayTabComponent;
                addBreak;
                addTextH1: 'Neue Position eingeben / Bestehende Position ändern';
                addBreak.
        entryComposite := self displayPositionForEntryComponent .
        e add: entryComposite .
        e newRow.
        e cell addButtonText: 'Eintrag hinzufügen / ändern ' action: #add.
        e newCell addButtonText: 'Neuer Eintrag' action: #new.
        e newRow.
        e cell addButtonText: 'Abbrechen / Zurück zu Positionen' action: #cancel.
        e newCell addButtonText: 'Angezeigten Eintrag löschen' action: #delete.
        e addBreak.
        e
                addText: 'Liste der Positionen:';
                addBreak.
        e add: (self
                                displayPositionenComponent:  (OrderedCollection with: entryComposite )).
        self pageFrameWith: e title: 'REB Elling'

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Herbert König
In reply to this post by Nicholas Moore
Hi Nicholas,

I'm better at trying code than at reading code but I miss too much of
your model to try myself.
NM> With this code, when an entry is selected the second display becomesblank:

The second display would be  self display: selectedEntry: ?

In the beginning I had a problem when entries did not yet have an ID.
That's why I have the line:

collectionElementsToUpdate do: [:each| each registerId].
just before I create the grid.

I got this clue by opening inspectors on the elements I wanted to
update. Se remark in your code further on.

And I notice that you first add display: selectedEntry in which you
use the grid which is created only after you already use it. In the
end I marked your code to explain what I mean here.

Having not understood enough, I anyway suggest you change your view
along the following lines:
viewAlternate2
   |... displaySelected|
   .....
   f := webElement new.
   displaySelected := self display: selectedEntry
   f add: displaySelected
   displaySelected: registerId
   ....
   then build your grid until columnAspects:
   grid registerId
   grid addBlock: .... onClickDo: []
                       andUpdateMany:
                         (OrderedCollection with: grid with:
                         displaySelected).

Alex has not yet put the last improvements into onClickDo:andUpdate:
so I would not use it yet.
OTOH I think we should rename ..:andUpdateMany: to :andUpdate: and
only have one method and a collection with one or many elements.

If you feel I'm totally mistaken please send a screenshot from the
browser. That would help me a lot.
                         

NM> viewAlternate2
NM>     | e f grid  |
NM>     self clear.
NM>     self title: 'CBD'.

NM>     e := WebElement newClass: #condiv.
NM>     f := WebElement new.
------------- Next line you use grid
NM>     f add: (self display: selectedEntry).   
------------- Which you create after using it
NM>     grid := ForumWebGrid new.
NM>     grid columnNames: #('' 'Name' );
NM>          setNumbering;
NM>          columnFilters: #(nil true);
NM>          sortOn: 2;
NM>          collection: self observee directory;
NM>          columnAspects: #(nil #name );       
NM>          column: 2
NM>         addBlock: [:each | (WebText new text: each
NM> name)onClickDo:[self display: each] andUpdate: f].
        f inspect.
------------- In the inspector you send self id
------------- the update happens via the ID, Firebug shows the
------------- genreated JavaScript.
NM>     self display: selectedEntry.   
NM>     e cell add: grid.
NM>     e addBreak.
NM>     e newCell add: f.
NM>     ^ self pageFrameWith: e title: self title

NM> display: anEntry
NM>     |e|
NM>     e := WebElement new.
NM>     anEntry isNil
NM>             ifTrue:[^e cell addText: 'No Name Selected']
NM>             ifFalse:[ selectedEntry := anEntry.
NM>                 e cell addText: anEntry business defaultEmail; addBreak.
NM>                 e newRow.
NM>                 e cell addText: anEntry business defaultPhone;addBreak].
NM>         ^e


 
NM>> 2) after selection, the second component disappears -
NM>> inspection in adebugger shows that the object associated with that
NM>> component would bethe last one described above).

NM> This is solved with Alex latest changes to onClickDo:andUpdateMany:

NM> Do you use it? If so tell me your system and I send you a fileout or a
NM> text for copy and paste with all changes to Aida 5.6.



NM> I am using Squeak 3.10 and Aida 6.0 (maybe I should try on 5.6?) I havenot used

I don't think it's a problem of 6.0 beta.

NM> onClickDo:andUpdateMany: because that needs to receive a
NM> collection, rather than one element.

Actually if you would decide to update your grid to highlight the
selected entry it would be two elements to update :-))

NM> Suggestions welcome, I am scratching my head!  ;-) Nicholas



Hth,

Herbert                            mailto:[hidden email]

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Alex Baran
In reply to this post by Nicholas Moore
Nicholas,

If I understand you code corectly, it can be slightly modified.
First of all we can divide selection  "selectedEntry := anEntry" and
updating of elements. So block will make selection [selectedEntry :=
anEntry] and update part will make redraw. With Herbert advice of
updating grid and "display" component it will look something like
(it's just idea not working code):

viewAlternate2
    | e f grid  |
    self clear.
    self title: 'CBD'.

    e := WebElement newClass: #condiv.

    displaySelected := self myComponent.
    grid := ForumWebGrid new.
    grid columnNames: #('' 'Name' );
         setNumbering;
         columnFilters: #(nil true);
         sortOn: 2;
         collection: self observee directory;
         columnAspects: #(nil #name );
         column: 2
        addBlock: [:each | (WebText new text: each name)
onClickDo:[self display: each] andUpdateMany: (Array with: grid with:
displaySelected)].

    e cell add: grid.
    e addBreak.
    e newCell add: displaySelected.
    ^ self pageFrameWith: e title: self title

You probably don\t need "f" variable, I removed it from code.

myComponent
    |e|
     e := WebElement new.
     selectedEntry isNil
             ifTrue:[^e cell addText: 'No Name Selected']
             ifFalse:[
                 e cell addText: selectedEntry business defaultEmail; addBreak.
                 e newRow.
                 e cell addText: selectedEntry business defaultPhone; addBreak].
       ^e


And if you will use onClickDo:updateMany: please consider using latest
version from my previous mail. Add 2 methods to WebElement and modify
1 in WebPage.

One more word about onClick: aBlock ...
A result of aBlock evaluation is not used, so you can not return new
element from block. For returning(redrawing) update/updateMany part is
used. Block is only supposed to make some modifications
(side-effects).

Hope this helps,
Alex

2009/4/24 Nicholas Moore <[hidden email]>:

> Thanks Herbert,
>
> � wrote:
>
> Hi Nicholas,
>
>
> NM> Herbert /Alex
>
> NM> I have a similar problem. I want to select an object in my
> NM> grid and seesome attributes of that object displayed by another
> NM> component. So far Ihave two phenomena:
>
> yes this should work in the end.
>
> NM> 1) the details displayed in the second component are always
> NM> those ofthe last object in the collection in the grid (as though
> NM> when the blockis executed the last 'each' is used).
>
> Hmm, I don't know if that has the same cause as my remaining problem
> where one field gets cleared and the others not changed at all. Maybe
> you have to throw some code and a picture of your app into the
> discussion.
>
>
>
> With this code, when an entry is selected the second display becomes blank:
>
> viewAlternate2
>     | e f grid  |
>     self clear.
>     self title: 'CBD'.
>
>     e := WebElement newClass: #condiv.
>     f := WebElement new.
>     f add: (self display: selectedEntry).
>     grid := ForumWebGrid new.
>     grid columnNames: #('' 'Name' );
>          setNumbering;
>          columnFilters: #(nil true);
>          sortOn: 2;
>          collection: self observee directory;
>          columnAspects: #(nil #name );
>          column: 2
>         addBlock: [:each | (WebText new text: each name) onClickDo:[self
> display: each] andUpdate: f].
>
>     self display: selectedEntry.
>     e cell add: grid.
>     e addBreak.
>     e newCell add: f.
>     ^ self pageFrameWith: e title: self title
>
> display: anEntry
>     |e|
>     e := WebElement new.
>     anEntry isNil
>             ifTrue:[^e cell addText: 'No Name Selected']
>             ifFalse:[ selectedEntry := anEntry.
>                 e cell addText: anEntry business defaultEmail; addBreak.
>                 e newRow.
>                 e cell addText: anEntry business defaultPhone; addBreak].
>         ^e
>
>
> NM> 2) after selection, the second component disappears -
> NM> inspection in adebugger shows that the object associated with that
> NM> component would bethe last one described above).
>
> This is solved with Alex latest changes to onClickDo:andUpdateMany:
>
> Do you use it? If so tell me your system and I send you a fileout or a
> text for copy and paste with all changes to Aida 5.6.
>
>
> I am using Squeak 3.10 and Aida 6.0 (maybe I should try on 5.6?) I have not
> used
>
> onClickDo:andUpdateMany: because that needs to receive a collection, rather
> than one element.
>
> Suggestions welcome, I am scratching my head!  ;-)
>
> Nicholas
>
> NM> I hope to be able to do some testing this weekend.
>
> Cheers,
>
> Herbert                            mailto:[hidden email]
>
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida
>
>
> --
>
> Nicholas J Moore
> Limoges
> France
>
>
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida
>
>
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Alex Baran
In reply to this post by Herbert König
Herbert,

2009/4/24 Herbert König <[hidden email]>:

> Having not understood enough, I anyway suggest you change your view
> along the following lines:
> viewAlternate2
>   |... displaySelected|
>   .....
>   f := webElement new.
>   displaySelected := self display: selectedEntry
>   f add: displaySelected
>   displaySelected: registerId
>   ....
>   then build your grid until columnAspects:
>   grid registerId

I think it's better not to use "registerId" in normal code. registerId
doesn't come for free. By registering you hook a component into some
registrator, and right now this can  add to garbage. And even if we
introduce some kind of Weak colleciton it's better to not have a lot
of work for garbage collector.
"grid registerId" can be ommited at all because grid register
themselves anyway.The same situation with "displaySelected:
registerId". It will be registered on script creation.


Alex
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Alex Baran
In reply to this post by Herbert König
2009/4/24 Herbert König <[hidden email]>:
> And you're right about the garbage. A minute of constantly switching
> between the views (tabs) got me three more MB for Squeak in the
> Windows task manager.

Yes, this a serious problem.

>
> My changed methods are at the end.
>
> That's a big step ahead!! Big Thanks!

My pleasure!


Alex
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Nicholas Moore
In reply to this post by Alex Baran
We have some synchronicity! I was just about to send the following as your mail arrived - so will let you know more when I have tried it.

In the mean time, with your and Herbert's help I have made some progress with the following view (using your latest code).

I have a directory of names and wish to display a list of those names so that a user can select one and then more pertinent details will appear to one side. The app has an instance variable 'selectedEntry' which is initialized to nil when the app is created.

What happens now is that selectedEntry is being properly set by this code (the selected name becomes green) but 'f' is not displayed until I refresh the browser page - then it is fine.

    e := WebElement newClass: #condiv.
    f := WebElement new.
    f registerId.
    grid := ForumWebGrid new.
    grid registerId.   

    grid columnNames: #('' 'Name' );
          setNumbering;
          columnFilters: #(nil true);
          sortOn: 2;
          collection: self observee directory;
          columnAspects: #(nil #name );       
          column: 2
          addBlock: [:each | (WebText new text: each name)
          onClickDo: [selectedEntry := each] fixTemps
                       andUpdateMany:
                         (OrderedCollection with: grid with:f)].

     selectedEntry notNil ifTrue:[
            grid
            rowGreenIfTrue: [:entry | entry id = selectedEntry id];
            rowBoldIfTrue: [:entry | entry id = selectedEntry id]].

    selectedEntry isNil
            ifTrue:[f cell addText: 'Hello World']
            ifFalse:[ f cell addText: selectedEntry business defaultEmail; addBreak.
    f newRow.
    f cell addText: selectedEntry business defaultPhone; addBreak].

    e cell add: grid.
    e newRow.
    e cell add: f.
    ^ self pageFrameWith: e title: self title.

Thanks

Nicholas



Alex Baran wrote:
Nicholas,

If I understand you code corectly, it can be slightly modified.
First of all we can divide selection  "selectedEntry := anEntry" and
updating of elements. So block will make selection [selectedEntry :=
anEntry] and update part will make redraw. With Herbert advice of
updating grid and "display" component it will look something like
(it's just idea not working code):

viewAlternate2
    | e f grid  |
    self clear.
    self title: 'CBD'.

    e := WebElement newClass: #condiv.

    displaySelected := self myComponent.
    grid := ForumWebGrid new.
    grid columnNames: #('' 'Name' );
         setNumbering;
         columnFilters: #(nil true);
         sortOn: 2;
         collection: self observee directory;
         columnAspects: #(nil #name );
         column: 2
        addBlock: [:each | (WebText new text: each name)
onClickDo:[self display: each] andUpdateMany: (Array with: grid with:
displaySelected)].

    e cell add: grid.
    e addBreak.
    e newCell add: displaySelected.
    ^ self pageFrameWith: e title: self title

You probably don\t need "f" variable, I removed it from code.

myComponent
    |e|
     e := WebElement new.
     selectedEntry isNil
             ifTrue:[^e cell addText: 'No Name Selected']
             ifFalse:[
                 e cell addText: selectedEntry business defaultEmail; addBreak.
                 e newRow.
                 e cell addText: selectedEntry business defaultPhone; addBreak].
       ^e


And if you will use onClickDo:updateMany: please consider using latest
version from my previous mail. Add 2 methods to WebElement and modify
1 in WebPage.

One more word about onClick: aBlock ...
A result of aBlock evaluation is not used, so you can not return new
element from block. For returning(redrawing) update/updateMany part is
used. Block is only supposed to make some modifications
(side-effects).

Hope this helps,
Alex

2009/4/24 Nicholas Moore [hidden email]:
  
Thanks Herbert,

� wrote:

Hi Nicholas,


NM> Herbert /Alex

NM> I have a similar problem. I want to select an object in my
NM> grid and seesome attributes of that object displayed by another
NM> component. So far Ihave two phenomena:

yes this should work in the end.

NM> 1) the details displayed in the second component are always
NM> those ofthe last object in the collection in the grid (as though
NM> when the blockis executed the last 'each' is used).

Hmm, I don't know if that has the same cause as my remaining problem
where one field gets cleared and the others not changed at all. Maybe
you have to throw some code and a picture of your app into the
discussion.



With this code, when an entry is selected the second display becomes blank:

viewAlternate2
    | e f grid  |
    self clear.
    self title: 'CBD'.

    e := WebElement newClass: #condiv.
    f := WebElement new.
    f add: (self display: selectedEntry).
    grid := ForumWebGrid new.
    grid columnNames: #('' 'Name' );
         setNumbering;
         columnFilters: #(nil true);
         sortOn: 2;
         collection: self observee directory;
         columnAspects: #(nil #name );
         column: 2
        addBlock: [:each | (WebText new text: each name) onClickDo:[self
display: each] andUpdate: f].

    self display: selectedEntry.
    e cell add: grid.
    e addBreak.
    e newCell add: f.
    ^ self pageFrameWith: e title: self title

display: anEntry
    |e|
    e := WebElement new.
    anEntry isNil
            ifTrue:[^e cell addText: 'No Name Selected']
            ifFalse:[ selectedEntry := anEntry.
                e cell addText: anEntry business defaultEmail; addBreak.
                e newRow.
                e cell addText: anEntry business defaultPhone; addBreak].
        ^e


NM> 2) after selection, the second component disappears -
NM> inspection in adebugger shows that the object associated with that
NM> component would bethe last one described above).

This is solved with Alex latest changes to onClickDo:andUpdateMany:

Do you use it? If so tell me your system and I send you a fileout or a
text for copy and paste with all changes to Aida 5.6.


I am using Squeak 3.10 and Aida 6.0 (maybe I should try on 5.6?) I have not
used

onClickDo:andUpdateMany: because that needs to receive a collection, rather
than one element.

Suggestions welcome, I am scratching my head!  ;-)

Nicholas

NM> I hope to be able to do some testing this weekend.

Cheers,

Herbert                            [hidden email]

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida


--

Nicholas J Moore
Limoges
France

    



_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Alex Baran
Nicholas,

Creation of your "f" variable should be factored into separated
method. In that way you can get component that can be updated. You can
look at the code in my previous mail.

Alex

2009/4/25 Nicholas Moore <[hidden email]>:

> We have some synchronicity! I was just about to send the following as your
> mail arrived - so will let you know more when I have tried it.
>
> In the mean time, with your and Herbert's help I have made some progress
> with the following view (using your latest code).
>
> I have a directory of names and wish to display a list of those names so
> that a user can select one and then more pertinent details will appear to
> one side. The app has an instance variable 'selectedEntry' which is
> initialized to nil when the app is created.
>
> What happens now is that selectedEntry is being properly set by this code
> (the selected name becomes green) but 'f' is not displayed until I refresh
> the browser page - then it is fine.
>
>     e := WebElement newClass: #condiv.
>     f := WebElement new.
>     f registerId.
>     grid := ForumWebGrid new.
>     grid registerId.
>
>     grid columnNames: #('' 'Name' );
>           setNumbering;
>           columnFilters: #(nil true);
>           sortOn: 2;
>           collection: self observee directory;
>           columnAspects: #(nil #name );
>           column: 2
>           addBlock: [:each | (WebText new text: each name)
>           onClickDo: [selectedEntry := each] fixTemps
>                        andUpdateMany:
>                          (OrderedCollection with: grid with:f)].
>
>      selectedEntry notNil ifTrue:[
>             grid
>             rowGreenIfTrue: [:entry | entry id = selectedEntry id];
>             rowBoldIfTrue: [:entry | entry id = selectedEntry id]].
>
>     selectedEntry isNil
>             ifTrue:[f cell addText: 'Hello World']
>             ifFalse:[ f cell addText: selectedEntry business defaultEmail;
> addBreak.
>     f newRow.
>     f cell addText: selectedEntry business defaultPhone; addBreak].
>
>     e cell add: grid.
>     e newRow.
>     e cell add: f.
>     ^ self pageFrameWith: e title: self title.
>
> Thanks
>
> Nicholas
>
>
>
> Alex Baran wrote:
>
> Nicholas,
>
> If I understand you code corectly, it can be slightly modified.
> First of all we can divide selection  "selectedEntry := anEntry" and
> updating of elements. So block will make selection [selectedEntry :=
> anEntry] and update part will make redraw. With Herbert advice of
> updating grid and "display" component it will look something like
> (it's just idea not working code):
>
> viewAlternate2
>     | e f grid  |
>     self clear.
>     self title: 'CBD'.
>
>     e := WebElement newClass: #condiv.
>
>     displaySelected := self myComponent.
>     grid := ForumWebGrid new.
>     grid columnNames: #('' 'Name' );
>          setNumbering;
>          columnFilters: #(nil true);
>          sortOn: 2;
>          collection: self observee directory;
>          columnAspects: #(nil #name );
>          column: 2
>         addBlock: [:each | (WebText new text: each name)
> onClickDo:[self display: each] andUpdateMany: (Array with: grid with:
> displaySelected)].
>
>     e cell add: grid.
>     e addBreak.
>     e newCell add: displaySelected.
>     ^ self pageFrameWith: e title: self title
>
> You probably don\t need "f" variable, I removed it from code.
>
> myComponent
>     |e|
>      e := WebElement new.
>      selectedEntry isNil
>              ifTrue:[^e cell addText: 'No Name Selected']
>              ifFalse:[
>                  e cell addText: selectedEntry business defaultEmail;
> addBreak.
>                  e newRow.
>                  e cell addText: selectedEntry business defaultPhone;
> addBreak].
>        ^e
>
>
> And if you will use onClickDo:updateMany: please consider using latest
> version from my previous mail. Add 2 methods to WebElement and modify
> 1 in WebPage.
>
> One more word about onClick: aBlock ...
> A result of aBlock evaluation is not used, so you can not return new
> element from block. For returning(redrawing) update/updateMany part is
> used. Block is only supposed to make some modifications
> (side-effects).
>
> Hope this helps,
> Alex
>
> 2009/4/24 Nicholas Moore <[hidden email]>:
>
>
> Thanks Herbert,
>
> � wrote:
>
> Hi Nicholas,
>
>
> NM> Herbert /Alex
>
> NM> I have a similar problem. I want to select an object in my
> NM> grid and seesome attributes of that object displayed by another
> NM> component. So far Ihave two phenomena:
>
> yes this should work in the end.
>
> NM> 1) the details displayed in the second component are always
> NM> those ofthe last object in the collection in the grid (as though
> NM> when the blockis executed the last 'each' is used).
>
> Hmm, I don't know if that has the same cause as my remaining problem
> where one field gets cleared and the others not changed at all. Maybe
> you have to throw some code and a picture of your app into the
> discussion.
>
>
>
> With this code, when an entry is selected the second display becomes blank:
>
> viewAlternate2
>     | e f grid  |
>     self clear.
>     self title: 'CBD'.
>
>     e := WebElement newClass: #condiv.
>     f := WebElement new.
>     f add: (self display: selectedEntry).
>     grid := ForumWebGrid new.
>     grid columnNames: #('' 'Name' );
>          setNumbering;
>          columnFilters: #(nil true);
>          sortOn: 2;
>          collection: self observee directory;
>          columnAspects: #(nil #name );
>          column: 2
>         addBlock: [:each | (WebText new text: each name) onClickDo:[self
> display: each] andUpdate: f].
>
>     self display: selectedEntry.
>     e cell add: grid.
>     e addBreak.
>     e newCell add: f.
>     ^ self pageFrameWith: e title: self title
>
> display: anEntry
>     |e|
>     e := WebElement new.
>     anEntry isNil
>             ifTrue:[^e cell addText: 'No Name Selected']
>             ifFalse:[ selectedEntry := anEntry.
>                 e cell addText: anEntry business defaultEmail; addBreak.
>                 e newRow.
>                 e cell addText: anEntry business defaultPhone; addBreak].
>         ^e
>
>
> NM> 2) after selection, the second component disappears -
> NM> inspection in adebugger shows that the object associated with that
> NM> component would bethe last one described above).
>
> This is solved with Alex latest changes to onClickDo:andUpdateMany:
>
> Do you use it? If so tell me your system and I send you a fileout or a
> text for copy and paste with all changes to Aida 5.6.
>
>
> I am using Squeak 3.10 and Aida 6.0 (maybe I should try on 5.6?) I have not
> used
>
> onClickDo:andUpdateMany: because that needs to receive a collection, rather
> than one element.
>
> Suggestions welcome, I am scratching my head!  ;-)
>
> Nicholas
>
> NM> I hope to be able to do some testing this weekend.
>
> Cheers,
>
> Herbert                            mailto:[hidden email]
>
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida
>
>
> --
>
> Nicholas J Moore
> Limoges
> France
>
>
>
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida
>
>
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Nicholas Moore
Alex, it works superbly!! - many thanks - and so to bed to dream of blocks, closures and garbage collection! :-D

Nicholas

Alex Baran wrote:
Nicholas,

Creation of your "f" variable should be factored into separated
method. In that way you can get component that can be updated. You can
look at the code in my previous mail.

Alex

2009/4/25 Nicholas Moore [hidden email]:
  
We have some synchronicity! I was just about to send the following as your
mail arrived - so will let you know more when I have tried it.

In the mean time, with your and Herbert's help I have made some progress
with the following view (using your latest code).

I have a directory of names and wish to display a list of those names so
that a user can select one and then more pertinent details will appear to
one side. The app has an instance variable 'selectedEntry' which is
initialized to nil when the app is created.

What happens now is that selectedEntry is being properly set by this code
(the selected name becomes green) but 'f' is not displayed until I refresh
the browser page - then it is fine.

    e := WebElement newClass: #condiv.
    f := WebElement new.
    f registerId.
    grid := ForumWebGrid new.
    grid registerId.

    grid columnNames: #('' 'Name' );
          setNumbering;
          columnFilters: #(nil true);
          sortOn: 2;
          collection: self observee directory;
          columnAspects: #(nil #name );
          column: 2
          addBlock: [:each | (WebText new text: each name)
          onClickDo: [selectedEntry := each] fixTemps
                       andUpdateMany:
                         (OrderedCollection with: grid with:f)].

     selectedEntry notNil ifTrue:[
            grid
            rowGreenIfTrue: [:entry | entry id = selectedEntry id];
            rowBoldIfTrue: [:entry | entry id = selectedEntry id]].

    selectedEntry isNil
            ifTrue:[f cell addText: 'Hello World']
            ifFalse:[ f cell addText: selectedEntry business defaultEmail;
addBreak.
    f newRow.
    f cell addText: selectedEntry business defaultPhone; addBreak].

    e cell add: grid.
    e newRow.
    e cell add: f.
    ^ self pageFrameWith: e title: self title.

Thanks

Nicholas



Alex Baran wrote:

Nicholas,

If I understand you code corectly, it can be slightly modified.
First of all we can divide selection  "selectedEntry := anEntry" and
updating of elements. So block will make selection [selectedEntry :=
anEntry] and update part will make redraw. With Herbert advice of
updating grid and "display" component it will look something like
(it's just idea not working code):

viewAlternate2
    | e f grid  |
    self clear.
    self title: 'CBD'.

    e := WebElement newClass: #condiv.

    displaySelected := self myComponent.
    grid := ForumWebGrid new.
    grid columnNames: #('' 'Name' );
         setNumbering;
         columnFilters: #(nil true);
         sortOn: 2;
         collection: self observee directory;
         columnAspects: #(nil #name );
         column: 2
        addBlock: [:each | (WebText new text: each name)
onClickDo:[self display: each] andUpdateMany: (Array with: grid with:
displaySelected)].

    e cell add: grid.
    e addBreak.
    e newCell add: displaySelected.
    ^ self pageFrameWith: e title: self title

You probably don\t need "f" variable, I removed it from code.

myComponent
    |e|
     e := WebElement new.
     selectedEntry isNil
             ifTrue:[^e cell addText: 'No Name Selected']
             ifFalse:[
                 e cell addText: selectedEntry business defaultEmail;
addBreak.
                 e newRow.
                 e cell addText: selectedEntry business defaultPhone;
addBreak].
       ^e


And if you will use onClickDo:updateMany: please consider using latest
version from my previous mail. Add 2 methods to WebElement and modify
1 in WebPage.

One more word about onClick: aBlock ...
A result of aBlock evaluation is not used, so you can not return new
element from block. For returning(redrawing) update/updateMany part is
used. Block is only supposed to make some modifications
(side-effects).

Hope this helps,
Alex

2009/4/24 Nicholas Moore [hidden email]:


Thanks Herbert,

� wrote:

Hi Nicholas,


NM> Herbert /Alex

NM> I have a similar problem. I want to select an object in my
NM> grid and seesome attributes of that object displayed by another
NM> component. So far Ihave two phenomena:

yes this should work in the end.

NM> 1) the details displayed in the second component are always
NM> those ofthe last object in the collection in the grid (as though
NM> when the blockis executed the last 'each' is used).

Hmm, I don't know if that has the same cause as my remaining problem
where one field gets cleared and the others not changed at all. Maybe
you have to throw some code and a picture of your app into the
discussion.



With this code, when an entry is selected the second display becomes blank:

viewAlternate2
    | e f grid  |
    self clear.
    self title: 'CBD'.

    e := WebElement newClass: #condiv.
    f := WebElement new.
    f add: (self display: selectedEntry).
    grid := ForumWebGrid new.
    grid columnNames: #('' 'Name' );
         setNumbering;
         columnFilters: #(nil true);
         sortOn: 2;
         collection: self observee directory;
         columnAspects: #(nil #name );
         column: 2
        addBlock: [:each | (WebText new text: each name) onClickDo:[self
display: each] andUpdate: f].

    self display: selectedEntry.
    e cell add: grid.
    e addBreak.
    e newCell add: f.
    ^ self pageFrameWith: e title: self title

display: anEntry
    |e|
    e := WebElement new.
    anEntry isNil
            ifTrue:[^e cell addText: 'No Name Selected']
            ifFalse:[ selectedEntry := anEntry.
                e cell addText: anEntry business defaultEmail; addBreak.
                e newRow.
                e cell addText: anEntry business defaultPhone; addBreak].
        ^e


NM> 2) after selection, the second component disappears -
NM> inspection in adebugger shows that the object associated with that
NM> component would bethe last one described above).

This is solved with Alex latest changes to onClickDo:andUpdateMany:

Do you use it? If so tell me your system and I send you a fileout or a
text for copy and paste with all changes to Aida 5.6.


I am using Squeak 3.10 and Aida 6.0 (maybe I should try on 5.6?) I have not
used

onClickDo:andUpdateMany: because that needs to receive a collection, rather
than one element.

Suggestions welcome, I am scratching my head!  ;-)

Nicholas

NM> I hope to be able to do some testing this weekend.

Cheers,

Herbert                            [hidden email]

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida


--

Nicholas J Moore
Limoges
France

    



_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Herbert König
In reply to this post by Alex Baran
Alex,


AB> I think it's better not to use "registerId" in normal code. registerId
AB> doesn't come for free. By registering you hook a component into some
AB> registrator, and right now this can  add to garbage. And even if we
AB> introduce some kind of Weak colleciton it's better to not have a lot
AB> of work for garbage collector.

I was using a cure as a cure-all :-))

Anyway, I commented out
collectionElementsToUpdate do: [:each| each registerId]
in my displayPositionenComponent.

Then viewAddPosition and viewPositionen do not update everything anymore.
(collectionElementsToUpdate collect: [:ea | ea id]) inspect.
delivers a Collection containing nil.

So the way to go would be
collectionElementsToUpdate do: [:each|each  id ifNil:  [each registerId]].?

Also in my WebElement>>addDelayedTabbingAspect I had to manually
registerId to make onEnterTabulate work.

Digging around:

registerId is sent in many methods. But WebForm>>registerIdFor: (this
is where registerId ends up) makes sure there will be no double
registration.

So my conclusion is: If I want to update an element it needs a
registered id. Registering any element I want to update will do no
harm garbage-wise.

Do you agree?

About weak collection:

My (weak) recollection of Squeak-dev postings suggests that either
Squeak is weak at weak collections or that weak collections are a
dangerous thing. SCNR the many weak's :-)

Looked through the archives and to sum it up, I quote a paragraph from
Andreas Raab:
<quote>
The solution? Don't do it. Don't use automatic finalization for large
collections. Do it manually every now and then, for example, having a timer
process which looks over the elements (this might get triggered by a signal
from the finalization process btw).
</quote>


Cheers,

Herbert                            mailto:[hidden email]

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Alex Baran
Hi Herbet,

2009/4/25 Herbert König <[hidden email]>:
> Anyway, I commented out
> collectionElementsToUpdate do: [:each| each registerId]
> in my displayPositionenComponent.
>
> Then viewAddPosition and viewPositionen do not update everything anymore.
> (collectionElementsToUpdate collect: [:ea | ea id]) inspect.
> delivers a Collection containing nil.

Right now I don't have ability to try your case, but it make me
curious. I think I will have chance to check it at Tuesday.

>
> So the way to go would be
> collectionElementsToUpdate do: [:each|each  id ifNil:  [each registerId]].?
>
> Also in my WebElement>>addDelayedTabbingAspect I had to manually
> registerId to make onEnterTabulate work.
>
> Digging around:
>
> registerId is sent in many methods. But WebForm>>registerIdFor: (this
> is where registerId ends up) makes sure there will be no double
> registration.
>
> So my conclusion is: If I want to update an element it needs a
> registered id. Registering any element I want to update will do no
> harm garbage-wise.
>
> Do you agree?

Yes, if you want to update an element you should find it first. And to
find an element you need id. But I think this id stuff should be the
responsibility of the framework, not user code.
Anyway if you register only components that will update, you do no
garbage-harm, because that way or another they need to be registered,
at least it so from Aida perspective.

>
> About weak collection:
>
> My (weak) recollection of Squeak-dev postings suggests that either
> Squeak is weak at weak collections or that weak collections are a
> dangerous thing. SCNR the many weak's :-)
>
> Looked through the archives and to sum it up, I quote a paragraph from
> Andreas Raab:
> <quote>
> The solution? Don't do it. Don't use automatic finalization for large
> collections. Do it manually every now and then, for example, having a timer
> process which looks over the elements (this might get triggered by a signal
> from the finalization process btw).
> </quote>

Thank you for mention the existence of the problem in Squeak. I hope I
will get into the topic at upcoming week.


Alex
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Alex Baran
In reply to this post by Nicholas Moore
Hi Nicholas,

2009/4/25 Nicholas Moore <[hidden email]>:
> Alex, it works superbly!! - many thanks - and so to bed to dream of blocks,
> closures and garbage collection! :-D

It's nice to hear that it works. Now we need to fight garbage, because
it eats our brain, even when we sleep ;)

Alex
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Janko Mivšek
Hi guys,

Now the new beta of 6.0 is out (on Squeak and VW!), please migrate to it
as soon as possible, so that we all will have the same base to work on
that problem further.

Best regards
Janko

Alex Baran pravi:

> Hi Nicholas,
>
> 2009/4/25 Nicholas Moore <[hidden email]>:
>> Alex, it works superbly!! - many thanks - and so to bed to dream of blocks,
>> closures and garbage collection! :-D
>
> It's nice to hear that it works. Now we need to fight garbage, because
> it eats our brain, even when we sleep ;)
>
> Alex
> _______________________________________________
> Aida mailing list
> [hidden email]
> http://lists.aidaweb.si/mailman/listinfo/aida
>

--
Janko Mivšek
Svetovalec za informatiko
Eranova d.o.o.
Ljubljana, Slovenija
www.eranova.si
tel:  01 514 22 55
faks: 01 514 22 56
gsm: 031 674 565
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Reply | Threaded
Open this post in threaded view
|

Re: Subtle bug on updating WebElements

Herbert König
Hi Janko and all,

JM> Now the new beta of 6.0 is out (on Squeak and VW!), please migrate to it
JM> as soon as possible, so that we all will have the same base to work on
JM> that problem further.

I tried but didn't succeed.

The changes to port where very few but now, when I login I get to my
app's main view but I have no more page frame and title, just my app.

When I change the tab I get to the login page (again without frame)
but logging in tells me the login failed.

I guess I made a stupid error, cause I already removed all old
sessions via:

site := AIDASite allInstances first
site sessionManager sessions copy do: [:each | site sessionManager removeSession: each]
site := nil

note the "sessions" instead of "activeSessions"

and tried to reinit by:
SwazooAida demoStart
(AIDASite named: 'aidademo') urlResolver defaultURL: '/EllingWeb.html' forObject: ewt

but this didn't change the symptoms.

Sad I will be on a business trip with others until Wednesday night, no
chance to steal away and look into this further.

But I'm eager to get it to work :-)





Cheers,

Herbert                            mailto:[hidden email]

_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
1234