Best Practices from Oracle Development's A‑Team

Customizing Session Time Out Pop Ups


In past posts, ATEAM has detailed how to customize the default behavior of the out-of-the-box (OOTB) session time out popups:



An item that has frequently been asked to ATEAM is how to customizing the default strings that are in the OOTB session time out popups. This blog post will detail the steps to create custom resource strings, which will override the default values.

Main Article

By default, the current session time out popups appear as follows:

timeout_resbundle_1 timeout_resbundle_2

The good news is that all of the text based resource strings (e.g. Expiration Warning, .etc) shown here are customizable.  The unfortunate news is that there is no where in the documentation that references how to modify them. These resource strings are actually contained in a bundle (RichBundle.java), which is declared in the skin (CSS).  So in order to override the defaults, a custom resource bundle must be created and then declared in a custom skin.

The custom skin declaration in the trindad-skins.xml should also declare to extend the default skin, so the other default resource strings can be picked up

For example, here is the example of the trinidad-skins.xml, which declares the custom resource bundle:

<?xml version="1.0" encoding="windows-1252" ?> <skins xmlns="http://myfaces.apache.org/trinidad/skin">   <skin>     <id>myskin.custom.desktop</id>     <family>myskindemo</family>     <render-kit-id>org.apache.myfaces.trinidad.desktop</render-kit-id>     <style-sheet-name>css/myskindemo.css</style-sheet-name>     <extends>fusionFx-v1.desktop</extends>     <bundle-name>com.ateam.view.MyBundleOverride</bundle-name>   </skin> </skins>

Once the skin is declared and selected in the trinidad-skins.xml, the last step is to create the resource bundle file that will hold the custom strings.  For this example, I have created a java based version for declaring the strings in the resource bundle. There are also other ways to declare the strings (e.g. .properties and .xliff).  Please refer to the documentation on how to create the different variations and on how to ensure support for both Internationalization and Localization. Now that the configuration is done to override the default bundle, the next step is to declare the strings themselves. OOTB the five default resource strings used, which are not declared in the documentation, are as follows:

af_document.PRE_SESSION_TIMEOUT_CONFIRM_TITLE = Expiration Warning af_document.PRE_SESSION_TIMEOUT_MSG = This page will expire unless a response is received within {0} minutes. Click OK to prevent expiration. af_document.PRE_SESSION_TIMEOUT_MSG_SECOND = This page will expire unless a response is received within {0} seconds. Click OK to prevent expiration. af_document.POST_SESSION_TIMEOUT_MSG = The page has expired af_document.POST_SESSION_TIMEOUT_MSG_CONTINUE = Click OK to continue. af_document.POST_SESSION_TIMEOUT_ALERT_TITLE = Page Expired

Here is an example of the MyBundleOverride.java, which contains the custom resource strings:

public class MyBundleOverride extends ListResourceBundle {     @Override     public Object[][] getContents() {         return _CONTENTS;     }     static private final Object[][] _CONTENTS =     {       { "af_document.PRE_SESSION_TIMEOUT_CONFIRM_TITLE",         "af_document.PRE_SESSION_TIMEOUT_CONFIRM_TITLE : Custom Expiry Warning" },       { "af_document.PRE_SESSION_TIMEOUT_MSG",         "PRE_SESSION_TIMEOUT_MSG : Custom: within {0} minutes. Click OK to prevent expiration." },       { "af_document.PRE_SESSION_TIMEOUT_MSG_SECOND",         "PRE_SESSION_TIMEOUT_MSG_SECOND : Custom: This page will expire unless a response is received within {0} seconds. Click OK to prevent expiration." },       { "af_document.POST_SESSION_TIMEOUT_MSG",         "POST_SESSION_TIMEOUT_MSG : This is a custom message from MyOverride Bundle" },       { "af_document.POST_SESSION_TIMEOUT_MSG_CONTINUE",         "POST_SESSION_TIMEOUT_MSG_CONTINUE : Custom continue Message" },       { "af_document.POST_SESSION_TIMEOUT_ALERT_TITLE",         "POST_SESSION_TIMEOUT_ALERT_TITLE : Custom Page Expired Title" }       }; }

This will produce the following results:


The browser cache may need to be cleared in order for the new strings to display correctly.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha

Recent Content