0

My jsf facelets webapplication uses h:selectonemenu which is populated (from mysql DB) with names, written with english and thai characters.

Deployed on glassfish-3.1.2.2 jsf 2.1, there is no problem at all.

Deployed on glassfish-4.0 jsf 2.2 EE7, if a name, which is written in thai language (english names no problem) is selected, i get a validation error value not valid.

After google around for hours, i can not find anything addresses this problem. Seems i am the only one, with this problem.

For debug reason i did add a custom converter into the .xhtml:

<h:selectOneMenu id="selCust" value ="#{OfficeBean.selectcust}" converter="#{zConverter}">

And in the backing Bean a System.out.println():

public Object getAsObject(FacesContext context, UIComponent component,
    String value) {

String submittedValue = value; System.out.println("converter value: "+submittedValue);

From the Server 3.1.2.2 log file I get:

[#|2014-02-18T01:45:16.184+0800|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=125;_ThreadName=Thread-2;|converter value: A-117,บริษัท โมเดอร์นฟู้ด อินดัสตรี้ จํากัด|#]

From the Server 4.0 log file I get:

[2014-02-17T19:13:47.055+0800] [glassfish 4.0] [INFO] [] [] [tid: _ThreadID=18 _ThreadName=Thread-3] [timeMillis: 1392635627055] [levelValue: 800] [[ converter value: A-117,à ̧à ̧£à ̧ ́à ̧©à ̧±à ̧ à1à ̧£à ̧à ̧à ̧2à ̧à1à ̧¡à1à ̧£à ̧§à ̧¢ à ̧à ̧3à ̧à ̧±à ̧]]

which results in value not valid.

I think, somewhere I did miss a character encoding related setup.

Any help would be very appreciated. Thanks.

1 Answers1

0

I did add in the above mentioned zConverter:

if(submittedValue.contains("à")){
    try {
        submittedValue = new String (value.getBytes ("iso-8859-1"), "utf-8");


} catch (UnsupportedEncodingException ex) {
        Logger.getLogger(zConverter.class.getName()).log(Level.SEVERE, null, ex);
    }
   }

Because the encoding was wrong, only, when the validation was invoked the first time. Later on, there was no problem anymore.?

Anyway for me it works now.

Regards