Thanks, Janne. I got the Stripe's form to refill with a valid value! But ${actionBean.field} won't work now. I have a filter that sets "request.setCharacterEncoding("UTF-8");" as you suggested. Then I print on my JSP: Last: ${actionBean.test} The action bean and the form are below. So stripes fills in fields fine, but the HTML displays ????

<s:form beanclass="web.actions.UTF8" method="post/get" acceptcharset="UTF8">
<s:text name="test"/>
<s:submit name="done"/>
</s:form>


@UrlBinding("/test.action")
public class UTF8 extends MyActionBean
    {
        private String test;

        public String getTest()
            {
                return test;
            }

        public void setTest(String test)
            {
                this.test = test;
            }

        public Resolution test()
            {
                return getContext().getSourcePageResolution();
            }
}

On 2/4/2011 4:16 PM, Janne Jalkanen wrote:
Simple solution: declare the accept-charset value on all your forms to be "UTF-8" (and *only* 
UTF-8), then put up a simple Filter in front of your chain which says 
"request.setCharacterEncoding("UTF-8"). This should ensure that you get full unicodes to 
the ActionBean, and then you only have to deal with your DB encodings.

Works for me well.

/Janne

On 4 Feb 2011, at 22:45, Daniil Sosonkin wrote:

Hi there,

So I'm sure there's someone out there who has met this problem and has found a 
solution, therefore, let me ask the source. We are dealing with an 
international web platform - many many languages. People submit forms in 
different languages and it all stored in a mySQL database. Basically, I'm 
having troubles getting UTF8 to work with said database. I have troubles at all 
levels - stripes and database.

Here's my set up:
    - mySQL 5.1
    - mysql-jdbc 5.1 (driver)
    - tables - utf8
    - LocalePicker is always forcing charset to UTF-8 in stripes

Here's the problem:
    - User enters some characters into the form (chinese, russian, hebrew....)
    - ActionBean sticks it into the database and sends email.
    - Fields are declared as Strings and nothing is done to the values
    - When sticking to the database it will contain - ???? as values
    - The output from the database obviously doesn't work
    - When printing submitted value on page from ${actionBean.field} it 
displays junk

I know that browsers send all forms to the servers in ISO-8859-1 encoding. In the good old days, or 
with plain servlets, I would always have to convert submitted values to UTF-8 with the following: 
new String(rs.getString(1).getBytes("ISO-8859-1"), "UTF-8"); From then on the 
value is in UTF-8

In Stripes, I think that the values come to ActionBeans in ISO-8859-1 since 
StringTypeConverter doesn't do anything. That's fine, I wrote my own converter 
for UTF using the logic from above. This solves the problem with printing 
submitted value on the page ${actionBean.field}; but if the value is still 
displayed in the form it is all grumbled as if it was ISO-8859-1 representation 
of UTF-8. That I don't understand.

As for storing UTF8 into mySQL - well, if someone can help me out it would be 
great since I can't get UTF8 string stored in the database without doing the 
UTF8 to ISO-8859-1 and back conversion while keeping tables at latin1 I would 
really appreciate it. The main question is Stripes.

I hope this whole rambling makes sense and someone has had this problem 
previously. Hopefully there was a solution.

Sincerely,
Daniil
<daniil.vcf>------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world?
http://p.sf.net/sfu/oracle-sfdevnlfb_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world?
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

<<attachment: daniil.vcf>>

------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to