Showing posts with label portlet. Show all posts
Showing posts with label portlet. 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.

Monday, April 20, 2009

WebSphere Portal - Know what action to take if portal's default Login portlet gets deleted..!!!

I was working on some customization of login portlet. I have deployed my own login portlet and added mylogin portlet to the login page.
Somehow accidently login portlet (portal default) got deleted and my own login portlet is also not working.
Because of this i am not able to login to portal and can't put back the ibm's login portlet on the login page.

To resolve this issue, I used the following URL whic is portals automatic login URL and its a standard
http://servername:port/wps/portal/cxml/04_SD9ePMtCP1I800I_KydQvyHFUBADPmuQy?userid=userid&password=password

With the help of this URL you can automatically login to the portal.
enjoy... :)

Tuesday, April 14, 2009

Customizing Themes & Skins in WebSphere Portal: how to add custom items to the portlet context menu

As we know the Portlet Context Menu contains controls to change the portlet's mode, state, and position on a page.In figure below, you can see that with different access rights, you have the ability not only to change the mode and the state, but also to change where that portlet renders on the page. From this menu, you can either move the portlet down in the order of the page or move it to the column on the right.



The above figure shows that the portlet context menu varies based on factors such as permission, placement, and the portlet with which it is interacting. Additionally, this menu is extensible in two ways. First, you can add items directly to the JSP file that renders the portlet context menu; Second, you can use theme extensions to add items to the menu with little coding involved.

To Know how to add a custom item option in portlet Context menu using theme extensions Click Here.



Friday, April 10, 2009

Know how to remove the Minimize, Maximize and other options out of the portlet context menu in WebSphere Portal 6.0...

Working on my current project, I had a requirment to remove portlet context menus such has Maximize, Minimize, Move up, Move right etc from the Portlet Context Menu. Themes and skins in WebSphere Portal provide the framework for the UI, which includes page navigation, page layout, containers to hold portlet-rendered markup, and controls for user interaction. The title of the portlet as well as the portlet context menu are the part of the skin is rendering. Control.jsp in skin folder is basically responsile to render the portelt title and portlet Context menu. Following code in Control. jsp is responsible for portelt context menu


The URL generated from the code in listing 2 targets the JSP file that renders the portlet context menu, the themeTemplate attribute tells WebSphere Portal what JSP file to render, and the value in themeTemplate must match the file name of the JSP file excluding the file extension, which in our case is portletContextMenu.
Hence all the portlet menu items are from portletContextMenu.jsp inside themes folder.
Now to remove a particular portelt menu, look for the following code inside porteltContextMenu.jsp








You can delete the above code to remove Maximize portlet menu. Similarly other portlet menus can be removed. You can find code for portlet menus like Personalize, Edit_Default, Config, Maximize, Minimize, Help, Delete etc in portletContextMenu.jsp. Hence for removing any menu, you can just find the entry of that particular menu and can remove it.

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

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.




















Friday, April 3, 2009

Career in Portals & JSR 168 Portlet technology ............

Planning for a career in Portal Technology....! Well definitely you can per sue your career in Portals . Any S/w Engg working for Java, J2EE can per sue his/her career in Portals. Many companies (large + middle) are now practicing Portal Practice in their workplace. Giants like IBM, Oracle , Bea, Wipro, Infosys, Accenture and a never ending list are all having Portal practices at their end. Large Projects are now executed in this technology.
Options available are :
1) You can be a JSR 168/ JSR 286 portlet developer.
For this the basic requirement is to know Java with flavor of J2EE. Like Servlets, Portlets has its own lifecycle. You need a Portal Server to deploy your applications. Hence knowledge of Java is must.

2) You can be a Portal administrator .
Portal administrator plays with the environment ans configuration of the Portal. These persons has vast knowledge of Portal . Portal is like their child, can change its look and feel also. Hence they are called as Portal Specialist.