Tuesday, 27 April 2010

Using WebSphere Portal from mobile devices

 I've just spent a few hours testing this, following a question from a customer, who had a requirement to show/hide portal resources e.g. pages, portlets etc. when accessing WebSphere Portal via a RIM BlackBerry device.

I was able to create a Personalization Visibility Rule that will hide a portlet based upon the browser's User-Agent parameter. The rule is: -

Hide page or portlet when
current Browser Capability.Agent includes blackberry
Otherwise show

I had previously written a portlet, using WebSphere Portlet Factory Designer, that captures this User-Agent string, using the following JSP: -

<html>
<body>

<%
out.println("User agent is " + request.getHeader("User-Agent"));
%>

</body>
<html>

which, for my BlackBerry Curve 8310, returned: -

BlackBerry8310/4.5.0.180 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/120

The final trick is to realise that the Visibility Rule is case-sensitive - in other words, the test needs to be for "blackberry" rather than "BlackBerry". Similarly, for Mozilla Firefox, which returns a User-Agent string of: -

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729) 

the test needs to be for "mozilla" rather than "Mozilla".

Once I'd gone through the above, I was able to browse to my portal instance using the native BlackBerry browser on a 8310 Curve, and see that the rule was working e.g. that the portlet to which I had applied the rule was HIDDEN for the BB, whereas it was visible on other devices.

The trick re case sensitivity came from a friend, Mike Spradbery, who had previously blogged about using a similar Visbility Rule with the Apple iPhone - in his example, he'd used a rule: -

Hide page or portlet when
current Browser Capability.Agent includes iphone
Otherwise show

Note the use of the case - iphone - rather than iPhone.

Comments: Post a Comment





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]