Creating custom preload notices

If none of the other preload notice button types meet your needs, you can use the <mwp:buttonTemplate> tag to help generate up to five custom buttons.

You can add your custom content within the body of the <mwp:buttonTemplate> tag. The tag also provides a way to enable or disable the Do not show again check box. Pass in the value from the mwpDisplayDoNotPrompt request parameter so that the administrator can toggle this feature from the preload notice portlet.

To include this tag, add the following line to the beginning of your JSP fragment:

<%@ taglib uri="/WEB-INF/tld/MWPXdimeTags.tld" prefix="mwp" %>

This includes the MWP tag library with the mwp prefix, which enables you to specify the <mwp:buttonTemplate> tag. The tag takes the following parameters:

Attribute Use Description
labeln optional String label for button number n, where n is 1, 2, 3, 4, or 5. The label is optional if a bundle and key is defined for the button.
bundlen optional Resource bundle location for button number n, where n is 1, 2, 3, 4, or 5.
keyn optional Resource key to lookup translated button name from the bundle for button number n, where n is 1, 2, 3, 4, or 5.
urln optional URL used when user clicks button n, where n is 1, 2, 3, 4, or 5.
displayDoNotPrompt optional Boolean true or false, indicating whether the Do not show again check box is enabled or disabled.
The following example uses the <mwp:buttonTemplate> tag to create two buttons:
<mwp:buttonTemplate
      label1="Hello!"
      url1="http://some/url/hello/"
     
      label2="Goodbye!"
      url2="http://some/url/goodbye/">

      Hello World!

</mwp:buttonTemplate>  

You create the JSP fragment similar to how you create them for the predefined preload notice types by placing your content between <canvas> and </canvas> tags.

To allow timeout redirects, add the following lines to your JSP:
<%
    //Get defined parameters for use by this preload notice
    String mwpTargetURL = (String)request.getAttribute("mwpTargetURL");
    String mwpTimeOut = (String)request.getAttribute("mwpTimeOut");

    // Add the timeout if we have one
    if(mwpTimeOut != null){
        int timeout = Integer.parseInt(mwpTimeOut);
        if (0 < timeout) {
            String timeOutURL = com.ibm.wps.engine.commands.MWPRedirect.computeRedirectURL(mwpTargetURL, runData);
%>
            <meta http-equiv="refresh" content="<%= mwpTimeOut %>; URL=<%= timeOutURL %>"/>
<%
        }
    }
%>

In this sample, the application fetches mwpTimeOut and mwpTargetURL from the request attributes. You may choose a different timeout URL from the one configured in mwpTargetURL. If the target URL is a relative path, you must use the MWPRedirect.computeRedirectURL(URL url, RunData rundata) method to compute the fully qualified URL. Otherwise, you can simply specify the fully qualified URL in the timeOutURL variable.

The following is an example of a custom preload notice:
wp_profile_root/installedApps/node_name/MPATheme.ear/MPATheme.war/preload/sample_custom/xdime/default.jsp

Because preload notice fragment JSPs are included in the MPATheme EAR, you must update and redeploy the EAR if you add or modify a preload notice JSP. See the topic Deploying updates to the MPATheme EAR in this information center.




Terms of use
(C) Copyright IBM Corporation 2012. All Rights Reserved.