Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF application using IE11 with Enterprise Mode

Our application cannot run with IE11 and EM. We are using modify JSF-1.2 and RichFaces 3.X . When we run Web page on IE11 without EM all working OK, but we have to use IE11 with EM. Is any possible method to disable EM for page from code?

IE console raising error: "XML5632: Only one root element is allowed." It occurs when moving between pages.

PS: Application working on IE8, IE9 and IE11 without any problems but when you try it with IE11 and EM It´s raising error.

like image 424
Eddy_Screamer Avatar asked Dec 11 '14 16:12

Eddy_Screamer


People also ask

How do I use enterprise mode in ie11?

Navigate to User Configuration > Administrative Templates > Windows Components > Internet Explorer. Scroll down and locate the Let users turn on and use Enterprise Mode from the Tools menu option. Double-click it, set it to Enabled, and users will be able to enable Enterprise Mode manually.

How do I turn off enterprise mode in ie11?

Go to the Use the Enterprise Mode IE website list setting, and then click Disabled. Enterprise Mode will no longer look for the site list, effectively turning off Enterprise Mode.


1 Answers

Solution for this problem is not sanding XHTML from server but native HTML. This providing filter which change response from application/xhtml+xml to text/html. Filter get response form header of user agent and find if is set „compatible; msie 8.0“ which means, that IE11 runs under Enterprise Mode and Emulate IE8.

Our implemented solution:

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

   String userAgent = ((HttpServletRequest) request).getHeader("user-agent");

   if (userAgent != null && userAgent.toLowerCase().contains("compatible; msie 8.0"))
    {   
     chain.doFilter(request, new ForcableContentTypeWrapper((HttpServletResponse) response));
    }
    else 
    {
     chain.doFilter(request, response);
    }
}

private class ForcableContentTypeWrapper extends HttpServletResponseWrapper
{
     public ForcableContentTypeWrapper(HttpServletResponse response)
    {
    super(response);
    }

    @Override
    public void setContentType(String type)
    {
      if (type.contains("application/xhtml+xml")) 
    {
        super.setContentType(type.replace("application/xhtml+xml", 
                                          "text/html"));
    }
    else 
    {
      super.setContentType(type);
    }

     }
 }
like image 60
Eddy_Screamer Avatar answered Sep 30 '22 15:09

Eddy_Screamer