Patching RichFaces 3.3.3 AJAX.js for IE11

Couple of years ago I wrote about patching RichFaces 3.3.3 AJAX.js for IE9 and as the browser world has moved on, it’s now time to patch RichFaces 3.3.3 AJAX.js for Internet Explorer 11. Of course you could update your web application to JSF 2 and RichFaces 4 or PrimeFaces but it’s neither trivial nor free. The issue with RichFaces 3.3.3 still stands, development has moved to 4.x version and they’ve dropped support for the older versions although at least IE issues could be easily fixed. Fortunately patching RichFaces AJAX.js is relatively easy.

The problem with Internet Explorer 11 is that although you upgraded Sarissa Framework and patched RichFaces AJAX.js file for IE 9 it just isn’t enough anymore as IE 11 uses different User-agent string and disguises itself as “like Gecko”. The User-agent string in Win 8.1 for IE11 is “Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko”. The issue is also discussed on JBoss Forums and on Stack Overflow.

The different User-agent string breakes the “rerender” after Ajax Request. For example using a4j:function in combination with “rerender” is not working on IE 11 and the problem is that after Ajax request the result XML can’t be correctly append to the body. Also the rerendering is abnormal for h:inputTextarea, rich:modalPanel, h:inputTextarea and rich:calendar.

Fortunately the fix is simple as RicFaces issue RF-13443 tells.

Patching RichFaces 3.3.3 AJAX.js for IE 11

Step 1: Do the “Upgrading Sarissa Framework and patching RichFaces AJAX.js file” steps in my Patching RichFaces 3.3.3 AJAX.js for IE9 article.

Step 2: Edit the AJAX_IE9fix.js file you just created and add IE 11 checking to Sarissa._SARISSA_IS_IE and Sarissa._SARISSA_IS_IE9. The changed lines should look like the following:

Sarissa._SARISSA_IS_IE = (document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1) || (navigator.userAgent.toLowerCase().indexOf("like gecko") > -1 && navigator.userAgent.toLowerCase().indexOf("11.") > -1);

Sarissa._SARISSA_IS_IE9 = Sarissa._SARISSA_IS_IE && (parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE")+5))) >= 9 || (navigator.userAgent.toLowerCase().indexOf("like gecko") > -1 && navigator.userAgent.toLowerCase().indexOf("11.") > -1);

If all fails you can try to tell IE 11 to emulate IE 10 with adding X-UA-Compatible meta tag to head.


The other thing I noticed with RichFaces 3.3.3 and modern browsers is that if you use ui:fragment which contains rich:suggestionbox and rerender it, the suggestionbox doesn’t work correctly. It gives an error: SCRIPT5007: Unable to get property 'parentNode' of undefined or null reference. For now I didn’t have time to figure out the issue and just changed my page structure and function.

Although it’s 2015 using JSF 1.2 and RichFaces 3.3.3 is still working quite nicely :)


Posted

in

by

Comments

6 responses to “Patching RichFaces 3.3.3 AJAX.js for IE11”

  1. Victor Zamora Avatar

    Thanks a lot!!! This patch saved a major problem in a big project.
    Thanks!

  2. Ravi Avatar
    Ravi

    Hi,
    I have applied the same thing but with richfaces-3.2.1.GA.jar.
    I am getting ‘SCRIPT28: Out of stack space’
    File: AJAX_IE9fix.js, Line: 619, Column: 33

    Do you have any idea or any solution for this ?

  3. Volkert de Buisonjé Avatar

    Hi! Thanks for this useful information!

    Note however, that your IE detection code for Sarissa._SARISSA_IS_IE9 now fails again in Microsoft Edge.

    I adapted your fix a bit and made it work with Microsoft Edge as well.

    Due to lack of actvity at the official Sarissa project web site, I started a 0.9.9.7-SNAPSHOT branch of Sarissa at https://github.com/volkertb/sarissa/tree/0.9.9.7-SNAPSHOT. It is not intended as an official fork. I just prefer working with Git and GitHub over CVS and SourceForge (even though SourceForge also supports Git these days).

    This new branch is based on the latest CVS trunk from the upstream Sarissa repository on SourceForge, which apparently includes some additional fixes since the 0.9.9.6 release, even though it was still given the version 0.9.9.6 in the source code, which was frankly confusing. Therefore I bumped it up to 0.9.9.7-SNAPSHOT in my branch, since no official version after 0.9.9.6 has been released yet. On top of that, my branch includes the Sarissa-specific fixes you shared, as well as my adaption to make it work with Microsoft Edge as well. I also applied a XMLSerializer wrapping code fix that I adapted from the fix for RichFaces issue NXBT-677, original commit https://github.com/nuxeo/richfaces/commit/5afdc76a78c18ccc965af04dea79ab7cfec96bb3

    Feel free to check it out, provide feedback an/or create pull requests with further improvements! :-)

    1. Patrick Avatar
      Patrick

      Hi,

      thanks for that fix.I just have one question regarding the replacePage function.

      A4J.AJAX.replacePage = function(req){
      if(!req.getResponseText()){
      LOG.warn(“No content in response for replace current page”);
      return;
      }
      LOG.debug(“replace all page content with response”);
      var isIE = _SARISSA_IS_IE;

      The last line is wrong in my opinion and needs to be
      var isIE = Sarissa._SARISSA_IS_IE;

      I think there is a mission sarissa reference.

  4. Russ Avatar
    Russ

    >> Although it’s 2015 using JSF 1.2 and RichFaces 3.3.3 is still working quite nicely :)
    I’m curious though whether you’ve noticed a delay on IE11 loading pages where r:dropDownMenu, r:dataTable and/or r:column were used?

    We’re using a similar stack (yay for early adopters – we were still on 3.2.2 because we thought the next step was JSF2) and since the menu was on every page our users were a little unhappy to get a 5 second delay on each page. I determined the issue was related to RichFaces and swapped out the menu for a DHTML version we abandoned in 2008 and modernized it a bit; but we still have a few pages that experience the delay. Wondering whether we’re the only ones.

    1. Marko Avatar

      Can’t say that I’ve noticed delays particularly with IE 11 when using RichFaces 3.3 and JSF 1.2. We have dropdownmenus but use Tomahawk’s datatables as RF datatable’s didn’t work well with large datasets (slow, would’ve needed custom paging).

      Fortunately I’ve nowadays left that legacy project behind and moved on to modern UI stack :)

Leave a Reply

Your email address will not be published. Required fields are marked *