ShowTable of Contents
Introduction
IBM® Mobile Portal Accelerator (MPA) is a free-of-charge extension to IBM WebSphere® Portal that provides an easy, cost-effective way to deliver content and applications to virtually all mobile devices. Its intelligent Multi-channel Server adapts the content for each mobile device based on the specific device characteristics and capabilities, as defined in the software's device repository.
Figure 1 illustrates the basic high-level architecture for MPA.
Figure 1. MPA architecture
MPA provides device-specific markup capability and, to display content on a range of devices, you must specify a layout policy with variants that are suited to different device characteristics, after which you associate the variants with one or more devices.
This mapping to a set of mobile devices is done either by:
- Choosing individual model numbers for a particular layout, or
- Assigning the layout to a family of devices, for example, Tablet or SmartBook, or by the manufacturer (Apple, BlackBerry, etc.)
These approaches are not always sufficient, however, especially for scenarios in which the implementation does not require a device-based, layout-mapping approach. These scenarios can be time consuming and may require significant effort to map layouts to devices---especially if there is quite a wide range of mobile devices to tackle.
This article describes a solution to tackle such scenarios by explaining how to build a device-attribute-based mobile site that is based on one or more attributes of the requesting device that are already present in the MPA device repository, thereby providing a programmatic approach to device grouping.
An example of such a scenario could be the width of the requesting mobile device. We'll discuss the details of how a different UI for the mobile site can be shown, depending on the width of the requesting device. A similar approach can be applied to other device attributes, such as page size / resolution, etc., that are present in Volantis' Multi-Channel Server (MCS) database.
Prerequisites
You'll need the following software to complete the steps in this article:
- IBM Rational® Application Developer 8
- IBM WebSphere Portal Server 7 with MPA 7
- IBM Mobile Portal Toolkit 7 (as a part of IBM MPA license)
- Device Emulators
To get the most from this article, you should have an understanding of WebSphere Portal Server, Rational Software Development Platform, Mobile Portal Accelerator, Java
TMServer Pages (JSPs), xHTML Device Independent Markup Extensions (Xdime), portal aggregator, and MCS policy development.
Setting up the development environment
Let's begin by setting up the development environment.
Create the XDIME aggregator project
1. In Rational Application Developer (RAD), create a General project as shown figure 2; click Next.
Figure 2. Create a General project
2. Specify MyXdimeAggregator as the Project name and click Finish (see figure 3).
Figure 3. New Project window
3. Copy the contents of MPA Theme application from
wp_profile_rootinstalledApps/
node_name/MPATheme.ear/MPATheme.war into the project created above (see figure 4). For more information about making changes to MPA theme, refer to the
IBM Mobile Portal Accelerator 7.0 information center.
Figure 4. MyXdimeAggregator

Create an MCS Policies project
To do this:
- In RAD, create a General project as we did above, specify MyMCSPolicies as the Project name, and click Finish.
- Export the aggregator policies from MCS database and copy the policy files to the above-created project (see figure 5). For more information about exporting and importing policies, refer to MPA InfoCenter topic, “Importing and exporting repositories.”
NOTE: If, instead of an actual database, an XML-based repository is being used, then the policy files can be copied from there.
Figure 5. MyMCSPolicies

Customize MCSPolicies
To do this:
- Switch to the MCS Navigator perspective in RAD and associate an .mdpr mcs repository file to the project, which comes with the product.
- In MyMCSPolicies project, open the wp_header.mlyt file and choose the Design view; the Layout design contains two panes, G and H, as shown in figure 6.
Figure 6. Layout Design window
3. Add another row after the row containing pane G by right-clicking pane G and selecting Grid --- Insert Row (see figure 7).
Figure 7. Add another row
4. In the Insert row window (see figure 8), enter a “1” for the Number input, to insert just one row, and enter “After” as the position to place it after the row containing G Pane; click OK.
Figure 8. Insert row window
This adds another row to the layout as shown in figure 9.
Figure 9. Another row added
5. Right-click on the newly inserted row and add two columns to it, using Add –- Grid --- 2 Columns, as shown in figure 10.
Figure 10. Add two columns
6. Right -click on Column 1, select Add --- Pane --- Pane (see figure 11), and name it “HeaderImage” in the Format Attributes section (see figure 12).
Figure 11. Add Pane
Figure 12. Formal Attributes section
7. In the same way, add a pane to Column 2, and name it “HeaderSearch”. The Layout Design will now look similar to that shown in figure 13.
Figure 13. HeaderSearch pane added to Column 2
8. Replace the original wp_header.mlyt file with the modified version and, if you are using a database for MCS repository, import the policies into the MCS database. If you're using an XML-repository instead, then replace the file directly. Note that a restart of WebSphere Portal server may be required.
Customizing the XdimeAggregator JSPs
To do this:
1. Enable the JSP reloading so that the changes to the XDIME aggregator JSP’s are reflected immediately and a server restart is not required. Refer to the WebSphere Portal InfoCenter topic, “
JavaServer Pages (JSP) runtime reloading settings,” for more information.
We conditionally render either pane “G” or panes “HeaderImage” and “HeaderSearch,” depending on the width of the requesting device.
We use the MCS expressions to determine the value of the device width attribute from the MCS repository, and then use it to conditionally render a pane, depending on the value of the width attribute of the device.
2. Modify the Header.jsp file under the themes/xdime/mpatheme/common folder and find the following section:
<img pane="G" src="<mwp:vpMapper name='/wp/logo.mimg'/>" alt="WebSphere Portal" />
replacing it with the following:
<img pane="G" expr="number(device:getPolicyValue('fullpixelsx'))<=250" src="<mwp:vpMapper name='/wp/logo.mimg'/>" alt="WebSphere Portal" />
After this change, the pane “G” will be rendered only if the requesting device width is less than or equal to 250 pixels.
3. Insert the following at the end of the above image tag:
<img pane="HeaderImage" expr="number(device:getPolicyValue('fullpixelsx'))>250" src="<mwp:vpMapper name='/wp/logo.mimg'/>" alt="WebSphere Portal" />
<pane name="HeaderSearch" expr="number(device:getPolicyValue('fullpixelsx'))>250">
<p><a href="#">SendFeedback</a> <a href="#">ContactUs</a></p>
</pane>
After this change, the image in the “HeaderImage” pane and the links in the “HeaderSearch” pane will be displayed only if the requesting device width is greater than 250 pixels.
The contents of the Header.jsp will now look like that shown in listing 1.
Listing 1. Contents of Header.jsp
<%
if(Debug.DEBUG_AGGR && logger.isLogging(Logger.TRACE_HIGH)){
logger.entry(Logger.TRACE_HIGH, "/common/Header.jsp");
}
%>
<region name="header">
<canvas layoutName="<mwp:vpMapper name="/wp_header.mlyt" nlsSensitive="<%=getLocaleIsBidi(request)%>" />" type="portlet">
<pane name="H.0" class="wpsPlaceBar"><%=navHelper.getPageTitle()%>
</pane>
<img pane="G" expr="number(device:getPolicyValue('fullpixelsx'))<=250" src="<mwp:vpMapper name='/wp/logo.mimg'/>" alt="WebSphere Portal" />
<img pane="HeaderImage" expr="number(device:getPolicyValue('fullpixelsx'))>250" src="<mwp:vpMapper name='/wp/logo.mimg'/>" alt="WebSphere Portal" />
<pane name="HeaderSearch" expr="number(device:getPolicyValue('fullpixelsx'))>250">
<p><a href="#">SendFeedback</a> <a href="#">ContactUs</a></p>
</pane>
</canvas>
</region> <!-- "header" -->
<%
if(Debug.DEBUG_AGGR && logger.isLogging(Logger.TRACE_HIGH)){
logger.exit(Logger.TRACE_HIGH, "/common/Header.jsp");
}
%>
4. Now replace the Header.jsp file under
wp_profile_root/installedApps/node_name/MPATheme.ear/MPATheme.war/themes/ xdime/mpatheme/common
with the file modified above.
5. Finally, touch the Default.jsp’s under
wp_profile_root/installedApps/node_name/MPATheme.ear/MPATheme.war/themes /xdime/mpatheme/treeview
and
wp_profile_root/installedApps/node_name/MPATheme.ear/MPATheme.war/themes /xdime/mpatheme
for the changes to take effect.
Testing
To test the mobile site using device emulators, we select two such emulators, one of which has a device width attribute less than or equal to 250 pixels, and the other has a width attribute greater than 250 pixels.
The results from two such mobile emulators are shown in figures 14 and 15, showcasing different site variants depending on the width of the device. For the device that is less than 250 pixels wide, we show just the header image (see figure 14), whereas for the device that that is more than 250 pixels wide, we show header image together with two header links, Feedback and ContactUs (see figure 15).
Figure 14. Site for a less-than-250-pixels-wide device
Figure 15. Site for a greater-than-250-pixels-wide device
Conclusion
In this article you learned how a device-attribute-based mobile site can be built that is based on one or multiple attributes of the requesting device already present in the MPA device repository, thereby providing a programmatic approach to device grouping. Similar approaches can be applied for other available attributes in the MCS database.
Resources
IBM Mobile Portal Accelerator 7.0 Information Center:
http://publib.boulder.ibm.com/infocenter/mpadoc/v7r0m0/
IBM Mobile Portal Accelerator 6.1.x Information Center:
http://publib.boulder.ibm.com/infocenter/mpadoc/v6r1m0/index.jsp
IBM WebSphere Portal 7.0 product documentation:
http://www.ibm.com/developerworks/websphere/zones/portal/proddoc.html#v70proddocwiki
IBM Mobile Portal Accelerator product page:
http://www-01.ibm.com/software/lotus/portal/value/mobileaccelerator/
IBM Accelerators for WebSphere Portal product page:
http://www-01.ibm.com/software/lotus/portal/value/
About the author
Animesh Sharma is a WebSphere Portal Specialist with IBM India Software Labs, currently working for the Lab Services division. He specializes in WebSphere Portal, IBM Mobile Portal Accelerator, IBM Web Experience Factory, and IBM Web Content Manager, and participates in various customer-facing engagements. You can reach Animesh at
animshar@in.ibm.com.