Showing posts with label JSR 168. Show all posts
Showing posts with label JSR 168. Show all posts

Friday, September 4, 2009

JSR 168 missing Portlet Filters.

A portlet filter in Portlets is same as a servlet filter in Servlets. Hence a portlet filter is an object which intercepts or modify s the output to or from a portlet before it is aggregated to the portal page. I cant find anything in JSR 168 to achieve this feature but you can find vendor specific api's for it else you can use JSR 286 to work with it.

Thursday, September 3, 2009

Inter-Portlet Communication missing in JSR168 !!

Inter-portlet communication is the ability of one portlet to communicate with another portlet. This is one of the most important feature when we talk about portlets and portals. Looking to its importance many portal vendors have provided their own specific api's to achieve inter-portlet communication but this is something JSR 168 is missing and have to work on it before releasing next version. As per now to achieve inter-portlet communication in JSR 168 the developers are storing data in session at application scope level or storing it at portal level.
Developers are also using Ajax for acheiving inter-portel communication. In my last project I have used Ajax to achieve inter-portelt communication between the portlets.

Wednesday, September 2, 2009

Know what are the features missing in JSR 168......

JSR 168 missed or lacked some major features which made specification developers to think and add these features in newer version. Below are some of the important features which JSR 168 missed:

* inter-portlet communication
* portlet filters
* common support for proper web frameworks
* serving non-html resources (pdf, doc, images etc.)

Thursday, April 16, 2009

Cross page portlet communication in WebSphere Portal Server using URL Generation API

How can I make communication between two portlet without using wires when you want to paas parameters from one portlet to other and that shoud be used by second portlet.
Well this can be achieved using URL Generation API, just use the code below on your SourceJSP of SourcePortlet.In the code below, PAGE_UNIQUE_NAME would be page name on which you have target portlet and Portlet name would be your target portlet name.Params would be your parameters that you want to pass to target portlet.

String homeURL = PortletURLHelper.generateUrl(PAGE_UNIQUE_NAME, Portlet Name, HashMap params, renderRequest, renderResponse);

you can get param values in target portlet using the following code

Map map = renderRequest.getParameterMap();

now just iterate the map and find the values you passed from source portlet.

Saturday, April 4, 2009

Know How to Change a Portlet Title at "Run Time" in WebSphere Portal V6!

Well in my recent project i had a requirement to change portlet title at runtime . I followed the following approach suggested by IBM

http://www.ibm.com/developerworks/websphere/library/techarticles/0612_rick/0612_rick.html


After setting the title in RenderResponse.setTitle() method,
you need to have following code to calculate the dynamic portlet id :

public void getDynamicPortletID(RenderRequest request) throws Exception {
String portletId = "";
try {
HttpServletRequest httpRequest = (HttpServletRequest)request;
RunData rundata = RunData.from(httpRequest);
LayoutNode layoutnode =
(LayoutNode) rundata.getAttribute("com.ibm.wps.composition.element");
com.ibm.portal.ObjectID objectid;

if (layoutnode == null)
throw new IllegalStateException("PortletIDTag: Control cannot be found!");
objectid = layoutnode.getObjectID();
if (objectid != null)
portletId = IdentificationMgr.getIdentification().serialize(objectid,false);

}
catch (Exception e) {
e.printStackTrace();

}
}
After calculating the dynamic portletId, with the help of this
portletId use the following code in your
respective JSP

var dynamicTitle = "<%=request.getAttribute(com.ibm.portal.portlet.Constants.DYNAMIC_TITLE)%>";
var titleElement =document.getElementById("title.<%=portletID%>");
if (titleElement != null) {
if(dynamicTitle != "" && dynamicTitle != "null")
titleElement.innerHTML = dynamicTitle;

Note :- This works fine with Mozilla and IE 7.0 browsers.
But has problems with IE 6.0.It gives "Operation TimeOut"
Error.


For reason that why it happeans :-

http://support.microsoft.com/kb/181050

Hence to solve this problem, I used DOJO. As WebSphere Portal Server
implicitly uses DOJO, it was better to find a solution using DOJO

function init() {

var dynamicTitle = "<%=request.getAttribute(com.ibm.portal.portlet.Constants.DYNAMIC_TITLE)%>";

var titleElement =document.getElementById("title.<%=portletID%>");
if (titleElement != null) {
if(dynamicTitle != "" && dynamicTitle != "null")
titleElement.innerHTML = dynamicTitle;
}
}
dojo.addOnLoad( init );

Now it works fine with all the Browzers........

If you have any better approach or any suggestions
to improve this post, please leave a comment below.









JSR 168, 286 Portlets & Portal Interview Questions

What is a portal ?

A portal can be best described as a web site that acts as a "point of entry" or a gate to a larger system. While it seems pretty difficult to define a portal in the strictest sense, these are some of the common features of portals:

  • Content aggregation:
    Portals tend to aggregate content from multiple, disparate sources and provide one unified view of the same.
  • Personalization:
    This refers to the ability of the portal to tailor the content/services that it offers according to the user of the portal.
  • Search:
    Most if not all portals, offer some form of searching of it's content and sometimes even content from external sources.
  • Single Sign On:
    Allows users to authenticate once to the portal and thereby allows access to many other systems without the need for re authentication.

What is a JSR 168 Portlet ?

Prior to JSR 168, almost all portal platforms offered their own proprietary approach to create pluggable portal components. For example, IBM had IBM portlets, Sun(iPlanet) had Providers, SAP had iViews and Plumtree had Gadgets.

JSR 168 aims to standardize these pluggable portal components so that they are independent of the actual portal server that they are written to. What this means is that one can migrate portlets seamlessly from one portal server to another without any code change.

What are the types of request in JSR 168 portlets?

Their are two types of request :-
1) RenderRequest
2) ActionRequest

What are the differences between portlets and servlets?

Essentially, Servlets provide content that normally takes up the whole page in a browser (unless you're using frames), and portlets provide content that is wrapped by a window. With portlets, you can have multiple portlets side by side with one another and each one can provide content and functionality that is different from the other. A portlet can provide the complete interaction for one type of application, while another portlet can provide content for another type of application. The portal can provide some house keeping functionality and secured single point of entry to all of the portlets on a page. As for the particulars (similarities/differences) between them, please continue reading.

Here are some similarities:

  • Servlets and portlets are web based components that utilize Java for their implementation
  • Portlets are managed by a portlet container similar to a servlet container
  • Both of these components generate content, which can be static or dynamic
  • Both portlets and servlets have a lifecycle that is controlled by the container
  • The client/server model is used for both servlets and portlets
  • The packaging and deployment are essentially the same
  • The manner in which the classes are loaded and the class loaders that perform the work are also the same
  • Lifecycle management is similar
  • The Request and Response semantics are also similar

Here are some differences:

  • Servlets can provide complete web pages, whereas portlets only provide fragments. These fragments are then aggregated to form a complete web page by the portal
  • Portlets aren?t allowed to generated HTML code that contains tags such as base, body, frame, frameset, head, html, or title. The iframe tag can be used with caution.
  • The user cannot access a portlet directly using a URL in the way that a servlet is accessed. Instead, the URL points to the page containing all of the portlets on one page
  • Communication between the web client and the portlets is performed through the portal
  • Portlets can be provided with buttons or controls to manipulate the portlets? window states or portlet modes
  • Multiple instances of a single portlet can be placed onto the same page
  • Portlets support persistent configuration and customization
  • Portlets also support user profile information
  • Portlets support two scopes within the session; application scope and portlet scope

There are several things that servlets are allowed to do, but portlets aren?t. These include the following:

  • Portlet aren?t allowed to set the character set encoding of the response
  • Portlet also aren?t allowed to set the HTTP headers on the response
  • Portlet cannot manipulate the URL of the client request to the portal

What is a portlet container ?

A portlet container runs portlets and provides them with the required runtime environment. A portlet container contains portlets and manages their lifecycle. It also provides persistent storage for portlet preferences. A portlet container receives requests from the portal to execute requests on the portlets hosted by it.A portlet container is not responsible for aggregating the content produced by the portlets. It is the responsibility of the portal to handle the aggregation.

Can I get the HttpServletRequest from a Portlet?

The PortletRequest object is supposed to give you everything you need i.e. parameters, attributes, dispatching, etc. As per the spec, you should not need the HttpServletRequest.

However, some portlet container implementations do provide some kind of hack to get hold of HttpServletRequest e.g. in Pluto you can cast the RenderRequest to HttpServletRequest. But, be aware that this behavior cannot be relied upon.

What's difference between PortletConfig.getInitParameter() and PortletContext.getInitParameter()?

Context-wide init-params share the same context space as Servlets and JSPs belonging to the same application and they are defined in the web.xml file. You can get them using PortletContext.getInitParameter() method.

Portlet-wide initialization parameters on the other hand belong in the portlet.xml file and you can get them using PortletConfig.getInitParameter() method.

What is a PortalSession Interface ?

User identification across many requests and transient information storage about the user is processed by PortletSession interace. One PortletSession is created per portlet application per client.

The PortletSession interface provides a way to identify a user across more than one request and to store transient information about that user.

The storing of information is defined in two scopes- APPLICATION_SCOPE and PORTLET_SCOPE.

APPLICATION_SCOPE: All the objects in the session are available to all portlets,servlets, JSPs of the same portlet application, by using APPLICATION_SCOPE.

PORTLET_SCOPE: All the objects in the session are available to the portlet during the requests for the same portlet window. The attributes persisted in the PORTLET_SCOPE are not protected from other web components.

What is a PortletContext Interface ?

The portlet view of the portlet container is defined by PortletContext. It allows the availability of resources to the portlet. Using this context, the portlet log can be accessed and URL references to resources can be obtained. There is always only one context per portlet application per JVM.

Is there any difference betweeb websphere and weblogic ?

Webpshere tends to focus more on integration, connectivity and web services. it has rich implementation of J2EE, better performance, more extensive integration and transaction management. In terms of trnsaction weblogic is having default transaction attribute as ’supports’, but websphere does not have any default transaction attribute.

How to implement JDBC-ODBC bridge driver (Type 1 ) in Websphere?

If you use JDBC type (I) driver you dont need to add any driver in websphere. you simply created DSN and use it locally, same we use java class, if you use Type(2) and Type(4) so first go to admin console then go to connection, then add driver there fill other info like conn. size, uname pass, max conn. and connect it to you applications.


What is the difference between application server and web server?

ApplicationServer: takes care of Security, Transaction, Multithreading, Resource pooling, load balancing, clustering, performence, highly availability, scalability, etc. Exposes business logic to client applications through various protocols, possibly including HTTP. Supports deployment of .war and .ear filesApplication server = webserver + EJB container.

Webserver: handles HTTP protocol. Receives HTTP request, it responds with an HTTP response.

Explain relationship betweeb the Servlet Container and Portlet Container?

The portlet container is an extension of the servlet container. As such, a portlet container
can be built on top of an existing servlet container or it may implement all the
functionality of a servlet container. Regardless of how a portlet container is implemented,
its runtime environment is assumed to support Servlet Specification 2.3

Explain portlet lifecycle?

A portlet is managed through a well defined life cycle that defines how it is loaded,
instantiated and initialized, how it handles requests from clients, and how it is taken out
of service. This life cycle of a portlet is expressed through the init, processAction,
render and destroy methods of the Portlet interface.




















Thursday, April 2, 2009

Introduction for JSR 168 - the Portlet Specification

JSR(Java Specification Request) 168 is basically the Portlet Specification version 1.0 where standard for Java Portlet API is described.Any portlet developed using this standard can be deployed on any JSR 168 compliant portal servers.

Before moving further, let me first tell you the need why this specification was introduced…

In my case, my company (http://www.syncex.com/) is practicing Portal technology for more than 4 years and are providing and developing collaborative portlets which are very useful from an organization’s perspective.If for the development of these portlets,we had used any specific vendor’s portlet API e.g API provided by IBM, then we would have targeted buisness of only those organizations whose portal servers are compatible with the portlets developed with this portlet API.For us it would have restricted our buisness since we cannot target all different available portal servers or we need to develop portlets with different portlet APIs available in the market which was never a solution.

This was my problem and I was in a desperate need of a kind of standard specification by which i can develop portlets which can run on many portal servers so that i can increase the business for my company.

This was my problem, now let me explain you the need in generalized manner .

As we know an enterprise portal is a unified access point for integrating information, people and processes of an organization often in the form of a web-based user interface. It is designed to aggregate and personalize information through application-specific portlets.

With the emergence of an increasing number of enterprise portals, various vendors have created different APIs to develop different portlets. This variety of incompatible interfaces generate problems for application providers, portal customers, and portal server vendors.

To overcome these problems,some smart people(experts of portlet technology) introduced JSR (Java Specification Request) 168, the Portlet Specification version 1.0 and this specification was started to provide interoperability between portlets and portals.

So let me conclude that this specification was introduced for:
(1) Portal server vendors so that they can provide portlet engines
that conform to this standard.
(2)To save portal customers from incompatibility issues.
(3)Application providers (like me ) who can now follow a standard for their applications.

If anybody have any thought or different perspective on the use of JSR 168 then do share with me by commenting.