Code reuse is a common practice in application development, but as an application developer, you may want to reuse a complete application—or an Oracle Application Development Framework (Oracle ADF) task flow—with a portal or another application. (An Oracle ADF task flow is a reusable Web component that encapsulates a set of activities and enables a user to complete a task. The task can be something as simple as displaying the current weather based on the user’s zip code or entering hours worked during a week on a time card.)
Oracle JDeveloper 11g (18.104.22.168.x) enables you to create applications and Oracle ADF task flows. Oracle WebCenter Framework extends Oracle ADF and contains a feature called the Oracle JSF [JavaServer Faces] portlet bridge that can turn an application or an Oracle ADF task flow into a portlet, which can then be consumed by a portal or an application.
For example, consider a scenario in which your team has designed and built an application that tracks time reporting from contractors in the IT department, including a time card Oracle ADF task flow that enables employees to submit their weekly work hours. Now other departments in your organization have begun to require employees to submit weekly time cards as well and have asked you to design a time card application for them. Your organization already uses an intranet portal in which all the employees track their vacation time, so you want to incorporate the time card application into this portal.
Using the Oracle JSF portlet bridge feature in Oracle WebCenter Framework, you can quickly address the time card application request by taking the time card Oracle ADF task flow your team designed and turning it into a portlet, which can then be consumed by your company’s intranet portal for the rest of your organization to use.
The Oracle JSF portlet bridge is based on the JSR 301 standard. This specification enables you to take existing JSF applications and Oracle ADF task flows and turn them into JSR 168-standard-based portlets, which you can then deploy through Web Services for Remote Portlets (WSRP). The portlets can be consumed by any application that can handle WSRP, such as an Oracle WebCenter application or Oracle Portal.
This article describes how to use Oracle WebCenter Framework’s Oracle JSF portlet bridge to turn an Oracle ADF task flow into a portlet and incorporate it into an Oracle WebCenter application. At the end of the article, you can even reuse the sample portlet with your own application or portal.Step 1: Setting Up
To begin working with this article’s applications, ensure that you are using the latest version of Oracle JDeveloper 11g and the Oracle WebCenter Framework extension. If you aren’t sure whether you have the Oracle WebCenter Framework extension, check by opening Oracle JDeveloper, then choosing Help -> About from the main menu, and clicking the Extensions tab. In the Extensions list, sort by Identifier to locate the oracle.webcenter.* components. If you do not see these components, download and install the Oracle WebCenter extension, by choosing Help -> Check for Updates . In Step 2 of the Check for Updates wizard, leave Search Update Centers selected and click Next . On the Updates page, scroll down, select Oracle WebCenter Framework . . . , and then click Finish . (You’ll need to restart Oracle JDeveloper to complete the installation process.)
Next, download this article’s applications. The download includes an application containing a sample Oracle ADF task flow—SimpleWeatherApplication—the sample JavaServer Pages (JSPs), and images the Oracle ADF task flow calls, and it also includes a second basic application—WeatherPortletConsumerApp—that will consume the portlet.
Extract the files in the o59webcenter.zip file to a temporary directory, such as C:\temp. Then extract the Simple WeatherApplication.zip file from the temporary directory into the directory where you maintain all your applications, such as C:\JDeveloper\mywork. Extract the WeatherPortletConsumerApp.zip file into the same directory. Your working directory should now contain two folders: SimpleWeatherApplication and WeatherPortletConsumerApp.Step 2: Checking the Assets
The Simple Weather Application was built with the Oracle Fusion Web Application template and contains a basic Oracle ADF task flow. This task flow displays information about the weather, based on the zip code (using the zipcode input parameter). Let’s take a look at the Simple Weather Application.
1. In Oracle JDeveloper, open the WeatherTaskFlowApplication.jws workspace file (located in your SimpleWeatherApplication folder).
2. Under ViewController -> Web Content , right-click the weather Consumer.jspx page and then choose Run . The page containing the Oracle ADF task flow appears in your browser, as shown in Figure 1. This is the Oracle ADF task flow rendered as an Oracle ADF table.
|Figure 1: Running the Simple Weather Application|
3. In your browser, view the contents of the weather.jsp file. In the Location field, enter the following URL:
4. This JSP file renders simple comma-separated values (CSV) data containing sample weather information, including the day of the week; sample temperatures; and basic weather images, such as rainy, sunny, and partly sunny weather. Listing 1 shows sample CSV data.
5. Click the weatherConsumer.jspx tab, or double-click the name in the Application Navigator (under ViewController -> Web Content ). The page displays an Oracle ADF task flow, weather-task-flow, as an Oracle ADF read-only table (shown in Figure 2). The task flow is based on weather.jsp.
|Figure 2: Oracle ADF read-only table in weatherConsumer.jspx|
Now let’s turn the Oracle ADF task flow into a JSR 168-standard-based portlet.
1. In the Application Navigator, in the Simple Weather Application, open the ViewController project and then navigate to Web Content -> Page Flows and locate the weather-task-flow file.
2. Right-click weather-task-flow , and choose Create Portlet Entry , as shown in Figure 3.
|Figure 3: Choosing Create Portlet Entry|
3. In the Create Portlet Entry dialog box, name the portlet something descriptive, such as WeatherTaskFlowPortlet , as shown in Figure 4.
|Figure 4: Entering portlet information|
4. Click OK .
The Oracle JSF portlet bridge generates all the necessary portlet files, including the web.xml file, which you’ll use to create the deployment profile, and the portlet.xml file, which contains the portlet entry information.
Now that you’ve turned the Oracle ADF task flow into a portlet, you can deploy the application containing this portlet to a portlet container.Step 4: Creating a Deployment Profile
Because the Oracle JSF portlet bridge turned the task flow into a JSR 168-standard-based portlet, you’ll need to deploy the portlet to a Web Archive (WAR) file.
1. In the Application Navigator, navigate to ViewController -> Web Content -> WEB-INF , right-click the web.xml file that was generated, and choose Create WAR Deployment Profile .
2. In the Create Deployment Profile - WAR File dialog box, enter a name, such as WeatherPortletApplication , as shown in Figure 5.
|Figure 5: Create Deployment Profile - WAR File dialog box|
3. Click OK .
4. In the Edit WAR Deployment Profile Properties dialog box, select Specify Java EE Context Root and enter a name that’s easy for you to remember, such as the name you entered for the WAR file, WeatherPortletApplication , as shown in Figure 6.
|Figure 6: The Edit WAR Deployment Profile Properties dialog box|
5. Click OK .
6. On the Project Properties page, click OK to finish creating the profile.Step 5: Deploying the Portlet to the Integrated Oracle WebLogic Server
Once you have a portlet and a deployment profile, you can deploy the portlet to a portlet container. In this example, you’ll use the Oracle portlet container, which is included with the integrated Oracle WebLogic Server in Oracle WebCenter.
You started the integrated Oracle WebLogic Server when you ran weather Consumer.jspx, so you do not need to run it again. If you’ve stopped the server, you can restart it by choosing Run -> Start Server Instance from the main menu.
1. In the Application Navigator, right-click the ViewController project in the Simple Weather Application and then choose Deploy -> WeatherPortlet Application -> to -> IntegratedWLS Connection , as shown in Figure 7.
|Figure 7: Deploying the portlet|
2. You’ll see in the deployment log that Oracle JDeveloper is building and compiling your portlet. If the Select Deployment Type dialog box appears, click OK .
3. In the Deployment Configuration dialog box, choose WeatherConn and then click Deploy . This connection is built into the sample application and points to the URL service for the data control on which the Oracle ADF task flow is based.
4. In the deployment log, you’ll see messages indicating that Oracle WebCenter is deploying the application. Check for the “Deployment finished” message.
5. Now confirm that the application page is still working (to verify that the application still works in the deployed environment). To do so, in the Application Navigator, under ViewController -> Web Content , open weatherConsumer.jspx and run it. The page should appear as it did when you first looked at it in Step 2.
6. Now confirm that the portlet producer test page appears. In your browser, enter http://localhost:7101/weather/info (the test page URL). You should see the WSRP Producer Test Page containing your portlet, as shown in Figure 8.
|Figure 8: WSRP Producer Test Page|
At this point, you’ve successfully turned an Oracle ADF task flow into a JSR 168-standard-based portlet and deployed it to a portlet container.Step 6: Registering Your New WSRP Producer with an Application
Now that you have a deployed portlet producer, you can register it with any application that can handle WSRP 2.0 portlet producers. In this case, we’ll use an empty application that was provided in the sample application files. (This simple JSF application was created with the Oracle WebCenter application template.)
1. In the Application Navigator, choose WeatherPortletConsumerApp from the list.
2. In ViewController -> Web Content , open the WeatherPortletConsumer Page.jspx page. This is a blank JSF page.
3. In the Resource Palette, click the folder icon and choose New Connection -> WSRP Producer .
4. In the Producer Registration Name field, enter WeatherPortletProducer , and click Next .
5. In the WSDL URL field, enter the URL for the portlet producer— http://localhost:7101/WeatherPortletApp/portlets/wsrp2?WSDL —as shown in Figure 9.
|Figure 9: Registering the WRSP portlet producer|
6. Click Next .
7. Click Finish . You’ll see the new portlet producer under IDE Connections .
8. Now that you’ve registered the WSRP producer with the WeatherPortlet ConsumerApp application, add the portlet, which was once an Oracle ADF task flow, to the WeatherPortlet ConsumerPage.jspx page. Drag and drop WeatherTaskFlowPortlet (from Resource Palette -> IDE Connections -> WSRP Producer -> WeatherPortlet Producer -> WeatherTaskFlowPortlet ) onto the page.
9. Run the WeatherPortletConsumer Page.jspx page in the browser (right-click WeatherPortletConsumerPage.jspx , and select Run ). You should now see your WeatherTaskFlowPortlet portlet on your WeatherPortletConsumerPage.jspx page.
Congratulations! You’ve turned an Oracle ADF task flow in a JSF application into a portlet and consumed it in another JSF application.Conclusion
In this article, you’ve learned how to take an Oracle ADF task flow, turn it into a JSR 168-standard-based portlet, and deploy it to a portlet container. You’ve also learned how to register the WSRP producer with an Oracle WebCenter application built with the Oracle WebCenter Framework and to use the portlet with the application. And you can now register that WSRP producer with any other application capable of handling WSRP and continue to use the portlet.
DOWNLOAD sample applications for this article
Photography byRicardo Gomez Angel,Unsplash