You can create device-specific content by retrieving device policy values.
Portlets may require information about device policies to render content dependent on device capabilities. To access this information, there are APIs that you may use, in either the portlet Java™ class, or portlet JSP, as illustrated in the examples that follow.
public void doView(PortletRequest request, PortletResponse response)
throws PortletException, IOException
{
try{
com.ibm.mwp.util.mcs.MCSUtil.getMarinerServletApplication();
com.volantis.mcs.devices.Device device = mcs.getDevice(request);
String deviceName = device.getName();
String mfg = device.getPolicyValue("mfg");
System.out.println("device.getName() = "+deviceName);
System.out.println("device.getPolicyValue(\"mfg\") = "+mfg);
}catch(Exception ex){
ex.printStackTrace();
}
}
<%@ taglib uri="/WEB-INF/tld/portlet.tld" prefix="portletAPI" %>
<portletAPI:init/>
<%
try{
com.ibm.mwp.util.mcs.MCSUtil.getMarinerServletApplication();
com.volantis.mcs.devices.Device device = mcs.getDevice(portletRequest);
String deviceName = device.getName();
String mfg = device.getPolicyValue("mfg");
%>
Device name: <%=deviceName%>
Manufacturer: <%=mfg%>
<%
}catch(Exception ex){
ex.printStackTrace();
}
%>
The getPolicyValue() method takes a
device policy attribute name as input and returns a string. To get
the list of device policy names, use the Mobile Portal Toolkit Device
Policy Browser. The policy names that can be used with the getPolicyValue() method
are in the shortname column displayed by the device policy browser.