Creating a Portlet from a JSF Application with WebCenter
Pass the portlet, dear
A portal is a web application that aggregates a collection of web applications (portlets) running on a page in separate windows. A portlet is a web component (application) that runs in a portlet container, processes requests and generates dynamic content.
Portlets are the pluggable user interface components in a portal page. Portlets facilitate the development of SOA (Service Oriented Architecture) based applications. The different portlets in a portal page may obtain data from different data sources. Java Portlet Specification (JPS), based on Java Specification Request (JSR 168), and Web Services for Remote Portlets (WSRP) are standards for developing and consuming portlets.
Oracle WebCenter Suite is the newest component of the Oracle Fusion Middleware. Oracle WebCenter Suite, based on SOA, provides a unified environment in which a user may access different enterprise applications and services. JDeveloper 10.1.3.2 includes a WebCenter Framework pre-configured OC4J using the WebCenter extension for JDeveloper. The WebCenter pre-configured OC4J provides a JSR 168 portlet container for developing WSRP 1.0/WSRP 2.0 standards based portlets. Portlet applications may be developed in JDeveloper and deployed to the WebCenter Framework. Subsequently, the portlet may be consumed in a WebCenter application by registering a WSRP producer with the application. In this article we shall develop an example JSF portlet based on the JSR 168 and WSRP 2.0 standards and run the portlet in the WebCenter Framework.
Setting the Environment
Install JDeveloper 10.1.3.2 Studio Edition. We shall create a JSF DataTable based portlet. We shall use the Oracle database as the datasource for the JSF portlet. Install Oracle 10g database including the Oracle database instance ORCL and the sample schemas. Create an example database table CATALOG in the OE schema from SQL *Plus with SQL script catalog.sql, in the Resources zip file.
Creating a JSF Portlet
The example JSF application that is to be portelized consists of a DataTable that is generated dynamically using an SQL query. First, create a JDeveloper application with WebCenter Application as the application template. The WebCenter application consists of the Portlets project for creating portlets and the ViewController project for creating JSF view pages in which portlets may be embedded. Add the library for the JSF-Portlet Bridge to the Portlets project.
Next, create a JSF application to be portelized and deployed in the WebCenter Framework enabled OC4J with File>New>Web Tier>JSF. Select Automatically Expose UI Components in a new Managed Bean, specify a class name (
portlet.xml to the Portlets project with File>New>General>Deployment Descriptors>portlet.xml. In the Component Palette select JSF HTML and add a Output Label, an Input Text, a Command Button and a Data Table to the JSF page
The JSF portlets application files are available in the in the Resources zip file. Next, configure a JDBC connection with the Oracle database. Select the Connections view, right-click on the Database node and select New Database Connection. Next, create a deployment profile, webapp1, for the JSF portlet application with a J2EE Web Context Root of
Deploying the JSF Portlet
Next, deploy the JSF portlet to the OC4J that is pre-configured with the WebCenter Framework. Start the WebCenter Preconfigured OC4J with Tools>Start WebCenter Preconfigured OC4J. Configure a connection with the WebCenter Preconfigured OC4J. In the Create Application Server Connection Wizard specify connection name (LocalOC4J), connection type as Standalone OC4J 10g 10.1.3, username as
oc4jadmin, password as welcome, host name as localhost, and RMI Port as 22667. Next, deploy the WAR deployment profile that was created from the JSP portlet application to the WebCenter Preconfigured OC4J. Right-click on webapp1.deploy and select Deploy to>LocalOC4J. The WSDLs for the WSRP application get created.
Registering a Portlet as a WSRP Producer
WSRP defines a set of interfaces that standardize interactions with portlet components that generate markup to be consumed in a user application. Before consuming a portlet in a WebCenter application page, a WSRP Producer for the portlet is required to be registered with the application. The WebCenter Framework provides a WSRP Producer Registration wizard to register a WSRP 1.0/WSRP 2.0 Producer for a portlet with an application. A WSDL is required to register WSRP Producer with an application. The WSDL URLs may be obtained from URL
http://localhost:6688/portletsApp/info, port 6688 being the HTTP port.
Next, register a WSRP Producer for the JSF portlet with the WebCenter application. Select the ViewController project and select File>New. In the New Gallery wizard select Web Tier>Portlets. Select WSRP Producer Registration and click on OK. In the WSRP Portlet Producer Registration Wizard specify a name for the WSRP Producer and click on Next. Obtain the WSDL URL for the JSF portlet application from the WSRP Producer Test Page and specify the URL in the URL Endpoint field.
Specify the default execution timeout fro the producer and click on Finish. The WSRP Portlet Producer gets registered with the WebCenter application.
Adding a Portlet to a JSF Page
Portlets registered with a WebCenter application using a WSRP Portlet Producer become available in the Component palette just like any other JSF component. In this section the JSF portlet is added to a JSF page. Add a .jspx JSF page to the ViewController project. In the Tag Libraries window select the ADF Portlet Components library, which is required to add portlets to a JSF page. Next, add the JSF portlet that was generated earlier to the JSF page. Position the cursor in the
PortletsPage.jspx page and select WsrpPortletProducer1 in the Component Palette and select the DataTable Portlet. The DataTable Portlet gets added to the JSF page just like any other JSF component would. Run the WebCenter application JSF page.
The JSF DataTable portlet gets displayed. Specify a SQL query statement in the SQL input field and click on the Create Data Table button – see Figure 7.
Finally, a Data Table gets displayed; with the Oracle database as the datasource for the Data Table – see Figure 8.®
Sponsored: 2016 Cyberthreat defense report