How to write server data request from client side using seaside

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

How to write server data request from client side using seaside

Eduard Maydanik

HI I am working with WebVelocity 1.1a:

 

 

this is a simple test.

It should start on client side(jQuery –> onClick event) –> get value from a server(ajax -> clicks ) -> apply this value on client side(jQuery ->  alert) .

 

renderContentOn: html

               "clicks is an instance variable, initialized as 1 "

               (html anchor)

                              onClick: (html jQuery ajax script:

                                                                                          [:s |

                                                                                          s alert: clicks printString.

                                                                                          clicks := clicks + 1]);

                              onClick: 'return false';

                              url: '#';

                              with: 'Test'

 

 

It shows all times original value only.

 

If I change it to:

 

               (html anchor)

                              onClick: (html jQuery ajax script:

                                                                                          [:s |

                                                                                          s alert: Time now printString]);

                              onClick: 'return false';

                              url: '#';

                              with: 'Test'

 

It shows right behavior. On each click right time.

If I change my code it to similar:

 

              (html anchor)

                              onClick: (html jQuery ajax script:

                                                                                          [:s |

                                                                                          s alert: self increaseClick]);

                              onClick: 'return false';

                              url: '#';

                              with: 'Test'

 

increaseClick

 

               ^ clicks := clicks + 1.

 

It shows again original value only.

 

What is wrong? Or if it’s a right behavior for this code -  how it should be redone to show clicks number?

 

Can you point me on code example?

 

Best regards,

Eduard

 


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

Re: How to write server data request from client side using seaside

tfleig
I have attached a fileout of your app that works correctly in my
environment. I did not change any of your code. All three examples
worked "out-of-the-box".

The only thing of importance that I did add was the class initialize,
which you did not mention in your email:

initialize
        "EduardMaydanik initialize"
        | application |
        application := WAAdmin register: self asApplicationAt: 'EduardMaydanik'.
        application preferenceAt: #scriptGeneratorClass put: JQScriptGenerator.
        application
                addLibrary: JQDeploymentLibrary.

Maybe you didn't load the library or something?

Regards,
TF

On Tue, Jan 4, 2011 at 11:31 AM, Eduard Maydanik <[hidden email]> wrote:

> HI I am working with WebVelocity 1.1a:
>
>
>
>
>
> this is a simple test.
>
> It should start on client side(jQuery –> onClick event) –> get value from a
> server(ajax -> clicks ) -> apply this value on client side(jQuery ->  alert)
> .
>
>
>
> renderContentOn: html
>
>                "clicks is an instance variable, initialized as 1 "
>
>                (html anchor)
>
>                               onClick: (html jQuery ajax script:
>
>
> [:s |
>
>
> s alert: clicks printString.
>
>
> clicks := clicks + 1]);
>
>                               onClick: 'return false';
>
>                               url: '#';
>
>                               with: 'Test'
>
>
>
>
>
> It shows all times original value only.
>
>
>
> If I change it to:
>
>
>
>                (html anchor)
>
>                               onClick: (html jQuery ajax script:
>
>
> [:s |
>
>
> s alert: Time now printString]);
>
>                               onClick: 'return false';
>
>                               url: '#';
>
>                               with: 'Test'
>
>
>
> It shows right behavior. On each click right time.
>
> If I change my code it to similar:
>
>
>
>               (html anchor)
>
>                               onClick: (html jQuery ajax script:
>
>
> [:s |
>
>
> s alert: self increaseClick]);
>
>                               onClick: 'return false';
>
>                               url: '#';
>
>                               with: 'Test'
>
>
>
> increaseClick
>
>
>
>                ^ clicks := clicks + 1.
>
>
>
> It shows again original value only.
>
>
>
> What is wrong? Or if it’s a right behavior for this code -  how it should be
> redone to show clicks number?
>
>
>
> Can you point me on code example?
>
>
>
> Best regards,
>
> Eduard
>
>
>
> _______________________________________________
> 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

EduardMaydanik.st (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to write server data request from client side using seaside

tfleig
Just realized you are using WebVelocity and I am using Pharo. But at
least we know that your code works in the Pharo environment.

TF

On Wed, Jan 5, 2011 at 7:07 PM, Tony Fleig <[hidden email]> wrote:

> I have attached a fileout of your app that works correctly in my
> environment. I did not change any of your code. All three examples
> worked "out-of-the-box".
>
> The only thing of importance that I did add was the class initialize,
> which you did not mention in your email:
>
> initialize
>        "EduardMaydanik initialize"
>        | application |
>        application := WAAdmin register: self asApplicationAt: 'EduardMaydanik'.
>        application preferenceAt: #scriptGeneratorClass put: JQScriptGenerator.
>        application
>                addLibrary: JQDeploymentLibrary.
>
> Maybe you didn't load the library or something?
>
> Regards,
> TF
>
> On Tue, Jan 4, 2011 at 11:31 AM, Eduard Maydanik <[hidden email]> wrote:
>> HI I am working with WebVelocity 1.1a:
>>
>>
>>
>>
>>
>> this is a simple test.
>>
>> It should start on client side(jQuery –> onClick event) –> get value from a
>> server(ajax -> clicks ) -> apply this value on client side(jQuery ->  alert)
>> .
>>
>>
>>
>> renderContentOn: html
>>
>>                "clicks is an instance variable, initialized as 1 "
>>
>>                (html anchor)
>>
>>                               onClick: (html jQuery ajax script:
>>
>>
>> [:s |
>>
>>
>> s alert: clicks printString.
>>
>>
>> clicks := clicks + 1]);
>>
>>                               onClick: 'return false';
>>
>>                               url: '#';
>>
>>                               with: 'Test'
>>
>>
>>
>>
>>
>> It shows all times original value only.
>>
>>
>>
>> If I change it to:
>>
>>
>>
>>                (html anchor)
>>
>>                               onClick: (html jQuery ajax script:
>>
>>
>> [:s |
>>
>>
>> s alert: Time now printString]);
>>
>>                               onClick: 'return false';
>>
>>                               url: '#';
>>
>>                               with: 'Test'
>>
>>
>>
>> It shows right behavior. On each click right time.
>>
>> If I change my code it to similar:
>>
>>
>>
>>               (html anchor)
>>
>>                               onClick: (html jQuery ajax script:
>>
>>
>> [:s |
>>
>>
>> s alert: self increaseClick]);
>>
>>                               onClick: 'return false';
>>
>>                               url: '#';
>>
>>                               with: 'Test'
>>
>>
>>
>> increaseClick
>>
>>
>>
>>                ^ clicks := clicks + 1.
>>
>>
>>
>> It shows again original value only.
>>
>>
>>
>> What is wrong? Or if it’s a right behavior for this code -  how it should be
>> redone to show clicks number?
>>
>>
>>
>> Can you point me on code example?
>>
>>
>>
>> Best regards,
>>
>> Eduard
>>
>>
>>
>> _______________________________________________
>> 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