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.

3 comments:

Dave Hay said...

For what it's worth, the User_Agent strings for the three browsers that I tested are: -

BlackBerry 8310 Curve

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

Firefox 3.6.3 ( Windows XP SP3 )

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)

Internet Explorer 8.0 ( Windows XP SP3 )

User agent is Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

Unknown said...

Hey Dave... interesting stuff... perhaps could have achieved the same using specific markups within portal (ie create a new markup - bhtml? - which spots blackberries and then say which pages/portlets do or don't support this markup)... Might be a better option in some cases as PZN visibility rules fail when there is no authenticated user (apparently by design...). Keep up the good work, tom.

Dave Hay said...

Tom, thanks for your comments - much obliged. The PzN rules worked for the client's specific requirement - for an intranet portal - so authenticated access was perfect, regards, Dave

Reminder - installing podman and skopeo on Ubuntu 22.04

This follows on from: - Lest I forget - how to install pip on Ubuntu I had reason to install podman  and skopeo  on an Ubuntu box: - lsb_rel...