Using Adrenaline Portlets to Energize Web Applications
Pages: 1, 2
Using an IFrame to insert a new feature into a Web page has become a common technique across the Internet. Many mashup sites rely on this approach, for example. The concept is simple: A developer edits an existing page, and then adds an <iframe> tag without disturbing the rest of the page. IFrames render within their own isolated frame, and so they cannot harm the surrounding page. For legacy Web applications that are risky to update, an IFrame is the right approach.
The IFrame tag is very easy to understand. The developer need only specify the source of the rendered content, and optionally some size and scrolling attributes:
<iframe src="http://wlp.bea.com/wlpBEAWeb/portlets/travel/customers/customers.portlet" width="350" height="450" frameborder="0" scrolling="auto"/>
The process of using the IFrame to render an Adrenaline portlet is easy. Follow these steps:
With the Ajax consumer technique, all clicks within the portlet are routed to the producer asynchronously, and the returned HTML is inserted into the page. Therefore, the enclosing page is not refreshed for portlet events, which allows the portlet to operate independently without interfering with the application. Multiple Ajax rendered portlets may be used on the same page as long as each instance is given a unique id attribute.
The following is the snippet to use when rendering an Adrenaline portlet via Ajax. Notice how
div tags define containers that control different pieces of the rendered portlet.
The key to the Ajax snippet is the call to
bea.netuix.ajax.updateContents() function. It is this function that will ultimately render the HTML contents from the portlet into the
async.js, which is referenced at the top of the snippet.
Note that there is a significant limitation for using this approach. Browsers have a security feature that will not allow the portlet to come from a server in a different IP domain than the outer HTML page. Therefore, this approach will work only when the portlet and the Web application are hosted by the same organization.
To use this snippet to surface your portlet in your own Web application, follow these steps:
cmbrowserwithin the snippet, and replace that text with a unique id for your portlet on the page.
http://[host]:[port]/[webappContextPath]/[relative path]/[portletName].portlet?[keep the existing parameters shown above].
Adrenaline offers a JSP tag that may be embedded into any JSP page in a WebLogic Server Web application that has Adrenaline installed. The portlet to which it refers must also be deployed in the same Web application (for a local portlet) or it can be deployed remotely if using WSRP. Ultimately, Adrenaline must have a WebLogic Portal .portlet descriptor in the Web application for the portlet that is to be exposed.
To surface a portlet in a JSP page, the new Adrenaline
portalFacet tag is inserted into the JSP page:
<%@taglib uri="http://www.bea.com/servers/portal/tags/netuix/render" prefix="render"%> ... < render:portalFacet label="_customers" path="/portlets/travel/customers/customers.portlet" />
where the Web application has a file called
sample.portlet deployed in the
portlets subdirectory. The
label tag attribute must be unique to all
portalFacet tags on the page as it identifies the portlet instance. At runtime, the
portalFacet tag will render the specified portlet on the page using the Ajax approach that has already been described. You may include multiple portlets on a single page by inserting multiple
portalFacet tags with unique
After reviewing the three techniques for consuming portlets into any Web application, it is important to focus on how to create the producer and its portlets. For customers with existing WebLogic Portal 9.2 Web applications, there is no work to be done. Any WebLogic Portal 9.2 Web application is automatically an Adrenaline portlet producer. Any portlet deployed within WebLogic Portal 9.2 can instantly be consumed using the three techniques above without any configuration or additional work. Customers deploying portlets on WebLogic Portal 8.1 will need to upgrade to version 9.2 to take advantage of this capability.
For WebLogic Server customers that are not currently building portlets on WebLogic Portal, it is a straightforward effort to take advantage of Adrenaline. The appendix contains a small set of steps to add Adrenaline to any WebLogic Server 9.2 Web application. However, note that there are three major prerequisites for building an Adrenaline portlet producer Web application:
Downloading WebLogic Platform 9.2 provides WebLogic Server and a development license for WebLogic Portal. To configure the Adrenaline libraries, it is easiest to use WebLogic Workshop for WebLogic Platform following the steps in Appendix A of this article.
Adrenaline will work with almost any portlet developed and deployed within WebLogic Portal 9.2. No special steps need to be taken to make a portlet Adrenaline compatible. However, several specific issues can affect the usability of a portlet through Adrenaline.
The IFrame technique could be accomplished without Adrenaline portlets; IFrames can consume any HTML source. You could add an IFrame to a legacy application that consumes www.bea.com, for example. In a similar way, using an Ajax toolkit, you can replicate the Ajax Snippet technique without Adrenaline. If this is true, why should you use Adrenaline portlets on the producer side?
What follows are the primary reasons for developing portlets on the producer side instead of plain Web applications:
Inter-Portlet Communication (IPC) allows for one portlet to communicate with another portlet within a portal. In some cases, this feature is used by portlet writers to allow multiple portlets to collaborate. The Master-Detail pattern formalizes this idea by defining a Master portlet and a Detail portlet that appear on a single portal page. The Master portlet usually contains a list of topics, that when one is clicked, causes the Detail portlet to update and display the clicked content.
Because Adrenaline surfaces a single portlet on a consumer Web page, the Master-Detail pattern is not supported. Portlets that rely on IPC therefore should not be consumed using Adrenaline.
When using any of the consumer techniques, it is always possible for the consumer and producer to be in the same Web application. For the
portalFacet tag, this is actually required. There is an advantage with deploying in this manner. In this configuration, if a user authenticates with either the consumer Web page or the producer portlet, the authentication is automatically shared. This is due to the fact that the user is operating entirely within the boundaries of a single Web application.
When using the IFrame Consumer or Ajax Consumer techniques, it is common for the consumer and producer to be part of different Web applications. While this is a flexible approach, it is important to understand how this configuration affects authentication. Because the consumer and producer are in different Web applications, by default authentication will not be shared. Therefore, the user will be required to authenticate twice—once with the consumer and once with the producer.
Adrenaline is not the first portlet technology to allow consumers to surface remote producer portlets. A standard called Web Service for Remote portlets (WSRP) already exists to provide exactly this capability. WebLogic Portal contains the industry-leading implementation of WSRP, and continues to enhance its implementation. WSRP is an advanced technology that contains many features useful for creating federated portals. Features such as shared authenticated, inter-portlet communication, and interceptors make the WebLogic Portal WSRP solution very powerful.
BEA recommends WSRP as the primary portlet federation technology. However, in cases where WSRP is not available on the consumer side, Adrenaline is a great substitute. Fortunately, with WebLogic Portal, the same portlet can be deployed once on the producer, and then can be surfaced to some consumers using Adrenaline and others with WSRP. In this way, Adrenaline and WSRP are complementary, not competing technologies.
Adrenaline dramatically expands the reach and flexibility of portlet technology. Adrenaline can breathe life into legacy applications, and promotes the reuse of portlet user interface components throughout the enterprise. For WebLogic Portal customers, this new technology comes for free and enhances the return on existing investment in portlet development. For all others, Adrenaline offers a compelling reason to adopt WebLogic portlet technology.
This appendix describes the list of steps to add Adrenaline to a WebLogic Server Web application. You must add certain WebLogic Portal components to the Web application using Workshop for WebLogic Platform 9.2, following these steps:
Enterprise Application Projectif one is not already created. File->New->Project...
Dynamic Web Projectif one is not already created. File->New->Project...
Portal Framework Strutsfacets.
Portal Customizations Frameworkfacets.
To create a sample portlet to use within a WebLogic Server Web application, follow these steps in Workshop for WebLogic Platform 9.2:
WebContentfolder in the Web Project.
portlets, and then click Finish.
sample, and then click Finish.
sample.jspin the Navigator pane.
sample, and then click Finish.
JSP/HTML, and then click Next.
sample.portletfile will be created.
Peter Laird is the Managing Architect of the WebLogic Portal product.