You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Fabio Fioretti <wi...@gmail.com> on 2007/10/19 19:11:40 UTC

Weird Ajax non-English characters encoding problem.

Hi all,

thanks in advance for your time and suggestions.

I'm building a really simple page made up of a form with a text area
and a submit button (instance of Button). An AjaxFormSubmitBehavior
that performs the "save" operation is added to the button. The page is
encoded as follows:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

Everything works fine until a user submits a non-English text (French
or Spanish, with characters like "íéñ", still supported by the
ISO-8859-1 encoding): all non-English characters are scrambled.

What appears weird to me is that the problem doesn't happen if I use,
for example, a SubmitLink instead of an Ajax-enabled Button.

This makes me point to Ajax as the responsible, and to the fact that
Wicket uses UTF-8 for requests... but I really have no clue about how
to fix it.

Any idea?


Thank you very much and have a nice week-end.

Fabio Fioretti - WindoM

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Weird Ajax non-English characters encoding problem.

Posted by Johan Compagner <jc...@gmail.com>.
is this reproduceable in a simple testcase? (junit)

johan



On 10/22/07, Paolo Di Tommaso <pa...@gmail.com> wrote:
>
> I'm experiencing a similar problem i.e.  I'm able to submit any Latin
> encoded characters but when I'm using an AjaxSubmitButton some characters
> are not encoded properly. This happens also specifying the right encoding
> with:
>
> getRequestCycleSettings().setResponseRequestEncoding("ISO-8859-1");
>
>
> So it appears to be clear that is an ajax encoding problem with wicket.
>
>
> Looking at the Wicket ajax code I found the following fragment:
>
>        if (t != null) {
>            t.open("POST", url, this.async);
>            t.onreadystatechange = this.stateChangeCallback.bind(this);
>            t.setRequestHeader("Content-Type",
> "application/x-www-form-urlencoded");
>            t.setRequestHeader("Wicket-Ajax", "true");
>            t.send(body);
>            return true;
>        } else {
>               this.failure();
>               return false;
>        }
>
>
> Now, how is defined the content encoding of an ajax request? I was
> expecting
> something like charset=<defined encoding> in the ajax request request
> header.
>
> Otherwise how the IRequestCycleSettings#setResponseRequestEncoding() will
> affect the charset definition in the ajax call?
>
> Thanks,
>
> Paolo
>
>
> On 10/22/07, Fabio Fioretti <wi...@gmail.com> wrote:
> >
> > Hi Matej and Johan,
> >
> > thanks for your replies.
> >
> > I'm using Latin1 because the page I'm talking about is part of a
> > legacy web application fully encoded in ISO-8859-1. The application
> > server it runs on is Tomcat 5.5, which defaults to Latin1, so it
> > shouldn't be a problem.
> >
> > I tried to set the request/response encoding in the application main
> > class using:
> >
> > getRequestCycleSettings().setResponseRequestEncoding("ISO-8859-1");
> >
> > but nothing changed, except that Wicket Ajax Debug now prints:
> >
> > INFO:
> > <?xml version="1.0"
> encoding="ISO-8859-1"?><ajax-response></ajax-response>
> >
> > The problem I'm facing seems the same Stefan Lindner faced last year,
> > whithout apparently finding a solution. I tried everything he tried.
> > See link:
> >
> >
> http://www.nabble.com/AjaxSubmitButton-and-Umlauts-with-ISO-8859-1-%28Wicket-2%29-tf2622064.html
> >
> >
> > I could migrate the whole application to UTF-8, but I would't do that
> > for a single textarea in a single page... :-) It's the only page that
> > needs non-English input.
> >
> >
> > Any suggestion?
> >
> >
> > Thanks a lot,
> >
> > Fabio Fioretti - WindoM
> >
> >
> > On 10/21/07, Matej Knopp <ma...@gmail.com> wrote:
> > > I don't know tbh. I believe the request body is encoded in UTF-8.
> > > People usually use UTF-8, so no-one was complaining before. Can't you
> > > just use UTF-8? It's much safer than latin1.
> > >
> > > -Matej
> > >
> > > On 10/20/07, Johan Compagner < jcompagner@gmail.com> wrote:
> > > > are you configuring wicket and you appserver correctly?
> > > > in wicket you have to set the encoding you want to use
> > > > why not just use utf8?
> > > > else matej?
> > > > How does the ajax submit work with encoding?
> > > > It is still a normal post and how do we interpret it?
> > > >
> > > >
> > > > On 10/19/07, Fabio Fioretti < windom.macrosorch@gmail.com> wrote:
> > > > > Hi all,
> > > > >
> > > > > thanks in advance for your time and suggestions.
> > > > >
> > > > > I'm building a really simple page made up of a form with a text
> area
> >
> > > > > and a submit button (instance of Button). An
> AjaxFormSubmitBehavior
> > > > > that performs the "save" operation is added to the button. The
> page
> > is
> > > > > encoded as follows:
> > > > >
> > > > > <meta http-equiv="Content-Type" content="text/html;
> > charset=ISO-8859-1">
> > > > >
> > > > > Everything works fine until a user submits a non-English text
> > (French
> > > > > or Spanish, with characters like "íéñ", still supported by the
> > > > > ISO-8859-1 encoding): all non-English characters are scrambled.
> > > > >
> > > > > What appears weird to me is that the problem doesn't happen if I
> > use,
> > > > > for example, a SubmitLink instead of an Ajax-enabled Button.
> > > > >
> > > > > This makes me point to Ajax as the responsible, and to the fact
> that
> > > > > Wicket uses UTF-8 for requests... but I really have no clue about
> > how
> > > > > to fix it.
> > > > >
> > > > > Any idea?
> > > > >
> > > > >
> > > > > Thank you very much and have a nice week-end.
> > > > >
> > > > > Fabio Fioretti - WindoM
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>

Re: Weird Ajax non-English characters encoding problem.

Posted by Paolo Di Tommaso <pa...@gmail.com>.
I'm experiencing a similar problem i.e.  I'm able to submit any Latin
encoded characters but when I'm using an AjaxSubmitButton some characters
are not encoded properly. This happens also specifying the right encoding
with:

getRequestCycleSettings().setResponseRequestEncoding("ISO-8859-1");


So it appears to be clear that is an ajax encoding problem with wicket.


Looking at the Wicket ajax code I found the following fragment:

        if (t != null) {
            t.open("POST", url, this.async);
            t.onreadystatechange = this.stateChangeCallback.bind(this);
            t.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded");
            t.setRequestHeader("Wicket-Ajax", "true");
            t.send(body);
            return true;
        } else {
               this.failure();
               return false;
        }


Now, how is defined the content encoding of an ajax request? I was expecting
something like charset=<defined encoding> in the ajax request request
header.

Otherwise how the IRequestCycleSettings#setResponseRequestEncoding() will
affect the charset definition in the ajax call?

Thanks,

Paolo


On 10/22/07, Fabio Fioretti <wi...@gmail.com> wrote:
>
> Hi Matej and Johan,
>
> thanks for your replies.
>
> I'm using Latin1 because the page I'm talking about is part of a
> legacy web application fully encoded in ISO-8859-1. The application
> server it runs on is Tomcat 5.5, which defaults to Latin1, so it
> shouldn't be a problem.
>
> I tried to set the request/response encoding in the application main
> class using:
>
> getRequestCycleSettings().setResponseRequestEncoding("ISO-8859-1");
>
> but nothing changed, except that Wicket Ajax Debug now prints:
>
> INFO:
> <?xml version="1.0" encoding="ISO-8859-1"?><ajax-response></ajax-response>
>
> The problem I'm facing seems the same Stefan Lindner faced last year,
> whithout apparently finding a solution. I tried everything he tried.
> See link:
>
> http://www.nabble.com/AjaxSubmitButton-and-Umlauts-with-ISO-8859-1-%28Wicket-2%29-tf2622064.html
>
>
> I could migrate the whole application to UTF-8, but I would't do that
> for a single textarea in a single page... :-) It's the only page that
> needs non-English input.
>
>
> Any suggestion?
>
>
> Thanks a lot,
>
> Fabio Fioretti - WindoM
>
>
> On 10/21/07, Matej Knopp <ma...@gmail.com> wrote:
> > I don't know tbh. I believe the request body is encoded in UTF-8.
> > People usually use UTF-8, so no-one was complaining before. Can't you
> > just use UTF-8? It's much safer than latin1.
> >
> > -Matej
> >
> > On 10/20/07, Johan Compagner < jcompagner@gmail.com> wrote:
> > > are you configuring wicket and you appserver correctly?
> > > in wicket you have to set the encoding you want to use
> > > why not just use utf8?
> > > else matej?
> > > How does the ajax submit work with encoding?
> > > It is still a normal post and how do we interpret it?
> > >
> > >
> > > On 10/19/07, Fabio Fioretti < windom.macrosorch@gmail.com> wrote:
> > > > Hi all,
> > > >
> > > > thanks in advance for your time and suggestions.
> > > >
> > > > I'm building a really simple page made up of a form with a text area
>
> > > > and a submit button (instance of Button). An AjaxFormSubmitBehavior
> > > > that performs the "save" operation is added to the button. The page
> is
> > > > encoded as follows:
> > > >
> > > > <meta http-equiv="Content-Type" content="text/html;
> charset=ISO-8859-1">
> > > >
> > > > Everything works fine until a user submits a non-English text
> (French
> > > > or Spanish, with characters like "íéñ", still supported by the
> > > > ISO-8859-1 encoding): all non-English characters are scrambled.
> > > >
> > > > What appears weird to me is that the problem doesn't happen if I
> use,
> > > > for example, a SubmitLink instead of an Ajax-enabled Button.
> > > >
> > > > This makes me point to Ajax as the responsible, and to the fact that
> > > > Wicket uses UTF-8 for requests... but I really have no clue about
> how
> > > > to fix it.
> > > >
> > > > Any idea?
> > > >
> > > >
> > > > Thank you very much and have a nice week-end.
> > > >
> > > > Fabio Fioretti - WindoM
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Weird Ajax non-English characters encoding problem.

Posted by Fabio Fioretti <wi...@gmail.com>.
Hi Matej and Johan,

thanks for your replies.

I'm using Latin1 because the page I'm talking about is part of a
legacy web application fully encoded in ISO-8859-1. The application
server it runs on is Tomcat 5.5, which defaults to Latin1, so it
shouldn't be a problem.

I tried to set the request/response encoding in the application main
class using:

getRequestCycleSettings().setResponseRequestEncoding("ISO-8859-1");

but nothing changed, except that Wicket Ajax Debug now prints:

INFO:
<?xml version="1.0" encoding="ISO-8859-1"?><ajax-response></ajax-response>

The problem I'm facing seems the same Stefan Lindner faced last year,
whithout apparently finding a solution. I tried everything he tried.
See link:

http://www.nabble.com/AjaxSubmitButton-and-Umlauts-with-ISO-8859-1-%28Wicket-2%29-tf2622064.html

I could migrate the whole application to UTF-8, but I would't do that
for a single textarea in a single page... :-) It's the only page that
needs non-English input.


Any suggestion?


Thanks a lot,

Fabio Fioretti - WindoM


On 10/21/07, Matej Knopp <ma...@gmail.com> wrote:
> I don't know tbh. I believe the request body is encoded in UTF-8.
> People usually use UTF-8, so no-one was complaining before. Can't you
> just use UTF-8? It's much safer than latin1.
>
> -Matej
>
> On 10/20/07, Johan Compagner <jc...@gmail.com> wrote:
> > are you configuring wicket and you appserver correctly?
> > in wicket you have to set the encoding you want to use
> > why not just use utf8?
> > else matej?
> > How does the ajax submit work with encoding?
> > It is still a normal post and how do we interpret it?
> >
> >
> > On 10/19/07, Fabio Fioretti <wi...@gmail.com> wrote:
> > > Hi all,
> > >
> > > thanks in advance for your time and suggestions.
> > >
> > > I'm building a really simple page made up of a form with a text area
> > > and a submit button (instance of Button). An AjaxFormSubmitBehavior
> > > that performs the "save" operation is added to the button. The page is
> > > encoded as follows:
> > >
> > > <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
> > >
> > > Everything works fine until a user submits a non-English text (French
> > > or Spanish, with characters like "íéñ", still supported by the
> > > ISO-8859-1 encoding): all non-English characters are scrambled.
> > >
> > > What appears weird to me is that the problem doesn't happen if I use,
> > > for example, a SubmitLink instead of an Ajax-enabled Button.
> > >
> > > This makes me point to Ajax as the responsible, and to the fact that
> > > Wicket uses UTF-8 for requests... but I really have no clue about how
> > > to fix it.
> > >
> > > Any idea?
> > >
> > >
> > > Thank you very much and have a nice week-end.
> > >
> > > Fabio Fioretti - WindoM

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Weird Ajax non-English characters encoding problem.

Posted by Matej Knopp <ma...@gmail.com>.
I don't know tbh. I believe the request body is encoded in UTF-8.
People usually use UTF-8, so no-one was complaining before. Can't you
just use UTF-8? It's much safer than latin1.

-Matej

On 10/20/07, Johan Compagner <jc...@gmail.com> wrote:
> are you configuring wicket and you appserver correctly?
> in wicket you have to set the encoding you want to use
> why not just use utf8?
> else matej?
> How does the ajax submit work with encoding?
> It is still a normal post and how do we interpret it?
>
>
> On 10/19/07, Fabio Fioretti <wi...@gmail.com> wrote:
> > Hi all,
> >
> > thanks in advance for your time and suggestions.
> >
> > I'm building a really simple page made up of a form with a text area
> > and a submit button (instance of Button). An AjaxFormSubmitBehavior
> > that performs the "save" operation is added to the button. The page is
> > encoded as follows:
> >
> > <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
> >
> > Everything works fine until a user submits a non-English text (French
> > or Spanish, with characters like "íéñ", still supported by the
> > ISO-8859-1 encoding): all non-English characters are scrambled.
> >
> > What appears weird to me is that the problem doesn't happen if I use,
> > for example, a SubmitLink instead of an Ajax-enabled Button.
> >
> > This makes me point to Ajax as the responsible, and to the fact that
> > Wicket uses UTF-8 for requests... but I really have no clue about how
> > to fix it.
> >
> > Any idea?
> >
> >
> > Thank you very much and have a nice week-end.
> >
> > Fabio Fioretti - WindoM
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Weird Ajax non-English characters encoding problem.

Posted by Johan Compagner <jc...@gmail.com>.
are you configuring wicket and you appserver correctly?
in wicket you have to set the encoding you want to use
why not just use utf8?
else matej?
How does the ajax submit work with encoding?
It is still a normal post and how do we interpret it?


On 10/19/07, Fabio Fioretti <wi...@gmail.com> wrote:
> Hi all,
>
> thanks in advance for your time and suggestions.
>
> I'm building a really simple page made up of a form with a text area
> and a submit button (instance of Button). An AjaxFormSubmitBehavior
> that performs the "save" operation is added to the button. The page is
> encoded as follows:
>
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
>
> Everything works fine until a user submits a non-English text (French
> or Spanish, with characters like "íéñ", still supported by the
> ISO-8859-1 encoding): all non-English characters are scrambled.
>
> What appears weird to me is that the problem doesn't happen if I use,
> for example, a SubmitLink instead of an Ajax-enabled Button.
>
> This makes me point to Ajax as the responsible, and to the fact that
> Wicket uses UTF-8 for requests... but I really have no clue about how
> to fix it.
>
> Any idea?
>
>
> Thank you very much and have a nice week-end.
>
> Fabio Fioretti - WindoM
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Weird Ajax non-English characters encoding problem.

Posted by Fabio Fioretti <wi...@gmail.com>.
PS: I'm using Wicket 1.2.6.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org