Charting Portlet using JSR-286
A while ago I had written an SDN article on how to generate charts dynamically in portlets. Following up on that, I have created a portlet that uses the JSR-286 feature of serve resources, to dynamically generate charts by reading its data from a JDBC compliant database. The essential feature of this portlet is that the image is generated dynamically and served via a serve resource call and isn't stored in any temporary location. The portlet can be run under any portlet container that supports JSR-286 specification. It has been tested on OpenPortal Portlet Container which supports the draft 19 of the JSR_286 specification. You can download the portlet war file from here.
Posted by insidemyhead [Personal] ( January 02, 2008 08:28 PM ) Permalink | Comments[6]
JSR-286 compliant ajax enabled Atom and RSS news reader Portlet
A colleague of mine, Satya a few days ago talked about JSR-286 and resource serving. He was describing what it is, and how it is a part of the JSR-286 spec. Satya incidentally was one of the key folks in implementing the same for the Open Source Portlet Container. He pointed me also to a nice article by Deepak Gothe and himself about the new JSR-286 specific features in the portlet container.
After going through the article I was waiting to get started with the JSR-286 implementation of the portlet container and resource serving in particular. So I have implemented a "RSS and Atom feed reader" portlet using the Open Source Portlet Container. The portlet is AJAX enabled as well. To see a small screencast of it in action click here.
This is how it looks (click to enlarge and see in a new window):
If you want to use this portlet, or try it out, you will need a portlet container which supports the JSR-286 spec, and resource serving in special. As mentioned earlier the Open Source Portlet Container is one of the best. You can get it from the web site as mentioned in the link, or get is as part of the JavaEE Tools Bundle (Choose to "Download with Tools"). If there is interest in this portlet, let me know and I can make it available.
Read where you can get this portlet source code from on my personal blog@blogspot.
Posted by insidemyhead [Sun] ( October 17, 2007 12:34 AM ) Permalink | Comments[0]
Presence - Dial tone of this century ...
How many times you have wanted to make an important business or a personal call, and picked up the phone to call the other party, but the call ended unsuccessfully, since all you managed to reach was the other party's voice mail? Such unsuccessful calls can be a serious drag on productivity and not to mention the frustration it causes, since instead of talking to each other the parties get to talk to the infamous 'voice mail'.
Or maybe the person you thought was in office actually was on the customer site today and was not reachable on his office number you just dialed. Well this brings in the concept of 'presence' which is so prevalent in the IM world. You begin to chat with a party only when his icon in the chat indicates that he is 'present'.
Now wouldn't that be really nice if we can apply this concept to telephone dialing as well. And why just telephones, we should be able to extend the concept of presence far beyond that.
A user, may opt for several ways in which he can be reached, phone, IM, SMS, Email etc. All of these are different modes of reaching the person. Now, imagine that this same person, can specify or update a unique "address" or a "URI" for each of the means to reach him. Then under his buddy icon, in a client application ( a universal communicator client), on right clicking his name, there appear several of these options to interact with him.
Clicking on the URI corresponding to a phone, will place a IP telephony based call, clicking the URI for email, could launch an application capable of sending an email. As long as the person has kept his information updated on the "Presence" server, the other parties are always able to get in touch with the person, based on his preferences of course.
Thus it would be appropriate to call "Presence" as the dial tone of this century. SIP ( Session Initiation Protocol ) seems to be right way to achieve this kind of communications.
From the portal perspective, the concept of "Presence" makes an absolute sense, since portal is a great way of achieving collaboration and bringing people together. Using a SIP server and a proxy, it seems that getting this above mentioned concept of "presence" into a portal has great potential value. Watch this space for more information on this topic.
Posted by insidemyhead [Sun] ( October 08, 2007 10:31 AM ) Permalink | Comments[0]
Flex or Ajax .. well both!
The release of Flash Player 9 included a new External API using a class file called the ExternalInterface that allows for the communication between JavaScript and Flash applications. To create the communication link and pass data between JavaScript and Flex, the developer had to create custom code to handle each call.
The newly introduced Flex-Ajax Bridge has simplified the usage of this API. By simply including the necessary classes, the bridge exposes all of the classes within the Flex application to JavaScript. You can almost create anything in your Flex application using JavaScript instead of ActionScript.
So if you are a JavaScript pro and want to try out Flex this is a good time to do so!
Posted by insidemyhead [Personal] ( August 07, 2007 08:57 AM ) Permalink | Comments[0]
Update: Flex up your portlets
A while ago I had talked about Rich Internet Applications on my blog and talked in detail about Flex. You can read that entry here. I had promised to put a tutorial/entry on how to create a portlet out of your Flex application, but I
didn't get time to post the entry.
Recently, I helped my colleague Murali on getting his Flex app converted to a portlet and he has been prompt enough to post the instructions on his blog here. Thanks Murali.
Posted by insidemyhead [Personal] ( August 03, 2007 12:27 PM ) Permalink | Comments[0]
A Solution: Maths Fun Again.. Again
So the solution to my previous entry and the one prior to that was provided by a few folks as (root 2), which is actually quite trivial in my opinion. The actual question that has been bothering me was what i posted in the comments to whatever few replies i got:
That is , what actually is
. If the answer to both questions (blog entries) is
, then how come
is 2 as per my first blog entry and equal to 4 as per the second entry. This is the one I was actually looking for an answer to. I have kind of an idea what it could be, I will put my explanation here, and hopefully it makes some sense.
is actually limit of the sequence
,
,
...
It is trivial to prove that the above sequence is increasing and is upper bounded by 2.
Coming back to the original question (the previous two blog entries marked above) which can be rewritten as
.
I tried to plot the graph of this function and it comes out as follows:

This proves that given a value of x, there are two values for y. And for x =
, we know these values are 2 and 4. But we just indicated above that the sequence
is upper bounded by 2. So the value 4 can't be possible for
.
Hope it makes some sense.
Posted by insidemyhead [Personal] ( August 01, 2007 09:22 PM ) Permalink | Comments[1]
Maths Fun Again .. Again
Some of the folks answered this in the comments to my previous entry as the answer to x being equal to
. However if that is true then what is the value of x in the following equation?
Getting interesting now I guess :-)
Posted by insidemyhead [Personal] ( July 27, 2007 09:17 PM ) Permalink | Comments[6]
How about a Semantic Community Portal?
Community can be defined as a group of users having common interests. As organizations become highly dynamic and the people that join them become more geographically dispersed, the need for improved ways to share and distribute data and information amongst the community or organization members has increased dramatically.
Speaking in terms of the Semantic Web, these community members share similar ontology items since in most probability their cultural backgrounds, work activities etc might be similar. "Semantic community portals" can make use of Semantic Web technology and shared community terms to create connections between people and people, and also between people and the information that they produce.
So how exactly would you define semantic community portal?
Orkut and LinkedIn are examples of community web portals where the people and their relationships were clearly defined using online social networking. However there is a strong connection between these social networking services and semantic community portals. For example consider Orkut or Linkedn using the FOAF ( Friend of a Friend ) ontology to describe its members profile and their relationships. This will bring these now separate social networking sites to inter operate with each other. This will help in bringing the people together in a 'universal social network'. For this to become a reality more and more of these social networking sites need to start using the FOAF and other related ontologies, in an attempt to make the data within them distributed and decentralized.
The onltologies that are typically most commonly used by the community web portals are the ones used to define people (vCard, FOAF) and documents ( RSS). However staying within these ontologies is far too limited for the currently evolving semantic web.
SIOC is an initiative that seems to be a step in the right direction from the semantic community portal perspective. Basically the SIOC tries to capture as much information as possible about the community web sites and the information that is contained within them. Have a look at the two figures below taken directly from the SIOC web site which clearly demonstrate the future of the semantic community portal.
SIOC has the ability to link all sorts of entries like Blogs, Forums, Mailing Lists from and amongst various community sites. Using SIOC we will have the ability to make the information contained within links in HTML documents, discussions in forums, trackbacks, replies, followups etc available explicitly for machine-processing. (That is the goal of the semantic web )
However, a full-fledged framework for community-driven ontology management should go beyond simple tagging and should enable merging of community portals with established practices for ontology management. The objective of community-driven ontology management is to provide means for a large number of users to build and adopt the Semantic Web, via practices for ontology management all in the community space. Such a portal will allow end users to define the structure of the content (i.e., develop ontologies), populate ontologies and define the ways in which this content is managed on Semantic Web community portals.
Reference: Berners-Lee, T., Hendler, J., & Lassila, O. (2001). The Semantic Web : Scientific American
Posted by insidemyhead [Sun] ( July 23, 2007 10:51 PM ) Permalink | Comments[0]
Maths Fun Again
Given that :

What is the value of x?
Posted by insidemyhead [Personal] ( July 20, 2007 08:17 PM ) Permalink | Comments[2]
Locker Mania - Answer
Although there were solutions to this provided by Murali and Eric in the comments section and they are correct. Just posting it here for more general viewing. BTW, I went through the C program written by Eric, it was really nicely written program with neat output as well. Really nice!
Anyway back to the answer.
The state of any locker N will remain unchanged from the beginining as long as N = P * Q, and P and Q happen to be distinct (There can be multiple combinations of P and Q). That means, given the 10th locker, its state will be toggled by the 1st and the 10th member. Its state will again be toggled by the 2nd member and then again by the 5th member, thus its state remaining unchanged. This is since the factors of 10 are (1,10) and (2,5)
For locker number N where N =P*Q, and P and Q are same, i.e locker numbers which are perfect squares, there will only be one state change and hence are the ones which will remain open in the end.
Example, locker number 9. Its state will be changed by (1,9) member and again by the (3,3). But since the 3rd member can only toggle once, we can see that the state if the 9th locker will be open ultimately. Same for all perfect squared numbered locker till 100.
Posted by insidemyhead [Personal] ( July 20, 2007 12:50 PM ) Permalink | Comments[0]
Locker Mania
There is a locker room in the club and they are numbered from 1 to 100. There are 100 members of the club who will enter the locker room in the following sequence. When the first member enters, he opens all the lockers. When the second member enters the locker room, he closes all even numbered lockers. When the next member enters the room, he toggles the state of every locker which is a multiple of 3.
This process continues till all the 100 members have been through the locker room. At the end of this process, which are the lockers that are open?
Posted by insidemyhead [Personal] ( July 17, 2007 07:40 PM ) Permalink | Comments[4]
Secure Remote Access (SRA) in 7.1
Sun Java Systems Enterprise Secure Remote Access version 7.x
The 7.0 release of Portal Server saw the introduction of the JMX Administration. All administrative interfaces in portal now used mbeans to manage the various servers and configuration. A single command line interface was provided for all the administrative activities ( viz. psadmin). The Portal Admin Server (PAS) is the admin server that holds all the configuration of the various mbeans known to the JMX Server. The PAS held its configuration/bootstrap information in LDAP.
Gateway, the main workhorse of Secure Remote Access (SRA) component of Sun's JES stack, resides in the DMZ ( De Militrized Zone) and hence doesnt or rather shouldn't have direct access to LDAP which is inside the corporate firewall. So as a workaround in 7.0 there was a requirement of installation of a local directory server on the Gateway host. This directory server was not required by the Gateway process per se, but was required to bootstrap the administrative interface of Portal Server (PAS). This local directory server contained only the bootstrap information to startup PAS and nothing else. Once the GW is started up using psadmin, this local directory server on the gateway node could very well be shut off and that wouldn't affect the gateway at all. This (installation of a local directory) however was a major restriction and was a big no no.
So in 7.1, release this restriction was done away with. The PAS module on the local gateway box uses a file based JNDI mechanism to load its configuration information and hence no need for a local LDAP on the gateway box. So far so good.
However it recently came to my attention that there was a bug in which it was reported that the LDAP port between GW and the Portal Server was required to be opened. I have traced the issue down and have done the fix for that. It should be checked in by EOD tomorrow. Once this fix is done in the code
base and the product patched with the fix, the flow of traffic from an administrative perspective should follow exactly the diagram below.
So in 7.1 the scenario, as far as the GW, Portal nodes and the firewall is concerned looks pretty much like this. Note this figure is only for as far as the administration of GW is concerned. What I mean by that is, executing of any SRA related psadmin commands on the gateway node. Once the step 8 is completed in the figure below, the gateway starts up and starts serving pages from the portal ( ofcourse the HTTP/HTTPS port for the portal server needs to be opened in the firewall as well, but like I mentioned the figure essentially talks about the admin interface only.)

Posted by insidemyhead [Personal] ( July 11, 2007 10:59 PM ) Permalink | Comments[0]
New Version of Eclipse Portal Pack with Action Support
I have uploaded the source code for the new version of Eclipse-Portalpack. I have been playing with the idea of making portlet development easy... and not just for rendering the view mode or the edit mode of the portlet but also in processing actions easily from the portlets. To this extent this is my first attempt in making this happen. Check it out and let me know if you find it useful and suggest any enhancements requests if any. I will be enhancing this further myself ( as there are areas I think that need it, but do let me know your suggestions )
Okay back to the new version. The new version supports the following new things :
- It is now built on the latest version of JAXB .i.e version 2.1.
- It has a new feature of adding a new portlet action very easily to your portlet, and to implement the action you just need to implement one method "execute()" in your action class and almost no code change to your portlet class is needed. You just specify what page to go to once the action is processed and the portlet has the code to automatically send you to the new page once the action is executed sucessfully. In case of an error that happens in your action's "execute()" method, the portlet will redirect you to the error page that gets created automatically for you when the portlet project was initially created.
Enhancements to this :
There are a couple of enhancements that I am still working on. If you think you can contribute to any of these please join in and contribute.
- There are enhancements to the GUI for action creation needs some work.
Suppose I want to develop a simple portlet which shows a form to collect some inputs from the user. The form might ask the user for his first name, last name and the email address. When the user submits this form, the data is collected at the server, and persisted to a data store. Once the data is persisted the user is shown a thank you page. Now assume the above needs to be done in a portlet. The scenario described above can be done using a portlet as shown below in the picture:

When developing this portlet the developer needs to write code in his processAction() method to do the following :
- Recognise the type of action this request is. In our case there is only one action so this case is simple.
- Collect the data from the form and populate a bean with that data.
- Put the bean in session data to be accessed in doView() mode.
- Now when the portlet container calls the doView() method, access the bean stored in session in previous step and do the actual action
- Dispatch the request to the destination JSP page.
All the above needs to be done by the developer whenever he writes a particular action. ( This is one way of doing this )
I wanted to make this a little easier to do, so I have added new code to the Eclipse Portal Pack project to make this easier. This is a very early version of it, so please bear with it, as I make further improvements. But feel free to try it out and give suggestions, or better still join on the project and contribute.
Developing the above portlet with the Eclipse Portal Pack Project
A screencast of creating a simple portlet project and a sample portlet is shown here.
Now that we have a sample portlet ready. Let's go about adding this new action that we wanted. Let's first create the JSP page that will show the form to the user in the view mode. By default the project would have created a JSP for the view mode called view.jsp in your /WEB-INF/jsps/ folder. Open this JSP file and add the following code to it.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="UTF-8"%>
<%@page import="javax.portlet.*" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<portlet:defineObjects/>
<portlet:actionURL var="portletUrl" />
<form id="form1" name="form1" method="post" action="<%=portletUrl.toString()%>">
First Name : <input type="text" name="fname" type="text"><br/>
Last Name : <input type="text" name="lname" type="text"><br/>
Email : <input type="text" name="email" type="text"><br/>
<input type="submit" name="Submit">
</form>
The lines in bold indicate the form that will be displayed to the user in the view mode. It presents the user with fields to accept his first name, last name and email address and then there is the submit button which submits the form to the portlet via the portlet:actionURL variable defined above.
Now this is where the new Eclipse Plugin can help you in making your life easier. Let's call the action to collect the user data and put it to datastore as "CollectData". Right click on the portlet project in Eclipse, and down at the bottom you will see a menu entry called "Portlets->Create new Portlet Action" as shown below in the picture.

So here is what we want to do, we want to define a new action called CollectData, which we want implemented by a class of our choice, in this case lets say com.sun.portal.test.actions.CollectDataAction, and when our action is complete we want the portlet to take us to the page defined in /WEB-INF/jsps/done.jsp. So fill up the dialog box as shown below and click Ok. ( Like I said this is the first version so I haven't added any error checking as of yet, it will be coming pretty soon though ).

On clicking Ok, you will see a new action class called CollectDataAction created under the package com.sun.portal.test.actions. Open this class in Eclipse and it will appear as below:
package com.sun.portal.test.actions;
import javax.portlet.ActionRequest;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import com.sun.portlet.core.actions.ActionExecuteException;
import com.sun.portlet.core.actions.BaseActionFormBean;
public class CollectDataAction extends BaseActionFormBean { public CollectDataAction(ActionRequest request) {
super(request);
}@Override
public boolean execute(RenderRequest portletRequest,
RenderResponse portletResponse) throws ActionExecuteException {
// Put your logic of executing the action for this request here.
return true;
}
So as you can see, all you need to do is implement the method "execute()" in your CollectDataAction.java class. In the execute() method, you can access the form parameters that your view.jsp sent in as getParameter(String), getParameterNames() and getParameterValues(String) as usual.
Also to invoke this action the only other thing you will need to do is, add a hidden field in your view.jsp form called ACTION_NAME, and its value must exactly be the action you want executed when the form is submitted, which in our case is "CollectData". So our view.jsp page in completion will look as below :
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="UTF-8"%>
<%@page import="javax.portlet.*" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<portlet:defineObjects/>
<portlet:actionURL var="portletUrl" />
<form id="form1" name="form1" method="post" action="<%=portletUrl.toString()%>">
First Name : <input type="text" name="fname" type="text"><br/>
Last Name : <input type="text" name="lname" type="text"><br/>
Email : <input type="text" name="email" type="text"><br/>
<input type="hidden" name="ACTION_NAME" value="CollectData">
<input type="submit" name="Submit">
</form>
The only changed line is shown in Bold and Italic.
That's all that is needed to implement this action from your side. Ofcourse, you need to write the done.jsp file to which the portlet will dispatch the view after the action is executed.
To summarise, to implement any new action, all you need to do in addition to writing the source JSP and the target JSP is :
- A hidden variable called ACTION_NAME in the source JSP page form.
- Implement the execute() method in your Action Bean.
Rest of the stuff is handled for you!!
Let me know if you like it, by posting your comments.
Posted by insidemyhead [Sun] ( July 03, 2007 04:03 PM ) Permalink | Comments[43]
Possible answer to the 123 black hole
Here is a explanation of the mathemagical black hole (123) in my opinion. If we consider the transformation on x as a function f(x), such that f(x) = E(x) O(x) T(x)
where E(x) = Number of even digits in x, O(x) = Number of odd digits in x and T(x) = Number of digits in x
Then for all x,
f(x) < x
So eventually as we recurse this process, at some point f(x) will fall below 1000. In that case the only possibilities for E(x) O(x) and T(x) are
1 2 3
2 1 3
3 0 3
Each of the above in the next iteration will give 123. Hence the proof.
Posted by insidemyhead [Personal] ( July 03, 2007 02:39 PM ) Permalink | Comments[0]
Another Mathemagical Black Hole
Read about another mathemagical black hole.. Really interesting one.
Take any natural number, treat it as a string. For example: 24,89,62,698.
- Count the number of even digits. In this case 7 even digits.
- Count the number of odd digits. In this case 2
- Count the total number of digits. In this case 9
So the new number now is 729. Repeat the above process. Even digits (1), odd digits (2), total digits (3). So the new number is 123. And now any more iterations will return 123 only. So in this case 123 is the mathemagical black hole.
All numbers in this universe are drawn to the number 123 by this process. Never to escape. Try it out.
Posted by insidemyhead [Personal] ( July 02, 2007 07:49 PM ) Permalink | Comments[0]


