How to set the charset in WAHtmlErrorHandler

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

How to set the charset in WAHtmlErrorHandler

jtuchel
Hi there,


I must be sitting on my brain at the moment...

How do I set the charset=utf-8 header in a WAHtmlErrorHandler subclass?


Joachim

_______________________________________________
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 set the charset in WAHtmlErrorHandler

Johan Brichau-2
Something along these lines:
E.g. In the handleDefault: method:

        errorDialog := WARenderCanvas builder
                                        fullDocument: true;
                                        rootBlock: [ :root | root beHtml5; title: anException description ];
                                        render: [ :html |  … whatever you want ... ].
                                                                       
        self requestContext respond: [ :response |
                response
                        internalError;
                        contentType: ((WAMimeType textHtml) charset: 'utf-8’);
                        nextPutAll: errorDialog ]


warning: coded in email editor ;)
Take a look at WAHtmlErrorHandler as well

cheers
Johan

> On 6 Sep 2018, at 14:50, [hidden email] wrote:
>
> Hi there,
>
>
> I must be sitting on my brain at the moment...
>
> How do I set the charset=utf-8 header in a WAHtmlErrorHandler subclass?
>
>
> Joachim
>
> _______________________________________________
> 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: How to set the charset in WAHtmlErrorHandler

Philippe Marschall
Something like

self handler charSet

is probably better than hard coding utf-8.

Cheers
Philippe



On Thu, Sep 6, 2018 at 3:24 PM Johan Brichau <[hidden email]> wrote:

>
> Something along these lines:
> E.g. In the handleDefault: method:
>
>         errorDialog := WARenderCanvas builder
>                                         fullDocument: true;
>                                         rootBlock: [ :root | root beHtml5; title: anException description ];
>                                         render: [ :html |  … whatever you want ... ].
>
>         self requestContext respond: [ :response |
>                 response
>                         internalError;
>                         contentType: ((WAMimeType textHtml) charset: 'utf-8’);
>                         nextPutAll: errorDialog ]
>
>
> warning: coded in email editor ;)
> Take a look at WAHtmlErrorHandler as well
>
> cheers
> Johan
>
> > On 6 Sep 2018, at 14:50, [hidden email] wrote:
> >
> > Hi there,
> >
> >
> > I must be sitting on my brain at the moment...
> >
> > How do I set the charset=utf-8 header in a WAHtmlErrorHandler subclass?
> >
> >
> > Joachim
> >
> > _______________________________________________
> > 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: How to set the charset in WAHtmlErrorHandler

jtuchel
Philippe,

Am 06.09.18 um 17:22 schrieb Philippe Marschall:
> Something like
>
> self handler charSet
> is probably better than hard coding utf-8.

agreed. Although WAHtmlErorHandler doesn't implement #handler. So I
ended up with this:


         response

             internalError;

             contentType: ((WAMimeType textHtml) charset: self requestContext charSet);


Thanks for your tip.

For the record: if the error handler gets rendered as a child in the
component tree, that setting of charset is not necessary, but it is
necessare if the Error handler is the main component. Special characters
might be wrong then if the server side is not using utf-8. It may even
have such strange effects like a Firefox on Mac using a 1252 code page
(which I thought is Windows specific...).


Joachim



> Cheers
> Philippe
>
>
>
> On Thu, Sep 6, 2018 at 3:24 PM Johan Brichau <[hidden email]> wrote:
>> Something along these lines:
>> E.g. In the handleDefault: method:
>>
>>          errorDialog := WARenderCanvas builder
>>                                          fullDocument: true;
>>                                          rootBlock: [ :root | root beHtml5; title: anException description ];
>>                                          render: [ :html |  … whatever you want ... ].
>>
>>          self requestContext respond: [ :response |
>>                  response
>>                          internalError;
>>                          contentType: ((WAMimeType textHtml) charset: 'utf-8’);
>>                          nextPutAll: errorDialog ]
>>
>>
>> warning: coded in email editor ;)
>> Take a look at WAHtmlErrorHandler as well
>>
>> cheers
>> Johan
>>
>>> On 6 Sep 2018, at 14:50, [hidden email] wrote:
>>>
>>> Hi there,
>>>
>>>
>>> I must be sitting on my brain at the moment...
>>>
>>> How do I set the charset=utf-8 header in a WAHtmlErrorHandler subclass?
>>>
>>>
>>> Joachim
>>>
>>> _______________________________________________
>>> 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


_______________________________________________
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 set the charset in WAHtmlErrorHandler

jtuchel
In reply to this post by Johan Brichau-2
Thanks Johan,

Am 06.09.18 um 15:24 schrieb Johan Brichau:
Something along these lines:               
    self requestContext respond: [ :response |
        response
            internalError;
            contentType: ((WAMimeType textHtml) charset: 'utf-8’);

This was exactly what was missing. WAMimeType>>#charset:

btw: I just noticed Seaside has implementers of charset: and charSet: unfortunately not in a way that you can always use either one.
Maybe a candidate for a "next time we do some cleanup" list.


Joachim

_______________________________________________
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 set the charset in WAHtmlErrorHandler

jtuchel
In reply to this post by Johan Brichau-2
I just saw that maybe the setting of the charset to the one of the
requestContext might be a good idea for inclusion in the Seaside code
rather than overriding it in my subclass.

So where can I add a bug entry for that (and can I at all)?

Jaochim

_______________________________________________
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 set the charset in WAHtmlErrorHandler

Philippe Marschall
In reply to this post by jtuchel
On Fri, Sep 7, 2018 at 7:59 AM [hidden email]
<[hidden email]> wrote:

>
> Thanks Johan,
>
> Am 06.09.18 um 15:24 schrieb Johan Brichau:
>
> Something along these lines:
>     self requestContext respond: [ :response |
>         response
>             internalError;
>             contentType: ((WAMimeType textHtml) charset: 'utf-8’);
>
>
> This was exactly what was missing. WAMimeType>>#charset:
>
> btw: I just noticed Seaside has implementers of charset: and charSet: unfortunately not in a way that you can always use either one.
> Maybe a candidate for a "next time we do some cleanup" list.

That has been known for a while :-(

https://github.com/SeasideSt/Seaside/issues/745

Cheers
Philippe
_______________________________________________
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 set the charset in WAHtmlErrorHandler

Philippe Marschall
In reply to this post by jtuchel
On Fri, Sep 7, 2018 at 7:57 AM [hidden email]
<[hidden email]> wrote:

>
> Philippe,
>
> Am 06.09.18 um 17:22 schrieb Philippe Marschall:
> > Something like
> >
> > self handler charSet
> > is probably better than hard coding utf-8.
>
> agreed. Although WAHtmlErorHandler doesn't implement #handler. So I
> ended up with this:
>
>
>          response
>
>              internalError;
>
>              contentType: ((WAMimeType textHtml) charset: self requestContext charSet);
>
>
> Thanks for your tip.

https://github.com/SeasideSt/Seaside/issues/998

Cheers
Philippe
_______________________________________________
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 set the charset in WAHtmlErrorHandler

jtuchel
Thanks!



> Am 08.09.2018 um 17:14 schrieb Philippe Marschall <[hidden email]>:
>
> On Fri, Sep 7, 2018 at 7:57 AM [hidden email]
> <[hidden email]> wrote:
>>
>> Philippe,
>>
>>> Am 06.09.18 um 17:22 schrieb Philippe Marschall:
>>> Something like
>>>
>>> self handler charSet
>>> is probably better than hard coding utf-8.
>>
>> agreed. Although WAHtmlErorHandler doesn't implement #handler. So I
>> ended up with this:
>>
>>
>>         response
>>
>>             internalError;
>>
>>             contentType: ((WAMimeType textHtml) charset: self requestContext charSet);
>>
>>
>> Thanks for your tip.
>
> https://github.com/SeasideSt/Seaside/issues/998
>
> Cheers
> Philippe
> _______________________________________________
> 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