I do not understand how I have to interpret this code

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

I do not understand how I have to interpret this code

marten
I have problems in understanding this code. It is from the WAExampleBrowser. I added an additional instance variable b to this class and changed the following methods.

initialize
   super initialize.
   self class: self allClasses first.
   b := 5.


renderChooserOn: html
   b := 12.
   html div class: 'chooser'; with: [
      html form: [
         html div: [
            html select
               selected: class;
               list: self allClasses;
               onChange: 'submit()';
               callback: [ :value | self halt. self class: value ] ] ].
      self allSelectors size > 1 ifTrue: [
         html form: [
            html div: [
               html select
                  selected: selector;
                  list: self allSelectors;
                  onChange: 'submit()';
                  callback: [ :value | self selector: value ] ] ] ] ]

The question is: What is the value of instance variable "b" of the receiver at the location of "self halt".

The answer is: 5 - but why !? what state of the instance do I see in the callback ?

I know that the Seaside book tells one: "Your rendering method is just for painting the current state of your component, it shouldn't be concerned with changing that state".



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: I do not understand how I have to interpret this code

radoslav hodnicak
Backtracking? Try to delete the #states method from the class to see
if it makes any difference.

rado

On Thu, Nov 25, 2010 at 9:45 PM, Marten Feldtmann
<[hidden email]> wrote:

> I have problems in understanding this code. It is from the WAExampleBrowser.
> I added an additional instance variable b to this class and changed the
> following methods.
>
> initialize
>    super initialize.
>    self class: self allClasses first.
>    b := 5.
>
> renderChooserOn: html
>    b := 12.
>    html div class: 'chooser'; with: [
>       html form: [
>          html div: [
>             html select
>                selected: class;
>                list: self allClasses;
>                onChange: 'submit()';
>                callback: [ :value | self halt. self class: value ] ] ].
>       self allSelectors size > 1 ifTrue: [
>          html form: [
>             html div: [
>                html select
>                   selected: selector;
>                   list: self allSelectors;
>                   onChange: 'submit()';
>                   callback: [ :value | self selector: value ] ] ] ] ]
>
> The question is: What is the value of instance variable "b" of the receiver
> at the location of "self halt".
>
> The answer is: 5 - but why !? what state of the instance do I see in the
> callback ?
>
> I know that the Seaside book tells one: "Your rendering method is just for
> painting the current state of your component, it shouldn't be concerned with
> changing that state".
>
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: I do not understand how I have to interpret this code

Bob Arning
In reply to this post by marten
One thing to look out for is:

WAExampleBrowser>>allClasses(b is shadowed)

Cheers,
Bob

On 11/25/10 3:45 PM, Marten Feldtmann wrote:
I have problems in understanding this code. It is from the WAExampleBrowser. I added an additional instance variable b to this class and changed the following methods.

initialize
   super initialize.
   self class: self allClasses first.
   b := 5.


renderChooserOn: html
   b := 12.
   html div class: 'chooser'; with: [
      html form: [
         html div: [
            html select
               selected: class;
               list: self allClasses;
               onChange: 'submit()';
               callback: [ :value | self halt. self class: value ] ] ].
      self allSelectors size > 1 ifTrue: [
         html form: [
            html div: [
               html select
                  selected: selector;
                  list: self allSelectors;
                  onChange: 'submit()';
                  callback: [ :value | self selector: value ] ] ] ] ]

The question is: What is the value of instance variable "b" of the receiver at the location of "self halt".

The answer is: 5 - but why !? what state of the instance do I see in the callback ?

I know that the Seaside book tells one: "Your rendering method is just for painting the current state of your component, it shouldn't be concerned with changing that state".


_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: I do not understand how I have to interpret this code

Bob Arning
In reply to this post by radoslav hodnicak
That does solve the problem, although I don't know what it might break.

On 11/25/10 3:58 PM, radoslav hodnicak wrote:
Backtracking? Try to delete the #states method from the class to see
if it makes any difference.

rado

On Thu, Nov 25, 2010 at 9:45 PM, Marten Feldtmann
[hidden email] wrote:
I have problems in understanding this code. It is from the WAExampleBrowser.
I added an additional instance variable b to this class and changed the
following methods.

initialize
   super initialize.
   self class: self allClasses first.
   b := 5.

renderChooserOn: html
   b := 12.
   html div class: 'chooser'; with: [
      html form: [
         html div: [
            html select
               selected: class;
               list: self allClasses;
               onChange: 'submit()';
               callback: [ :value | self halt. self class: value ] ] ].
      self allSelectors size > 1 ifTrue: [
         html form: [
            html div: [
               html select
                  selected: selector;
                  list: self allSelectors;
                  onChange: 'submit()';
                  callback: [ :value | self selector: value ] ] ] ] ]

The question is: What is the value of instance variable "b" of the receiver
at the location of "self halt".

The answer is: 5 - but why !? what state of the instance do I see in the
callback ?

I know that the Seaside book tells one: "Your rendering method is just for
painting the current state of your component, it shouldn't be concerned with
changing that state".



_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside