JSR 286 TUTORIAL PDF DOWNLOAD

adminComment(0)

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. This portlet programming tutorial shows how the PortletRequest and Portlet Response are used when developing JSR, request-response based apps. The following tutorial is the second in a series of JSR development learning resources appearing on TechTarget's TheServerSide. Java Portlet Specification , Java Specification Request (JSR) , was the latest portal server release from Sun, is free for download and deployment. The Java Portlet Specification (PDF), which describes the benefits of JSR . Forums · Java Magazine · Developer Training · Tutorials · wfhm.info


Jsr 286 Tutorial Pdf Download

Author:ASHANTI SHELLNUT
Language:English, Japanese, Arabic
Country:Marshall Islands
Genre:Environment
Pages:558
Published (Last):07.10.2015
ISBN:283-8-26673-181-1
ePub File Size:29.49 MB
PDF File Size:12.21 MB
Distribution:Free* [*Registration needed]
Downloads:45399
Uploaded by: JODY

build standards-based Java portlets using the Java Portlet Specification, JSR For more information and to download a sample application, see the blog . Jsr vs Jsr - Download as Word Doc .doc /.docx), PDF File .pdf), Text File .txt) or Introduction to the Struts Web Framework - NetBeans IDE Tutorial. 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.

Portlet filters The new portlet filter functionality allows you to plug filters around any life-cycle call of the portlet. Following the common decorator pattern, filters can do pre- or post-processing, and they can modify or wrap the request and response objects that are passed to the portlet.

Typical applications of portlet filters could include these: Passing information from additional sources to the portlet as attributes or parameters Output filtering for security enforcement or markup compliance Collecting diagnostic information Bridging between Web application frameworks WebSphere Portal V6.

The portlet filter programming model is modeled on the servlet filter model: Define the filters in the deployment descriptor.

Implement the corresponding Filter interface in your filter. You can also list multiple life-cycle entries and implement multiple Filter interfaces with your class.

Provide a filter-mapping element where you describe to which portlets your filter should be applied you can also use an asterisk as a wildcard if it should be applied to all portlets in the application. The order of the filter-mapping elements in the deployment descriptor also defines the order of the filters that are applied to the portlet.

Listing 4 shows an example for a deployment descriptor entry. Listing 4. Each filter gets the current request and response, or a wrapped version created by a preceding filter, and the filter chain.

After doing its preprocessing, the filter implementation can either terminate the request processing or call the next element in the filter chain, passing in either the received request and response or additional wrappers.

The last element in the filter chain is the portlet itself. Listing 5 is an example of a filter that does some pre- and post-processing and provides the portlet with a wrapped request. Listing 5. Do not add new methods on the wrapper; there may be other wrappers in the chain that you don't know of, and thus the portlet may not be able to access your new method.

If you want to provide the portlet with additional capabilities, set an object providing access to these capabilities as a request attribute. One example involves implementing a mapping of resources to shared IDs. You need to register such a listener with the listener element in the portlet deployment descriptor, and your class needs to implement the PortalURLGenerationListener interface that defines a callback method for each type of portlet URLs: action, render, and resource.

Portlet-managed modes In JSR , the portlet could leverage only portlet modes that are supported by the portal framework running the portlet. In some use cases, the portlet wants to offer portlet-specific functionality with the same user look-and-feel as portlet modes supported by the portal for example, with context menus on the portlet window.

Building composite applications using coordination

For example, a ShowShoppingCart portlet mode lists all entries that you currently have in your shopping cart. To support these use cases, JSR introduces the portlet-managed modes that are not known to the portal, but are managed by the portlet itself. The portlet can declare such a mode in the portlet deployment descriptor with the code shown in listing 6.

Listing 6. This setting indicates to the portal that it should treat this mode just like the standard View mode concerning all aspects, including how it provides the portlet with preferences and from the perspective of access control. The portal should provide UI controls that allow the portlet to switch to this mode. The portlet can define localized names for the decoration using the resource bundle entry: javax.

Because the portal does not know specific semantics of the portlet-managed modes, it does not know when it makes sense to present a decoration to switch to a portlet-managed mode and when it does not. Therefore, the JSR specification lets you indicate for which portlet modes the portal should display UI controls as part of the render response using the method setNextPossiblePortletModes.

Note that you need to set this list of modes on each response and that you should enable the container runtime option javax. Container runtime options Container runtime options allow the portlet to supply specific options to the portlet container that either change default behavior defined in the Java Portlet Specification or add additional behaviors. We've already seen an example of such a container runtime setting: the renderHeaders option. JSR defines a list of container runtime options that are all optional except for actionScopedRequestAttributes.

In addition to these options, specific portlet container implementations may provide their own options. You indicate that your portlet requires a specific container runtime option in the deployment descriptor using the code shown in listing 7. Listing 7. Enables the two-part rendering mechanism that lets you set headers in streaming-based portal implementations. Allows you to change the default scope of the session object provided to servlets or JSPs that are called from the portlet through forward or include from application scope to portlet scope.

That way, these resources access the same session data using portlet and servlet APIs, which is particularly convenient if your JSPs are written for a servlet-based Web framework. Allows Web frameworks to pass complex objects from the action or event phase to the render phase through the request. You are able to access these attributes until the next request with an action semantic which may be an action triggered through an Action URL or an event occurs.

This feature likely is implemented by the portlet container by storing these attributes in the session. Therefore, use this feature only if you cannot avoid it, as it will probably cause some performance degradation. This option is the only one that JSR requires to be supported by all containers.

Note that if you use a container runtime option and the container on which your portlet is deployed does not support this option, the container may reject the deployment of the portlet. Use these options with care if you want to develop a portlet that can run on many different portlet container implementations.

Backward compatibility Java Portlet Specification V2. This design point means that all portlets written against the V1. The only exceptions to this rule are the following slight behavior changes that normally should not break any portlets: RenderResponse.

Introducing Java Portlet Specifications: JSR and JSR

Calling getWriter or getOutputstream without previously setting the content type no longer results in an IllegalStateException in V2.

This backward compatibility statement also includes the deployment descriptor in which V2.

This behavior means that you can turn most JSR portlets into a JSR portlet by changing the one line in the portlet deployment descriptor that references the schema to the new V2. In this section, we cover various smaller additions that can make your life easier and that can support new use cases, such as the new Java 5 features leveraged in the API, the new caching features, the changes in the runtime IDs that you can access, and the tag lib additions.

Java 5 features JSR leverages some of the new Java 5 features: Using Generics Introducing a new enum class for all user profile attributes GenericPortlet also lets you use the following annotations to make dispatching life-cycle calls to specific handler code easier: ProcessAction. This annotation allows you to annotate a method that should process a specific action. To allow dispatching, the Action URL needs to include the parameter javax.

This annotation allows you to annotate methods that should process specific events. This annotation allows you to annotate methods that should render a specific portlet mode. Listing 8 shows how you use the ProcessAction annotation.

Listing 8. For Java 1. New caching features JSR adds new caching features that help making portlets scale better: Public caching scope, which marks cache entries shared across users Support for multiple cached views per portlet Validation-based caching for validating expired cache entries In JSR , all cache entries were private for each user.

If you have portlets that are not customizable and don't display different content for different users, such as a news-of-the-day portlet, then you get a cache entry for each user, even if all entries are the same. Now, in JSR , you can tell the portlet container that the cache entry can be shared using the cache-scope element in the deployment descriptor.

Thus, you can dramatically reduce the memory footprint for these portlets, as the code in listing 9 shows. Listiing 9. We recommend that you do not change the cache scope programmatically, though, as it may be difficult for portlet containers to ensure that cache entries are invalidated correctly if your portlet mixes responses with cache scope public and private for the same user.

The JSR specification demanded that portlet containers must invalidate the cache for each user interaction with a portlet render or action URL , so that there could be only a single cache entry per portlet window and user. With the introduction of public render parameters and shared caching, the specification has been enhanced to allow the container to cache multiple portlet views based on render parameters.

This enhancement means that you can use render parameters so that users can navigate between different views in a shared cacheable portlet while the output still remains cached. Only the action and event processing calls, which can cause side-effects that are not known to the container, now require a cache invalidation.

Validation-based caching is useful for situations in which you do not want to recompute the markup of a portlet often because it is an expensive operation.

Ideally, set the expiration time to a high value so that the markup is cached for a long time. On the other hand, you may want to respond quickly to changes in your back-end system and provide an updated view of the portlet. Validation-based caching solves this dilemma: It allows you to define a short expiration time so that your portlet gets called often and can check for changes in the back-end system.

If nothing has changed in the back-end system, you validate that the expired cache content is still valid to use by setting the CacheControl. If something has changed in the back-end system, then you produce new markup and set the setting to false.

How do you know which back-end state the currently cached markup maps to? The portlet container can then provide you with this ETag in the request of the next render or serveResource call, indicating that it still has the cached content available, which can be revalidated. An example of using validation-based caching is shown in listing Listing If, for example, the request to the back-end server takes up 90 percent of the time to render the portlet, it does not make sense to use validation-based caching to save only the remaining 10 percent rendering time.

Runtime IDs Runtime IDs can be used to scope data that your portlet handles, so that you can avoid collisions between multiple occurrences of a portlet within the same portal, and maybe even on the same page. Enjoy this article as well as all of our content, including E-Guides, news, tips and more. Step 2 of 2: You forgot to provide an Email Address. This email address is already registered. Please login. You have exceeded the maximum character limit. Please provide a Corporate E-mail Address.

Please check the box if you want to proceed. I agree to my information being processed by TechTarget and its Partners to contact me via phone, email, or other means regarding information relevant to my professional interests. I may unsubscribe at any time. These tutorials and tips are designed to help any software developer who is looking to develop JSR programming skills to become quickly adept at both basic and advanced portlet programming topics, empowering the developer to quickly create portlet-based software that can be effectively deployed to any of the standards-based portal servers on the market today.

What exactly is a portlet? 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.

Portlets Integration Using JSR

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. 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. These "quickstart" tutorials and tips are intended to help any application developer acquire coveted portlet programming skills and become quickly adept at both introductory and expert portal programming topics, which allow the developer to build portlet-based applications that can be effectively deployed to any of the standards-based portal servers available on the market today.

JSR portlets are Java-based components, and like all Java-based components, they can have any number of business methods and instance variables defined within.

However, there is one method that all portlets must define if they want to be rendered on a portal page, and that ever-important method is the doView method. The view mode and the doView method When a portlet is initially displayed on a page, it is said to be in view mode. The view mode represents the normal way that a portlet looks when it appears on a portal page. The doView method of a portlet corresponds to the view mode of a portlet. The way that a portlet, in its normal mode, should look on a page, is coded into the doView method.

Since it must be possible to view a portlet that is placed on a portal page, every portlet must have a doView method.

Portlet Tutorial

Along with a concrete implementation of the doView method, to be rendered on a page, a portlet must also define support for the view mode within its deployment descriptors. Cameron McKenzie , editor of TheServerSide potemcam A portlet's primary responsibility is to handle a Web-based request-response cycle. The JSR specification defines a PortletRequest data type, but it is actually a subtype of the PortletRequest that is passed into the doView method. This special subtype of the PortletRequest is the RenderRequest, which sort of makes sense, as the doView method is invoked when a portlet is required to render content to be displayed on the client device.

While the doView method of a portlet is passed a RenderRequest, as opposed to the more generic PortletRequest, the RenderRequest only defines a single new method used with caching, named getETag , so the distinction is largely academic. All of the other methods available to the RenderRequest, such as getLocale and isSecure , are actually defined in the PortletRequest interface.

Inspecting the incoming request Any information a developer is allowed to know about the incoming client request is obtained through the request object. Some of the salacious things we can find out about the user through the PortletRequest object include: The preferred language of the user; Any headers served up by a client's browser; What a user typed into a textfield; Which radio button a user selected; The type of browser the client is using; and The color of the shirt the user is wearing.

Okay, maybe the PortletRequest can't tell you the color of the shirt your user is wearing, but it can tell you practically anything else.

The PortletRequest makes interrogating your client way too easy. The PortletResponse object While the PortletRequest is used to discover information about the incoming request, the PortletResponse, or more accurately for methods used during the rendering phase of a portlet, the RenderResponse object, is typically used to send something back, or do something to, the client.In some use cases, the portlet wants to offer portlet-specific functionality with the same user look-and-feel as portlet modes supported by the portal for example, with context menus on the portlet window.

If the returned content is not user specific, you should additionally set the cache control to public scope. Furthermore, any HTML tags that are opened in a portlet should be closed by that same portlet. You can add Faces components to this page. Click OK. All portlets defined within a portlet application must be declared in the portlet deployment descriptor, portlet. Page-level cacheable resources such as resources providing action or render URLs, for example, the markup returned for an Ajax call.

As stated earlier, this cache setting only comes into play when the portlet itself does not specify a caching condition for a response. Select Custom Code to implement the portlet mode through a custom coded object.

BRANT from Providence
Look through my other articles. I'm keen on track racing. I do relish studying docunments meaningfully .
>