Friday, December 02, 2011

ADF Mailto - IE Compatibility mode

Hi all,

Recently, I encounter a very strange issue with the mailto functionality in IE8, after looking in the web I found lots of references to the problem but not valid solutions, so I came up with this little hack/workaround for it.

Basically, the problem presents itself when the user clicks in a "mailto" link within a page that is in the "trusted zone" of IE. if the trusted zone has not compatibility mode, and the internet zone does, IE treats the mailto as being part of the Internet zone and does a weird local refresh of the page with causes the IE page to display an error ""Internet Explorer cannot display the webpage"

To add to the picture, I had UCM pages in the same URL domain with mailto links working fine, the issue only presented itself when we were adding the links to ADF taskflows.

The issue could be simply resolved by changing the IE settings, either making both the trusted zone and the internet zone run in compatibility mode or turn it off on both, unfortunately, when you roll-our to a company with mode than 8000 users, changing the IE settings is not as trivial as one may think.

So, after trying multiple things, here is what we ended up with... basically, the idea is to show the mailto in a pop-up, this way the local refresh of IE doesn't impact the page, we also needed to hide the pop-up before the refresh otherwise we end up with 2 outlook windows being open.

First off, at the begining of the JSF page, add the following JS function used to show and close the popup, the function uses the v_popop variable to identify which popup to show in case you need to add more than one link to the page

<af:resource type="javascript">
function showMailerPopup(actionEvent)
{
actionEvent.cancel();
var eventSource = actionEvent.getSource();
var v_popup = eventSource.getProperty("v_popup");
var popup = eventSource.findComponent(v_popup);
popup.show({align:AdfRichPopup.ALIGN_AFTER_START, alignId:eventSource.getClientId()});
popup.cancel();
}
</af:resource>


Then, we add the link using a af:commandLink, to call the JS function when the user clicks the link we add a af:clientListener referencing the JS function and a af:clientAttribute to pass on the v_popup variable with the is of the popup.


<af:commandLink text="Send Email Sample" id="cl3" >
<af:clientListener method="showMailerPopup" type="action" />
<af:clientAttribute name="v_popup" value="mailer1"/>
</af:commandLink>

Then, right after the af:commandLink we add the popup with the id as per the af:clientAttribute in the af:commandLink, the only think in the popup is an af:inlineFramewith the src attribute set to the mailto link


<af:popup id="mailer1" clientComponent="true">
Opening Outlook...
<af:inlineFrame id="if1" inlineStyle="width:2px; height:2px;" visible="false" shortDesc="mailer" source="#{mailto:joe.smith@myemail.com}" clientComponent="true"/>
</af:popup>

1 comment:

badri said...

Hi
I tried to implement this.
but issue is outlook mails are opening twice.

Please suggest how to resolve this issue?

Many thanks
-J