webtier@glassfish.java.net

Encoding issue in new JSF2 ajax tag

From: <forums_at_java.net>
Date: Thu, 14 Apr 2011 14:15:46 -0500 (CDT)

Hi,   I'm trying to include an ajax feature in my application and I'm having
some trouble with that. I add a textfield in a page of my app and using
<f:ajax> tag. Then I try to send the value of this field to server in a
'keyup' event. But what is happening is if I type some accent character, like
'ç' for example, in text field, the 'set' method at server side receive
weird character like "ç". Am I doing something wrong ? Is it a JSF bug ?
Are there some walkaround? I'm using Glassfish v3.1 server.  Follow the code
I'm using.
I thanks in advance for any help.

Cristiano (English is not my native language, so if I was not clear, please
just ask me to clarify)
 

test.xhtml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"> <f:view contentType="text/html"
encoding="UTF-8"> <h:head> <meta http-equiv="content-type"
content="text/html; charset=UTF-8" /> <title>teste</title> </h:head> <h:body>
<h:form acceptcharset="UTF-8" enctype="application/x-www-form-urlencoded;
charset=UTF-8"> <fieldset> <br/><br/><br/> <h:inputText
value="#{fieldTest.field}"> <f:ajax event="keyup" render="field1"/>
</h:inputText> <br/> <h:outputText value="#{fieldTest.field}" id="field1"/>
</fieldset> </h:form> </h:body> </f:view>
FieldTest.java

package teste; import javax.annotation.PostConstruct; import
javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped;
@ManagedBean @RequestScoped public class FieldTest { private String field =
""; public FieldTest() { } public String getField() { return field; } public
void setField(String field) { this.field = field; System.out.println(">>>
"+field); }  

 


--
[Message sent by forum member 'cmoraes']
View Post: http://forums.java.net/node/792025