Emoji JavaEE JSF JBOSS ORACLE

3

I have a WEB System and have been asked to put emoticons for sending e-mail.

I had some problems with the database encoding that is Oracle and the NLS_CHARACTERSET was set to WE8MSWIN1252 . In order to not change the structure of the database, I have made a solution that saves the emoticons in a field of type BLOB , that is:

// pego esse valor e salvo no BD na coluna Tipo BLOB
String em = emoji.getBytes("UTF-8");

To redeem the value of emoji as String I do:

// BLOB formatado para string
String em = new String(getEmoji, "UTF-8"); 

If I make a System.out.printl(em) emoji usually appears on my console, but when I send this String to a value of <h:inputText/> a black diamond with ? appears.

I've been trying to resolve for some time, including changing the JBOSS settings for UTF-8 encoding, and the xhtml files are saved as UTF-8. Could someone point me in some direction towards the solution?

Update The HTML Header is as follows:

<f:view contentType="text/html; charset=UTF-8"
        encoding="UTF-8"
        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"
        xmlns:a="http://richfaces.org/a4j"
        xmlns:rich="http://richfaces.org/rich"
        xmlns:s="http://jboss.com/products/seam/taglib">

       <html>
          <head>
             <meta http-equiv="X-UA-Compatible" content="IE=8"/>
             <meta name="author" content="#{applicationService.getPropertyValue('app.fullname')}"/>
             <meta http-equiv="Content-Language" content="pt-BR"/>
             <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <meta http-equiv="Cache-Control" content="public, must-revalidate"/>
          </head>
      </html>
</f:view>

Update

As suggested by Gustavo Fragoso I saved the emoji string # x1F354, by passing the value to the inputText the string was converted to

Update: As suggested by Gustavo Fragoso could be a problem with my browser more is not; I am using a library called jQuery-emoji-picker and my front-end works perfectly, if I click on some emoji it will normally go into the input, the problem is when I do the opposite ie if the emoji string comes from the bank or if I manually paste emoji into the value of inputText when rendering html the emoji is converted to ; I was almost certain that some configuration in JBOSS was converting any request and response to another encoding other than UTF-8; so I made a filter that forced HTTP requests into UTF-8 encoding and looked like this:

package br.com.dt.filter;

import static org.jboss.seam.ScopeType.APPLICATION;

import static org.jboss.seam.ScopeType.APPLICATION;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.annotations.web.Filter;
import org.jboss.seam.web.AbstractFilter;

@Scope(APPLICATION)
@Name("encodingFilter")
@Install(precedence = Install.BUILT_IN)
@BypassInterceptors
@Filter
public class EncodingFilter  extends AbstractFilter{
    /** Preform the filtering. */
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {  
           response.setContentType("text/html; charset=UTF-8");  
           request.setCharacterEncoding("UTF-8");  
           response.setCharacterEncoding("UTF-8");  
           chain.doFilter(request, response);  
      }  
}

more unsuccessful, so I configured JBOSS in standalone.xml by placing:

 system-properties
        property name="file.encoding" value="utf-8"/
        property name="org.apache.catalina.connector.URI_ENCODING" value="UTF-8"/
        property name="org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING" value="true"/
    /system-properties

But also without success so far.

Update:

In Web Resources - Configuration there are several configuration files of faces-config.xml and one of them is called jsf-facelets.jar and see how it is configured:

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE faces-config PUBLIC
 "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
 "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">

<faces-config>
    <component>
        <component-type>facelets.ui.Repeat</component-type>
        <component-class>com.sun.facelets.component.UIRepeat</component-class>
    </component>
    <component>
        <component-type>facelets.ui.ComponentRef</component-type>
        <component-class>com.sun.facelets.tag.ui.ComponentRef</component-class>
    </component>
    <component>
        <component-type>facelets.ui.Debug</component-type>
        <component-class>com.sun.facelets.tag.ui.UIDebug</component-class>
    </component>
    <render-kit>
        <render-kit-id>HTML_BASIC</render-kit-id>
        <renderer>
            <component-family>facelets</component-family>
            <renderer-type>facelets.ui.Repeat</renderer-type>
            <renderer-class>com.sun.facelets.component.RepeatRenderer</renderer-class>
        </renderer>
    </render-kit>
</faces-config>

Is this ISO-8859-1 setting the reason for this problem?

    
asked by anonymous 05.11.2018 / 19:11

0 answers