Seaside function onLoad problematic

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

Seaside function onLoad problematic

dtrussardi@tiscali.it
Ciao,

        into Pharo5.0 with Seaside 3.2 ( but i have the same problematic into Pharo 4.0 with Seaside 3.1 )

        when define a function to load when the page has finished loading

                with addLoadScript: 'so_initdtr()'.

        the function is not called.


        For example:


        renderContentOn: html

                html document addLoadScript: 'so_initdtr()'.
       
                html heading: 'Pippo'.


        The html report:

                <script type="text/javascript">function onLoad(){"soinitdtr()";};</script>

        but the browser don't call it when load the page.

        The relative javascript code is right loaded into the browser.

        I can call the so_initdtr() function with the browser console and it works fine.


        Thanks in advance!

        Dario

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

Re: Seaside function onLoad problematic

Johan Brichau-2
Hi Dario,

Try:

html document addLoadScript: (html javascript: ‘so_initdtr()’)

As you can notice in the generated html output, the contents of the loadscript is a JS string.

cheers
Johan

> On 26 Nov 2016, at 19:00, [hidden email] wrote:
>
> Ciao,
>
> into Pharo5.0 with Seaside 3.2 ( but i have the same problematic into Pharo 4.0 with Seaside 3.1 )
>
> when define a function to load when the page has finished loading
>
> with addLoadScript: 'so_initdtr()'.
>
> the function is not called.
>
>
> For example:
>
>
> renderContentOn: html
>
> html document addLoadScript: 'so_initdtr()'.
>
> html heading: 'Pippo'.
>
>
> The html report:
>
> <script type="text/javascript">function onLoad(){"soinitdtr()";};</script>
>
> but the browser don't call it when load the page.
>
> The relative javascript code is right loaded into the browser.
>
> I can call the so_initdtr() function with the browser console and it works fine.
>
>
> Thanks in advance!
>
> Dario
>
>
> _______________________________________________
> 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: Seaside function onLoad problematic

dtrussardi@tiscali.it
Ciao Johan,


i add the A B C considerations.

Hi Dario,

Try:

html document addLoadScript: (html javascript: ‘so_initdtr()’)

A) The: html javascript:   is not supported by the system

The call answer:  " you sent a message this type of object doesn't understand"


As you can notice in the generated html output, the contents of the loadscript is a JS string.

Yes but into it the so_initdtr() is surround by the "

<script type="text/javascript">function onLoad(){"soinitdtr()";};</script>



B) I change the JSStream   encodeString: aString on: aStream   metod

removing the initial and final  "aStream nextPut: $'."  ( view the **** )

 encodeString: aString on: aStream 
"Strings have a complicated encoding in Javascript, try to optimize their serialization."
****  "aStream nextPut: $'."
1 to: aString size do: [ :index | 
| char value encoded |
char := aString at: index.
value := char greaseInteger.
value < JavascriptCharacters size 
ifFalse: [
"U+2028 and U+2029 have to be treaded as new lines"
value = 16r2028 "Line separator"
ifTrue: [ aStream nextPutAll: '\u2028' ]
ifFalse: [
value = 16r2029 "Paragraph separator"
ifTrue: [ aStream nextPutAll: '\u2029' ]
ifFalse: [ aStream nextPut: char ] ] ]
ifTrue: [
encoded := JavascriptCharacters at: value + 1.
"we use nil markers becausee #isNil is faster than #isString because it's not
actually sent"
encoded isNil 
ifTrue: [ aStream nextPut: char ]
ifFalse: [ aStream nextPutAll: encoded ] ] ].
**** "aStream nextPut: $'"


With this modification my code works fine.

The browser  report:

 <script type="text/javascript">function onLoad(){so_initdtr();};</script>


But with this change the JQuery example don't works.


C) My final considerations is relative to the WAScriptGenerator  writeLoadScriptsOn: aDocument metod 

I change it to the seaside 3.0 version: 

writeLoadScriptsOn: aDocument "Utility method to write the receivers load scripts onto aDocument." " *** ----
self loadScripts do: [ :each | aDocument stream javascript: each. aDocument nextPut: $; ]"
"**** +++ " self loadScripts do: [ :each | aDocument nextPutAll: each greaseString; nextPut: $; ]

With just this change everything works, but it is in the right direction?


Thanks,

Dario


cheers
Johan

On 26 Nov 2016, at 19:00, [hidden email] wrote:

Ciao,

into Pharo5.0 with Seaside 3.2 ( but i have the same problematic into Pharo 4.0 with Seaside 3.1 )

when define a function to load when the page has finished loading

with addLoadScript: 'so_initdtr()'.

the function is not called.


For example:


renderContentOn: html

html document addLoadScript: 'so_initdtr()'.

html heading: 'Pippo'.


The html report:

<script type="text/javascript">function onLoad(){"soinitdtr()";};</script>

but the browser don't call it when load the page.

The relative javascript code is right loaded into the browser.

I can call the so_initdtr() function with the browser console and it works fine.


Thanks in advance!

Dario


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: Seaside function onLoad problematic

Paul DeBruicker
Hi Dario

Instead of rewriting how the strings are encoded you could maybe try


 html document addLoadScript: (JSStream on: ‘so_initdtr()’)





dtrussardi@tiscali.it wrote
Ciao Johan,


        i add the A B C considerations.

> Hi Dario,
>
> Try:
>
> html document addLoadScript: (html javascript: ‘so_initdtr()’)

A) The: html javascript:   is not supported by the system

                        The call answer: " you sent a message this type of object doesn't understand"

>
> As you can notice in the generated html output, the contents of the loadscript is a JS string.

        Yes but into it the so_initdtr() is surround by the "

                <script type="text/javascript">function onLoad(){"soinitdtr()";};</script>


B) I change the JSStream encodeString: aString on: aStream   metod

        removing the initial and final "aStream nextPut: $'."  ( view the **** )

         encodeString: aString on: aStream
        "Strings have a complicated encoding in Javascript, try to optimize their serialization."
               
****  "aStream nextPut: $'."
       
        1 to: aString size do: [ :index |
                | char value encoded |
                char := aString at: index.
                value := char greaseInteger.
                value < JavascriptCharacters size
                        ifFalse: [
                                "U+2028 and U+2029 have to be treaded as new lines"
                                value = 16r2028 "Line separator"
                                        ifTrue: [ aStream nextPutAll: '\u2028' ]
                                        ifFalse: [
                                                value = 16r2029 "Paragraph separator"
                                                        ifTrue: [ aStream nextPutAll: '\u2029' ]
                                                        ifFalse: [ aStream nextPut: char ] ] ]
                        ifTrue: [
                                encoded := JavascriptCharacters at: value + 1.
                                "we use nil markers becausee #isNil is faster than #isString because it's not
                                actually sent"
                                encoded isNil
                                        ifTrue: [ aStream nextPut: char ]
                                        ifFalse: [ aStream nextPutAll: encoded ] ] ].
**** "aStream nextPut: $'"


        With this modification my code works fine.

        The browser  report:

                 <script type="text/javascript">function onLoad(){so_initdtr();};</script>

        But with this change the JQuery example don't works.


C) My final considerations is relative to the WAScriptGenerator writeLoadScriptsOn: aDocument metod

        I change it to the seaside 3.0 version:

        writeLoadScriptsOn: aDocument
        "Utility method to write the receivers load scripts onto aDocument."

        " *** ----
                self loadScripts do: [ :each |
                aDocument stream javascript: each.
                aDocument  nextPut: $; ]"
       
        "**** +++ "
        self loadScripts do: [ :each |
                aDocument nextPutAll: each greaseString; nextPut: $; ]

        With just this change everything works, but it is in the right direction?


        Thanks,

                Dario

>
> cheers
> Johan
>
>> On 26 Nov 2016, at 19:00, [hidden email] wrote:
>>
>> Ciao,
>>
>> into Pharo5.0 with Seaside 3.2 ( but i have the same problematic into Pharo 4.0 with Seaside 3.1 )
>>
>> when define a function to load when the page has finished loading
>>
>> with addLoadScript: 'so_initdtr()'.
>>
>> the function is not called.
>>
>>
>> For example:
>>
>>
>> renderContentOn: html
>>
>> html document addLoadScript: 'so_initdtr()'.
>>
>> html heading: 'Pippo'.
>>
>>
>> The html report:
>>
>> <script type="text/javascript">function onLoad(){"soinitdtr()";};</script>>>
>> but the browser don't call it when load the page.
>>
>> The relative javascript code is right loaded into the browser.
>>
>> I can call the so_initdtr() function with the browser console and it works fine.
>>
>>
>> Thanks in advance!
>>
>> Dario
>>
>>
>> _______________________________________________
>> 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
Reply | Threaded
Open this post in threaded view
|

Re: Seaside function onLoad problematic

Johan Brichau-2
In reply to this post by dtrussardi@tiscali.it

On 28 Nov 2016, at 11:22, [hidden email] wrote:

A) The:  html javascript:   is not supported by the system

The call answer:  " you sent a message this type of object doesn't understand"

Sorry

Should be:

html document addLoadScript: (JSStream on: ‘init()’)

cheers
Johan

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

Re: Seaside function onLoad problematic

dtrussardi@tiscali.it
OK,

it's right.

Thanks,

Dario


On 28 Nov 2016, at 11:22, [hidden email] wrote:

A) The:  html javascript:   is not supported by the system

The call answer:  " you sent a message this type of object doesn't understand"

Sorry

Should be:

html document addLoadScript: (JSStream on: ‘init()’)

cheers
Johan
_______________________________________________
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