In this three-part series, the articles describe new features available in the Java Portlet Specification (JSR ) and extensions supported by OpenPortal. This JSR Portlet Development Tutorial and Technology Guide is designed to help enterprise Java professionals gain the knowledge they need to excel in the emerging portal and portlet development space. A short article appeared in April of on TheServerSide that discussed. This portlet programming tutorial is an introduction to developing JSR applications that can be deployed to any standards-based portal server. Portlets are, quite simply, standardized, Java-based, content delivery vehicles that render themselves within the confines of a portal.

Jsr 286 Tutorial Download

Language:English, Portuguese, Arabic
Genre:Politics & Laws
Published (Last):05.07.2016
ePub File Size:28.43 MB
PDF File Size:13.56 MB
Distribution:Free* [*Registration needed]
Uploaded by: CARLY

Developing JSR Portlets Cris J. Holdorph Unicon, Inc. JA-SIG . Portlet / JSR History Java Community Process. Portlet Tutorial, Java Portlet, Portlet Example, Java Portlet Tutorial, What is JSR has introduced the using of annotations for controlling things .. Contribute us by commenting below and find downloaded source code. Liferay Portal Portlet tutorial for beginners, liferay download, liferay eclipse plugin example, liferay Liferary is a JSR complaint leading Portlet container.

This method returns an object of type Event encapsulating the current event name and value. Event names are represented as QNames to identify them uniquely.

The event name can be retrieved by using the getQName method that returns the complete QName of the event, or by using the getName method that returns only the local part of the event name. The value of the event must be based on the type defined in the deployment descriptor.

Continue Reading This Article

To create portlets that use the event feature: Declare the events that will be published or processed in the portlet. The event definition must specify a name and optionally an object type. Note: The object must be serializable and must be annotated with the XML root element. Clicking on any continent in the World Map triggers an event. This event is processed by the Continent Information and Continent Map portlets to show the relevant information.

Figure 1. Sample Application: Eventing Map Using Wildcards To use wildcards, the portlet must organize the local part of the event names in the event-definition element in a hierarchical manner using the dot.

You might also like: W3SCHOOL HTML TUTORIAL IN PDF

For example: foo. If you want the wildcard string to match a part of a hierarchy, two dots are required at the end of the wildcard string: one to denote the hierarchy and one for the wildcard.

For example: foo.. The event name must be part of the hierarchy, not a substring. Portlet2 can process the events x:foo.

Portlet3 can process the events x:foo. Portlet4 cannot process any event because there is no event that begins with the hierarchy x:foo. Note: e. Using Aliases Aliases can be used to coordinate between two portlet applications that use different event names. Consider a portlet, PortletA, that uses lastname as an event name and a portlet, PortletB, that uses surname as an event name. The event published by PortletA cannot be processed by PortletB because the event names are different.

Java Portlet Example Tutorial

By adding alias in the portlet. To add aliases for portlet events: Add an alias the same as qname of the event of PortletB in the portlet.

By using the public render parameters feature, the render parameters set in the processAction method of one portlet are available in render parameters of the other portlets. Using public render parameters instead of events avoids the additional process event call. The public render parameters can also be set on the render URL. To enable coordination of render parameters with other portlets within the same portlet application or across portlet applications, the portlet can declare public render parameters in its deployment descriptor using the public-render-parameter element in the portlet application section.

Public render parameters can be viewed and changed by other portlets or components. In the portlet section, each portlet can specify the public render parameters to be shared through the supported-public-render-parameter element.

The supported-public-render-parameter element must reference the identifier of a public render parameter defined in the portlet application section in a public-render-parameter element. To create portlets that use the public render parameters: Declare the render parameters to be shared in the portlet.

Figure 2 shows the Weather and Map portlets. The Weather portlet sets the zip code, which is declared as a public render parameter. This parameter is supported by both Weather and Map portlets. So, you want to develop portlets, eh? Well, we should probably baseline this whole process with a little bit of a discussion about just exactly what a portlet is. A portlet, in the most vulgar sense, is simply a content-delivery vehicle.

That's what a portlet does -- it delivers content to a user. Sure, a user can be as simple as a Web page, or as voluptuous as a handheld multimedia device, but that's all that a portlet really does -- it simply delivers content to an end user. Portlets are not Web services; Web services are Web services.

Portlets are not Web services. Portlets are not EJBs. Portlets are not JavaBeans. Portlets are, quite simply, standardized, Java-based, content delivery vehicles that render themselves within the confines of a portal page. Note: The fact that portlets are rendered within the confines of a portal page is not a minor point.

When a portlet renders itself, the content it generates only constitutes a portion of the total content delivered to the end user. A portlet may make up a large portion of the overall content delivered to a handheld device, or it may make up a quarter of the HTML page delivered to a client's Web browser; but regardless of how much of the total content delivered to an end user for which a given portlet is responsible, the fact remains that a portlet only generates part of the total amount of content delivered to the end user.

The portion of content a portlet generates for rendering is typically referred to as a fragment. The mighty portlet interface From the standpoint of an application developer, a portlet is any Java class that implements the javax.

Portlet interface. Like a servlet, a portlet is a shy and reserved little creature that lives peacefully in a WAR file Web Application aRchive. However, if you get a few drinks into a portlet and get it loaded, that little portlet remains loaded in memory forever, and it is not unloaded until the portal server shuts down or the administrator explicitly takes the portlet out of service.

Once loaded, the single portlet instance can respond, in a threaded fashion, to an unlimited number of client requests, with the only restraint being the hardware limitations of the portal server on which it runs. Figure 1. The Portlet interface and the methods it defines.

Liferay Tutorial – Liferay Portal Portlet Tutorial

Lifecycle methods of the Portlet interface The javax. Portlet interface defines four lifecycle methods, with the init and destroy methods used to allow a developer to take action when a portlet is first loaded, or when a portlet is unloaded by the portal server. Similar to the Servlet and JSP API, the method corresponding to a portlet's initialization is very uncreatively named init PortletConfig config , and the method that maps to the unloading of a portlet is violently named destroy.

The very generic portlet interface also defines two more very important lifecycle methods, namely the processAction method, which logically is intended to be used during the action-processing phase, and the render method, which as you could probably guess, corresponds to the rendering phase in which a portlet generates the markup fragment that eventually gets displayed back to the client. The abstract class GenericPortlet As a JSR portlet developer , you will never create a class that simply implements the portlet interface.

Okay, maybe never is a little bit of an exaggeration, but when you code your portlets, you don't implement the portlet interface directly, but you extend the abstract class GenericPortlet instead, which itself implements the javax. These methods correspond to the three standard rendering modes of a portlet.

Clever, eh? Figure 2. The methods of the GenericPortlet class. What do portlets do? Okay, so far we've discussed what a portlet is. In so doing, we have covered the mind-numbing details of the portlet interface and the abstract GenericPortlet class. That describes what a portlet is. But as developers, we are more concerned with what a portlet does, and more to the point, how it does it. At the most fundamental level, portlets are simply presentation-tier components that handle a request-response cycle.

When a request comes in from a client, portlets are responsible for inspecting that request, and figuring out exactly what the client is requesting. Once the portlet has figured out what the crazy client is requesting, the portlet must then figure out how to respond. Before responding to a client, a portlet might use a bunch of EJBs or JavaBeans , Web services or JDBC, but eventually, a response must be formulated and sent back to the portal for portal page aggregation, after which content is finally returned to the client.

The essence of portlet programming is handling the request-response cycle. Conquer the request-response cycle, and the rest of the Portlet API will easily fall under your control. Figure 3. The ancestry and the implemented interfaces of a custom portlet.

The most basic portlet In the most basic sense, a portlet simply handles a Web-based, request-response cycle.

As a portlet developer, our fundamental responsibility is to simply inspect the incoming request, and subsequently supply an appropriate response back to the user.

JSR-286 portlet development tutorial and technology guide

The Portlet API makes it very easy to develop delicious portlets that can intelligently respond to this Web-based request-response cycle. To create a portlet that can be viewed on any portal page, we simply create a Java class that extends GenericPortlet, and code a special method called doView. And what do we do in the doView method? We implement some logic and eventually send some output to the client. The junk we output appears within the confines of a portlet window, on a portal page.

Figure 4. Output generated in the doView method is rendered within the confines of a portlet, which appears, aggregated, on a portal page. The HelloWorldPortlet is an example of a very simple portlet that extends GenericPortlet, and simply outputs data to a client in the doView method.

The PortletRequest and PortletResponse Two supremely important objects are passed to a portlet's doView method: a PortletRequest object, as the RenderRequest a PortletResponse object, as the RenderResponse Everything a developer wants to know about the incoming request is stuffed inside the PortletRequest object.This tutorial aimed to provide you additional details about GenericPortlet, PortletRequest, PortletResponse and others.

EmployeeDAO is responsbile of saving an employee while the database connectivity is handled by ConnectionUtility. But before adding your Portlet into your dashboard, just make sure you were deploying it.

Minimized A portlet may show very little information, or none at all. Portlets are not Web services.