wc-devices.xml
The Madisons mobile starter store uses the wc-devices.xml file to identify mobile devices and route them to specific mobile optimized pages. The wc-devices.xml file contains a list of mobile devices that can be identified based on their name and user agent pattern.
- It searches for a pattern in the User-Agent HTTP header and maps it to a specific device internal ID.
- It looks up the JSP file template specific to the device internal ID.
- If you have not deployed the Madisons mobile starter store, or if you want to disable the auto-reload functionality, remove the wc-devices.xml entry from the WC_eardir/xml/config/com.ibm.commerce.foundation/.reloadfilelist file. If the .reloadfilelist file is empty, you can simply remove the file from the directory.
- A reload interval can be specified in the
.reloadfilelist file by adding the following property:
For example, if you use a property ofreloadinterval=numberOfSeconds
reloadinterval=300
in the .reloadfilelist file, the specified files are only reloaded 5 minutes after the last reload time. By default, this property is not specified in the file and when it is not specified, the reload interval is set to 3600, or 60 minutes. - You can force the loading of the mobile storefront from a non-mobile browser
by entering the following URL:
- http://host_name/webapp/wcs/stores/servlet/mStoreView?storeId=storeId
Pattern matching in the User-Agent HTTP header and mapping to a specific device internal ID
WebSphere Commerce provides a default mapping configuration file that maps a specific User-Agent pattern to a device ID. The pattern specified in this file uses the Java regular expression syntax specified in Sun's Class Pattern API documentation.
- WC_eardir/xml/config/com.ibm.commerce.foundation/wc-devices.xml
<_config:Devices
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-devices.xsd" xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config">
<_config:DeviceGroup internalID="-11" channelID="-6" >
<_config:Device name="BlackBerry Bold 9000" userAgentPattern="BlackBerry9000.*" />
<_config:Device name="BlackBerry Storm 9530" userAgentPattern="BlackBerry9500.*" />
<_config:Device name="BlackBerry Curve 8320" userAgentPattern="BlackBerry8320.*" />
<_config:Device name="HTC S740" userAgentPattern=".*MSIEMobile.*" />
<_config:Device name="Nokia S60" userAgentPattern=".*SymbianOS.*Series60/3.1.*Nokia3250.*" />
<_config:Device name="Nokia N97" userAgentPattern=".*SymbianOS.*Series60/5.0.*Nokia3250.*" />
</_config:DeviceGroup>
</_config:Devices>
<_config:Devices
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/foundation/config ../xsd/wc-devices.xsd" xmlns:_config="http://www.ibm.com/xmlns/prod/commerce/foundation/config">
<_config:DeviceGroup internalID="-31" channelID="-6" >
<_config:Device name="Apple iPad" userAgentPattern=".*iPad.*Safari.*" />
<_config:Device name="BlackBerry Playbook" userAgentPattern=".*PlayBook.*Safari.*" />
<_config:Device name="Android Tablets" userAgentPattern=".*Android.((?!Mobile).)*Safari.*" />
</_config:DeviceGroup>
<_config:DeviceGroup internalID="-21" channelID="-6" >
<_config:Device name="Apple iPhone" userAgentPattern=".*iPhone.*Mobile.*Safari.*" />
<_config:Device name="Android Handsets" userAgentPattern=".*Android.*Mobile.*Safari.*" />
</_config:DeviceGroup>
<_config:DeviceGroup internalID="-22" channelID="-6" >
<_config:Device name="Android Hybrid Smartphone Client" userAgentPattern=".*Android Smartphone Hybrid.*" />
</_config:DeviceGroup>
<_config:DeviceGroup internalID="-11" channelID="-6" >
<_config:Device name="BlackBerry Bold 9000" userAgentPattern="BlackBerry9000.*" />
<_config:Device name="BlackBerry Storm 9530" userAgentPattern="BlackBerry9500.*" />
<_config:Device name="BlackBerry Curve 8320" userAgentPattern="BlackBerry8320.*" />
<_config:Device name="HTC S740" userAgentPattern=".*MSIEMobile.*" />
<_config:Device name="Nokia S60" userAgentPattern=".*SymbianOS.*Series60/3.1.*Nokia3250.*" />
<_config:Device name="Nokia N97" userAgentPattern=".*SymbianOS.*Series60/5.0.*Nokia3250.*" />
</_config:DeviceGroup>
</_config:Devices>
- The storefront can differentiate between an iPhone shopper using its native browser, and an iPhone shopper using a mobile application.
- The storefront can differentiate between a shopper using a smart phone or tablet device, and if the device is using its native browser or a mobile application.
- config:DeviceGroup
- Defines a logical group of mobile devices with the same internal device ID and channel ID.
- config:Device
- Defines a mobile device. This mobile device configuration is used for mapping a User-Agent HTTP header to a specific device.
JSP file template lookup
The existing WebSphere Commerce Struts framework is used to load the JSP file template specific to the device internal ID.
BlackBerry9530/4.7.0.41 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/-1
WebSphere
Commerce searches the wc-devices.xml configuration file for a matching User-Agent
and finds the following
snippet:
<_config:Device name="BlackBerry Storm 9530" userAgentPattern="BlackBerry9530.*" />
WebSphere Commerce sets the defined deviceID (-11) and channelID (-6) in the session. This device ID is then used by the Struts presentation layer to render the specific JSP file template response to the user.
<_config:DeviceGroup internalID="-11" channelID="-6">
<_config:Device name="Google Android" userAgentPattern=".*Android.*" />
</_config:DeviceGroup>
The User-Agent header mappings are cached to maximize performance, where multiple requests with the same User-Agent header do use the same lookup multiple times.