How to write Alphablox JSR168 Portlet in WebSphere Environment

Alphablox is used to present consolidated information and analytical capabilities in rich diagrams and reports. Here I am going to show you how to write a simple Alphalox JSR168 Portlet by presenting an example.

Working Environment

·        Developement Tool: RAD 6.0.1.1 + Interim Fix 003 // Alphablox Toolkit  is not supported in RAD7.0 currently

·        WebSphere Application Server v 6.0.2.11

·        WebSphere Portal Server v5.1.0.3

·        Alphablox V8.4.0 is installed on top of WPS V5.1.0.3

Alphalbox Portlet (JSR168) Sample

This sample uses the default data source which is automatically installed with Alphablox.

Lines marked with red are important points of writting an JSR168 Alphalbox Portlet.

<%@ page contentType="text/html" import="java.util.*, java.io.*"%>

<%@ taglib uri="bloxtld" prefix="blox"%>

<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>  //This line indicates we are using JSR168 API specification

<portlet:defineObjects/>

<%
 String bloxName = renderResponse.getNamespace() + "chartBlox0";

%>

<head>

  <blox:header />

</head>

<blox:chart id="chartBlox" bloxName="<%= bloxName %>">

  <blox:data dataSourceName="Canned" />

</blox:chart>

Some Words about Alphablox and its Portlet

You may see a lot of Alphablox advantages on internet but not its shortcoming, here, based on my limited experience, I list some inconvenience of using it and hope they will be noticed and enhanced in the future.

1. Alphalbox support standard J2EE model, but it is not compatible with SOA architecture.

As I experienced, Alphablox does not provide any interfaces to support SOA, which means, it is impossible in Alphablox to invoke service which returns data sets in XML format.

There are two ways to access datasource in Alphablox (please refer to my next blog: Tow different ways of accessing Datasource in Alphablox for more information)
a). work directly with sql statement
b). work with java.sql.ResultSet

2. It is impossible for an Alphablox Portlet to be a source portlet

For instance, this is a report alphalbox portlet. You want to get the detail information in a target portlet of a product that you selected in source, however, this scenario can not be realized.

However, it is possible for a Alphablox Portlet to be a target portlet. In this case, there is one thing you need to pay attention. Normally, you want the target Alphablox Portlet will change itself according to the different selection on the source portlet, if so, in the above blox code, the bloxName attribute should be different each time so that Alphablox Server knows this is a new one, otherwise, the blox will remain unchanged. To achieve this, one possible way is to use random value.

Random r = new Random();
   int i = r.nextInt();   
   if (i<0)
       i=i*(-1); // it will cause problem when the blox name contains "-".

String bloxName = renderResponse.getNamespace() + "standingRankingSeasonBox_"+i;

3. Unfriendly JSP Page

As we have seen on the above sample code, all Alphablox code should be written on the jsp, sometimes even the business logic which increased the complication of jsp page.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值