Fixing Trinidad IE 11 Partial Page Request (PPR) Issue / Support All IE Browsers With Examples

Trinidad 1.2.14 is MyFaces implementation for JSF 1.2 specification. It’s mainly released by Apache MyFaces and it’s considered last official release that you can download from Apache MyFaces Trinidad site.

Actually, Trinidad library is a leading library that truly help you getting JSF application in the most easiest way, it’s contained a lot of important components that can help you avoid wasting your time creating or developing any component you may need.

This version of Trinidad is almost ideal but there’s one issue you may be suffering from when it comes to deal with, it’s actually doesn’t understand Ajaxifying request on IE 11 and that may cause a headache for a lot of developers whom want to use this feature.

This tutorial is a solid trial that would help you getting full-fledged Trinidad 1.2.14 library ajaxified comfortably on all version of IE including IE 11. You may review the internet and Trinidad JIRA but actually, you my be wondering that the Trinidad itself doesn’t provide any solution for that. All what you may find is just a scattered patch that’s required you to work on it to justify the needed solution.

Tools Used

I’ve assumed that you will use the below Tools/Envs for getting this practice applied:

  • Any JEE container.
  • JSF Trinidad 1.2.14 API & Impl.
  • JDK 1.6.
  • Eclipse Kepler 4.3.
  • Maven 3.2.1.

Ajax Concept In Trinidad

Ajax concept hasn’t vary differ from what already most of developers were knew. It’s simple partial submission for the page; instead of sending a full JSF Post-Back request into server, you’re just sending part of the page into server and update part of it in the response.

Here, you would see a true Ajax application that uses a Trinidad 1.2.14 upon Chrome browser. In fact and indeed the implementations of Ajax aren’t analogous to that degree that you may use different mechanisms for ِAjaxifying your application if you’re decided to use different JSF vendors. That is, there’s no standard way to Ajaxify, so it depends on the library that you’re going to use.

index.jsp

MessageBackingBean.java

faces-config.xml

pom.xml

web.xml

Here’s detailed explanation for the code listed above:

  • Trinidad has initiated a PPR through using of its library that’s grabbed by resources Servlet. This script library will be injected into your JSF page as soon as it’s rendered and it would have this name /CONTEXT/adf/jsLibs/Common1_2_14.jsif you’re explored your page header.
  • The action Ajax Sending will be used to ajaxify the calling of addMessage method/action.
  • The action Non-Ajax Sending will be used to initiate normal PostBack request.
  • As soon as the Ajax request is triggered, the Ajax loader image will be displayed by statusIndicator Trinidad Tag. This will give you a good indicator for being the request is initiated using Ajax manner.
  • At the MessageBackingBean, you will be waiting there in for 5 seconds, just to give you a chance simulating heavy processing.

Now, let’s see a simple demonstration for what already implemented till now using a non error prone Chrome browser.

Below figure shows you the initial view of the index.jsp that’s already considered as default page.

Trinidad-Application-Initial-View-1024x140

Enter a message inside the box below and submit the Ajax Sending action. You will notice that the ajax indicator loading image will be displayed, just wait for 5 seconds before the message is sent.

Trinidad-Application-Initial-View-1024x140

Trinidad-Application-Ajax-Message-Sending-Message-Added-1024x125

The same behavior can be achieved through using a default Post Back JSF action and the same result would be occurred with one major difference is being the request is Post back.

Trinidad-Application-Non-Ajax-Message-Sending-Message-Added-1024x143

What’s The Problem

As you’ve noticed above, Ajax Trinidad has functioned properly on the Chrome where no issues were noticed. But what if you’re going to IE 11, you will absolutely get Ajax failed due to Trinidad Implementation missing.

Let’s look at the behavior below that shows you the impact of browsing the same Application above on the IE 11 – Notice, this issue weren’t noticed at any version of IE and that what i will explore in the next coming lines

Trinidad-Application-Initial-View-1024x140

Here’s below a detailed explanation for the behavior seen above:

  • Once you’ve clicked on the Ajax action, the ajax loading image will be displayed but actually the behavior is little bit different where the IE won’t get updated the Table of Sent Messages as well as an error message will be thrown says Connection Failed.
  • If you’ve reviewed your Console or Logger, you’re likely get an exception like below.

Thrown Exception

  • Actually, the above listed exception wasn’t thrown on any browser except the IE 11, even if you’re used IE 7, 8, 9 or 10 this issue won’t be noticed.
  • This above exception is caused due to unavailability of correct Agent value. That is, RequestContextImplgetAgent will be asked to determine the type of the Agent that actually try to display the view. By its turn, the AgentFactoryImpl_populateMozillaAgentImpl method will be called because the Agent description starts with Mozilla keyword.
  • The _populateMozillaAgentImpl method will return wrong value that’s affected the normal procedure of your Partial Page Trigger (PPR) handling. User agent of IE 11 is Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko and the _populateMozillaAgentImpl method won’t be able to recognize the Agent Type which will be finally just like in the figure below:
  • But if you’re modifying the user agent string from your IE browser to be Internet Explorer 10 or less and you tried to initiate a new Partial Page Request, you will find a different agent string, that will be Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)and the agent type will be just like figure below:
  • The same correct value you will still be able to receive as long as you used an IE version less than 11. Look below for the value of IE 8.
  • Agent-value-for-IE-8-1024x349

As a conclusion, the main issue is relevant for _populateMozillaAgentImpl that should be fixed to contain a proper handling for IE 11.

Importing Trinidad 1.2.14 Source Code Impl Library into Eclipse Project

To know the main cause of this issue, it’s worthy to get Trinidad Impl debugged to know from where we can start the fix procedure. Upon that, let’s basically download Trinidad 1.2.14 and look inside to know what the cause of this behavior.

  • Download Trinidad impl 1.2.14 source code from Trinidad Apache official site.
  • Unzip trinidad-1.2.14-src-all.zip into your hard storage.
  • From your Eclipse Project Explorer, click new – import and choose Maven project.
  • Paste your Trinidad location just as you see below.
  • Success-Cleaning-Packaging-of-Trinidad-Impl
  • Now, you’re able of getting Trinidad Impl compiled and packaged through using of both Maven command & Eclipse. Figure below shows you the success cleaning and packaging for Trinidad Impl library.
  • Success-Cleaning-Packaging-of-Trinidad-Impl
  • Now, you can provide your Fix for the AgentFactoryImpl and provide your own Trinidad Impl library.

Fixing AgentFactoryImpl

According for the previous investigation and to fix the issue of IE 11, I’ve provided you the new implementation of _populateMozillaAgentImpl to be like below:

_populateMozillaAgentImpl

Here’s detailed explanation for the code listed above:

  • We added the code commented to handle the IE 11 & all types of IEs.
  • You can download the full AgentFactoryImpl right here AgentFactoryImpl.
  • Replace the downloaded file or re-implement the method and make your code compiled and package the updated Trinidad impl library just like you saw in the Maven figure above.
  • Install your latest Trinidad Impl library using mvn clean package install.

Demonstrate PPR Sample Using IE 11 After Fixing

This figure below shows you a proper handling for the PPR request against IE 11.

IE-11-Fixed-PPR-Demonstration-1024x249

IE-11-Fixed-PPR-Demonstration-1024x249

Resources

Summary

Trinidad is a leading implementation for JSF and it provides you a different kinds of components that actually have the capability of initiating requests Post back or partially. The main issue you may got when it comes to deal with Trinidad latest release 1.2.14 is handling partial request on IE 11.  This tutorial will help you getting this issue resolved, so contribute us by commenting below.

By admin

Leave a Reply

%d bloggers like this: