Post a Comment. Search for:. Tuesday, April 8, We can also call Portlet Specification 2.

Author:Samuzilkree Malarn
Language:English (Spanish)
Genre:Health and Food
Published (Last):10 April 2009
PDF File Size:18.32 Mb
ePub File Size:8.2 Mb
Price:Free* [*Free Regsitration Required]

Portlets are componentized user-facing applications that create some kind of markup. This markup is intended to be aggregated with other markup fragments into a larger application, for example, a portal page as shown in figure 1. View image at full size. Portlets can therefore be viewed as user interface UI -based services that take the Service-Oriented Architecture SOA approach all the way up to the user interface. Since then, nearly all the vendors in the Java portal space, both commercial and open-source vendors, have implemented this standard, and developers have written portlets using the Java Portlet API.

The JSR , however, stopped at defining the overall UI component model and did not define any means for building integrated composite applications out of these components. This limitation, and many other things that didn't make it into V1. The expert group of JSR consists of all the major commercial and open-source portal developers, portlet bridge developers, and portlet framework developers.

You can find a complete list of the members of the expert group here. This article provides an overview of the main new features in JSR and some examples of how to leverage these features. This article assumes basic knowledge about the portlet programming model defined in version 1. The main new features of version 2. At development time, you define only the data that a portlet understands, and the actual connections between portlets are created at deployment or runtime.

Leveraging these coordination features, portal administrators or business users can now build larger composite applications, out of portlet components without programming. This capability opens the possibility to create new functionality by combining existing components into business mashups in a similar fashion to popular Web 2. JSR allows portlets to send and receive events.

As mentioned before, the model is a loosely coupled model where the portal application acts as broker between the different portlets and distributes the events.

Figure 2 depicts the details of how this distribution works. Portlet 1 defines that it can publish some event A in its portlet. Portlets 2 and 3 define that they are able to receive event A in their portlet. The portal administrator or business user has now put these three portlets on a page and created connections between the sending portlet Portlet 1 and the receiving portlets Portlet 2 and Portlet 3. Now the user interacts with Portlet 1 and triggers an action on Portlet 1.

As a result of this action, the portlet issues event A. After the portlet has finished its action processing the event broker component, which is typically part of a portal runtime, it looks for targets of this event. In our sample, there is a connection between Portlet 1 and Portlets 2 and 3 for this event. Thus, the event broker calls the processEvent life cycle method introduced with version 2. After the action and event processing have finished, the rendering lifecycle starts and the portlets can create new markup based on the state updates that occurred in the action and event phases.

JSR does not specify how connections for portlet coordination are defined and managed. Typically, connections are defined explicitly at page creation time, or they are automatically inferred by the portal at runtime.

The first approach allows more control and flexibility, while the second is easier to use. In both cases, the portal needs to know what kind of events a portlet can receive and send. Therefore, you need to provide this information in the portlet.

How would you do this? First, you provide the general event definition, and then you reference this definition in the portlet section with tags that specify that the portlet can either receive or send this event.

QNames are the mechanism for using unique names in XML; they also have a Java representation as the standard library class javax. You can specify a full QName for each event, or if you use the same namespace for many events, you can declare it as the default namespace and then specify only the local part of each event.

Why do we need this additional JAXB serialization? A portlet may want to send an event to a remote portlet that is running using WSRP. These remote portlets may not be written in Java, and so we need a more general mechanism than the Java serialization. This detail was the hard part; now your work is getting simpler: receiving and sending events through your portlet. To receive events you need either to extend GenericPortlet or to implement the EventPortlet interface yourself.

Extending GenericPortlet has the additional advantage of being able to use annotations for denoting special methods for handling events, processing actions, and rendering a specific portlet mode. Public render parameters allow sharing of request parameters across different portlets or other artifacts, like themes or portal pages in IBM WebSphere Portal. Defining a public render parameter is very similar to defining an event: You specify a unique QName and optional alias names in the portlet.

The QName and alias names are used to connect public render parameters of different portlets. You can view these public render parameters as a shared storage area where all participating portlets can set and get the values.

Figure 3 depicts an example where a navigator portlet and a content portlet share the same public parameter docid. After you click a link in the navigator portlet that sets the docid to document3, the content portlet displays the content of that document because its view state the ID of the current document has been changed from an external influence.

Note that public render parameters can be stored in the URL, as in the WebSphere Portal implementation, and thus you can bookmark pages and use the browser's Back and Forward buttons.

How can the portlet get access to these public render parameters? In the portlet itself, you access the public render parameters with the same methods that are used to handle ordinary render parameters defined in version 1. Given that these methods take only Strings as keys and not QNames you need to define an identifier in the portlet. In most cases, the portlet code does not actually need to change whether a render parameter is public or private, so you can enable your portlet for coordination by simply declaring those parts of the view state information in the portlet.

If you want to specifically access only public render parameters in your code, then you can also use the method getPublicParameterMap on the request. In the first version of the Java Portlet Specification, you could not serve dynamically generated resources directly through the portlet. Instead, you needed an additional servlet that served the resources. This limitation had some disadvantages:. One advantage of serving resources through a servlet is less overhead because the request does not have to pass through the additional portal framework, for example, when serving large media streams.

Version 2. Resource URLs trigger the lifecycle method, serveResource, on the ResourceServingPortlet interface that you can leverage to create dynamic resources directly in the portlet. You must have a resource URL to trigger the new serveResource life-cycle method.

Let's start by looking into the details of the new resource URL. You receive these parameters in the serveResource call.

Note that ResourceURLs cannot set new render parameters, portlet mode, or window state. This restriction occurs because serveResource calls do not generate a full new portal page, but return the response of serveResource. Thus, the portal does not have a chance to update other parts of the page where this information may be encoded; for example, in WebSphere Portal all URLs contain this information and so need to be updated.

You can also set an additional resource ID on the resource URL that clearly identifies your resource. You can set the path to your resource asID, as shown here: url. In this case, GenericPortlet automatically dispatches to the given JSP, which can then make use of the portlet state information by including the portlet tag library.

Serving static resources using the portlet's serveResource method causes unnecessary performance overhead. To receive a serveResource call triggered by a resource URL, you need to either implement the new ResourceServingPortlet or extend GenericPortlet, which already implements the new interface. The resource request has similar methods to the render request, but in addition it lets you get access to upload data.

In the resource request, the parameter handling lets you have access to three different types of parameters:. The ordinary parameter access methods return the merged set of these three parameter maps. Parameters that have the same key first get the resource parameter values merged and then either the private or public render parameter values, depending on whether the parameter key was declared as a public render parameter in portlet.

These state changes, though, should be limited to private state of the portlet: portlet-scoped session data and portlet preferences. You should not modify state that affects other portlets because the portal framework does not have a chance to update other parts of the portal page for serveResource calls, so that updates to page-level state may not be visible.

NOTE: Render parameters, portlet mode, and window state fall into this category as some portal implementations, such as WebSphere Portal, store this information in the URL to support the ability to bookmark and the use of Back and Forward buttons in the browser. This implementation means that changing a render parameter, for example, requires an update of all the URLs on the page, which the portal cannot perform, as the processing of the response data on the client is done entirely by the portlet.

Because the markup returned from serveResource is not aggregated with other markup from the portal framework, the resource response allows full control over the output stream. For example, the portlet can set a HTTP status code. There are many different use cases for serving resources; therefore, there are also different requirements for the ability to cache serveResource calls.

This method gives a hint to the portal about how much information the target serveResource call requires. Note that setting the cacheability of a resource response makes sense only if you allow the response to be cached by specifying HTTP caching headers for the returned response. This specification means that you must set at least an expiration time using response. If the returned content is not user specific, you should additionally set the cache control to public scope.

Full cacheable resources, which do not depend on interaction state. An example is a programmatically generated SVG view that depends on the portlet preferences for back-end access. This setting means that the portal can generate a URL that does not contain any interaction state of the page and the portlets on the page. Thus, the browser can cache the returned markup of the serveResource call for at least as long as the user interacts with the current page.

As a result of not encoding any state of the page and portlets on the page, you cannot count on getting the current render parameters, portlet mode, or window state in your portlet. Keep in mind that because of the missing state information, you are restricted in the output of serveResource: You can include only resource URLs that are fully cacheable, and you cannot include action or render URLs.

Full and shared cacheable resources such as shared static resources, for example, JavaScript libraries. Specifying the shared property enables the portal to use only one version of such shared resources per page. It still requires that the portlet packages these resources in its WAR file in case the portal has not already loaded the resource.

In summary, these cacheability levels give you the ability to provide as many hints about the cacheability as possible to the runtime. The runtime also can enhance the cacheability of resources in other ways, for example by keeping track of the state changes on the client and re-rendering only the parts affected by state changes. In version 1. This servlet, however, was then addressed directly and not through the portal framework, so it did not have the portlet state provided, nor was it under the security protection of the portal, as you can see in figure 4.



In fact, GateIn 3. This chapter gives a brief overview of the Portlet Specifications but portlet developers are strongly encouraged to read the JSR Portlet Specification. GateIn 3. A portal can be considered as a series of web pages with different areas within them. Those areas contain different windows and each window contains portlet:.


Java Portlet Specification

The Java Portlet Specification defines a contract between the portlet container and portlets and provides a convenient programming model for Java portlet developers. Portlets are pluggable user interface software components that are managed and displayed in a web portal , for example an enterprise portal or a web CMS. A portlet can aggregate integrate and personalize content from different sources within a web page. A portlet responds to requests from a web client with and generates dynamic content.


Java Portlet Specification 2.0 (JSR 286) Support

Portlets are componentized user-facing applications that create some kind of markup. This markup is intended to be aggregated with other markup fragments into a larger application, for example, a portal page as shown in figure 1. View image at full size. Portlets can therefore be viewed as user interface UI -based services that take the Service-Oriented Architecture SOA approach all the way up to the user interface. Since then, nearly all the vendors in the Java portal space, both commercial and open-source vendors, have implemented this standard, and developers have written portlets using the Java Portlet API.


What's new in the Java Portlet Specification V2.0 (JSR 286)?


Related Articles