Oracle® Webcenter Framework: Tutorial 10G (10.1.3.2.0)
Oracle® Webcenter Framework: Tutorial 10G (10.1.3.2.0)
Oracle® Webcenter Framework: Tutorial 10G (10.1.3.2.0)
Tutorial
10g (10.1.3.2.0)
B31072-02
March 2007
Oracle WebCenter Framework Tutorial, 10g (10.1.3.2.0)
B31072-02
The Programs (which include both the software and documentation) contain proprietary information; they
are provided under a license agreement containing restrictions on use and disclosure and are also protected
by copyright, patent, and other intellectual and industrial property laws. Reverse engineering, disassembly,
or decompilation of the Programs, except to the extent required to obtain interoperability with other
independently created software or as specified by law, is prohibited.
The information contained in this document is subject to change without notice. If you find any problems in
the documentation, please report them to us in writing. This document is not warranted to be error-free.
Except as may be expressly permitted in your license agreement for these Programs, no part of these
Programs may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any
purpose.
If the Programs are delivered to the United States Government or anyone licensing or using the Programs on
behalf of the United States Government, the following notice is applicable:
U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data
delivered to U.S. Government customers are "commercial computer software" or "commercial technical data"
pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As
such, use, duplication, disclosure, modification, and adaptation of the Programs, including documentation
and technical data, shall be subject to the licensing restrictions set forth in the applicable Oracle license
agreement, and, to the extent applicable, the additional rights set forth in FAR 52.227-19, Commercial
Computer Software--Restricted Rights (June 1987). Oracle USA, Inc., 500 Oracle Parkway, Redwood City, CA
94065.
The Programs are not intended for use in any nuclear, aviation, mass transit, medical, or other inherently
dangerous applications. It shall be the licensee's responsibility to take all appropriate fail-safe, backup,
redundancy and other measures to ensure the safe use of such applications if the Programs are used for such
purposes, and we disclaim liability for any damages caused by such use of the Programs.
Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective owners.
The Programs may provide links to Web sites and access to content, products, and services from third
parties. Oracle is not responsible for the availability of, or any content provided on, third-party Web sites.
You bear all risks associated with the use of such content. If you choose to purchase any products or services
from a third party, the relationship is directly between you and the third party. Oracle is not responsible for:
(a) the quality of third-party products or services; or (b) fulfilling any of the terms of the agreement with the
third party, including delivery of products or services and warranty obligations related to purchased
products or services. Oracle is not responsible for any loss or damage of any sort that you may incur from
dealing with any third party.
Contents
2 Getting Started
Downloading Oracle JDeveloper With WebCenter Extensions...................................................... 2-1
Downloading Sample Tutorial Files..................................................................................................... 2-1
Copying the Sample system-jazn-data.xml File................................................................................. 2-2
iii
Step 6: Testing the Portlet .................................................................................................................... 3-22
Step 7: Adding Some Simple Logic to the Portlet........................................................................... 3-26
8 Providing Security
Introduction............................................................................................................................................... 8-1
Prerequisites.............................................................................................................................................. 8-2
Step 1: Creating a Login Page................................................................................................................. 8-2
Step 2: Configuring ADF Security Settings ........................................................................................ 8-5
iv
Step 3: Creating a Welcome Page........................................................................................................ 8-10
Step 4: Securing Pages .......................................................................................................................... 8-22
Step 5: Mapping Security Roles in orion-web.xml......................................................................... 8-25
Step 6: Demonstrating the Security Features ................................................................................... 8-30
Login as User Singh ........................................................................................................................ 8-30
Login as User Cho ........................................................................................................................... 8-32
Login as User Harvey ..................................................................................................................... 8-33
Login as User King.......................................................................................................................... 8-34
Try to Access a Secured Page Directly ......................................................................................... 8-34
Enter Invalid Credentials ............................................................................................................... 8-35
Step 7: Authorizing Access to Your Data Controls ......................................................................... 8-35
Index
v
vi
Preface
This tutorial introduces you to Oracle WebCenter Framework, one of the key
components of Oracle WebCenter Suite. As you work through this tutorial, you'll
become familiar with Oracle JDeveloper and the components that have been added to
support the new Oracle WebCenter Framework functionality. When you're ready to
begin building your own application, you can move on to the Oracle WebCenter
Framework Developer's Guide for assistance.
Audience
This tutorial does not assume any prior knowledge of Oracle JDeveloper or Oracle
WebCenter Suite. It does, however, assume that you are already somewhat familiar
with the following:
■ Oracle Application Development Framework (Oracle ADF) (Purpose and basic
architecture)
■ Oracle ADF Faces
■ Java
The tutorial is intended for the developer who wants to build a WebCenter
application, or the application developer who wants to use Oracle ADF to build
customization capabilities into their application.
Documentation Accessibility
Our goal is to make Oracle products, services, and supporting documentation
accessible, with good usability, to the disabled community. To that end, our
documentation includes features that make information available to users of assistive
technology. This documentation is available in HTML format, and contains markup to
facilitate access by the disabled community. Accessibility standards will continue to
evolve over time, and Oracle is actively engaged with other market-leading
technology vendors to address technical obstacles so that our documentation can be
vii
accessible to all of our customers. For more information, visit the Oracle Accessibility
Program Web site at
http://www.oracle.com/accessibility/
Related Documents
For more information on Oracle WebCenter Framework, see the following documents:
■ Oracle WebCenter Framework Developer's Guide
■ Oracle WebCenter Framework Error Messages Guide
For more information on Application Development Framework, see the following
documents, both of which are available on Oracle Technology Network (OTN) at
http://www.oracle.com/technology/index.html:
■ Oracle Application Development Framework: Tutorial
■ Oracle Application Development Framework: Developer's Guide
Conventions
The following text conventions are used in this document:
Convention Meaning
boldface Boldface type indicates graphical user interface elements associated
with an action, or terms defined in text or the glossary.
italic Italic type indicates book titles, emphasis, or placeholder variables for
which you supply particular values.
monospace Monospace type indicates commands within a paragraph, URLs, code
in examples, text that appears on the screen, or text that you enter.
viii
Part I
Introducing WebCenter Framework Tutorial
This chapter introduces you to Oracle WebCenter Suite and helps you understand how
you can use it to enhance your service-oriented applications. With Oracle WebCenter
Suite, you get services that you can integrate with your application to afford your
users improved communication, content management capabilities, customization, and
advanced search support. More important, you get a development framework that
provides essential capabilities, such as the ability to consume portlets and content in a
Java Server Faces application, declarative security, and life-cycle management tools.
In this chapter, you will discover answers to these key questions:
■ What is Oracle WebCenter Suite?
■ What Will You Learn in this Tutorial?
After you read this chapter, you'll be ready to start building your own Java EE 5
application.
In this example, a user who is new to the company is working with an application that
allows him to add dependents to his company insurance policy. Notice that the
transaction itself is surrounded by additional context that helps the user, including:
■ New Hires Tasks, in the upper left corner, provide an activity guide that shows
where the user is in the larger process of becoming acclimated to his new
company. The user's next task is also identified. This type of process orchestration
helps the user step through the entire multi-step flow quickly and easily.
■ Task and process analytics let users know where they are in the process and how
decisions are impacting them. In this case, the Task Analytics on the right show the
total cost impact of the benefit choices made so far.
■ The Help Center on the bottom left provides an up to date FAQ for quick access to
typical questions and a direct chat link to the help center where the user can ask
additional questions not addressed by the FAQ. Again, no need for the user to
leave the context of the transaction to get help.
■ Knowledge Exchange, on the bottom right, provides documentation relevant to
the current task. These documents, stored in the corporate repository, give detailed
advice on the different beneficiary and dependent scenarios applicable to the user.
Until Oracle WebCenter Suite, building this kind of application was a rather tedious
process. To gain access to the beneficiary scenarios, for example, used to involve
creating a portlet to gain a view into the Java Content Repository (JSR 170)—if the API
required to do so was available. Oracle WebCenter Suite reduces the front-end labor
historically required to bring necessary business components to the user by
capitalizing on the notion of Service Oriented Architecture (SOA). Thanks to Oracle
WebCenter Suite's commitment to SOA, as well as to the Java Content Repository (JSR
170) and other industry standards, you get a wide range of plug-and-play products,
tools, and services that make it easy to build the applications your users need.
Figure 1–2 shows what Oracle WebCenter Suite provides1:
1
Some components shown are not available in the initial release of Oracle WebCenter Suite:
Presence/IM, Discussions, and Wiki. In this chapter, we describe components relevant to this
release of Oracle WebCenter Framework.
WebCenter Framework
WebCenter Framework augments the Java Server Faces (JSF) environment by
providing additional integration and runtime customization options. In essence, it
integrates capabilities historically included in portal products directly into the "fabric"
of the JSF environment. This eliminates artificial barriers for the user and provides the
foundation for developing the kinds of context-rich applications depicted in
Figure 1–1.
page for user consumption. Once you do so, the portlet becomes available through
JDeveloper's Component Palette for others to use in their applications.
■ Web Clipping: An extremely easy-to-use wizard that requires no technical
expertise whatsoever. Users simply locate the Web content they want to "clip",
then use the wizard to grab it and display it within their application. If the Web
content on the original site is updated, so is the user's associated Web Clipping.
■ Rich Text portlet: A tool that allows users to publish their own announcements
and broadcasts. When you place a Rich Text portlet on a page, during run time,
authorized users can access all the rich-text editing tools needed to insert, update,
and format display text.
Customizable Components
WebCenter Framework provides new JSF components that allow developers to make
any of their applications customizable. These new components act as containers into
which developers can drop another Faces view component or a portlet. With these
capabilities in place, administrators can customize virtually any JSF page by
minimizing/maximizing, hiding/showing, or moving any component on the page.
Content Integration
Suppose you have data in a content management system such as Oracle Content DB,
OracleAS Portal—or even on your file system—that you want to make available to
your application. WebCenter Framework provides you with the JCR adapters you
need to access that content. Using JDeveloper, you can then build JCR data controls to
grab the content and drop it onto your page in a variety of display modes. WebCenter
Framework also comes with Oracle Drive, through which you can represent the
contents of your OracleAS Portal repository as a tree-like structure, right on your
desktop.
WebCenter Services
WebCenter Services offer a variety of content management, search, and
communication services, including:
■ Oracle Content Database (Oracle Content DB), the default content repository for
Oracle WebCenter Services. Oracle Content DB is a full-fledged content
management system that enables users to manage content through the Web or
from desktop applications. A rich library of ready-to-use Web services is provided
to content-enable your enterprise in a service-oriented environment. With Oracle
Content DB, you can:
– Improve the productivity of individuals and teams with secure access to the
right content in the context of business processes
– Reduce risk associated with content, including information loss and legal
discovery
– Facilitate adaptability of business processes
– Reduce IT and administrative costs through content consolidation
Oracle Content DB bridges the gap between limited capability file servers and the
specialized, expensive, and complex content management applications that are so
widely available.
■ Oracle Secure Enterprise Search is a crawler-based service that can search a
multitude of sources, structured and unstructured, in a variety of file formats,
indexed or real-time. With Oracle Secure Enterprise Search, you can reduce the
time spent finding relevant documents on your company's information
repositories.
■ Communication Services, which help you better connect people and facilitate
communication. These services include:
– Instant Messaging: Lets users freely exchange ideas through audio and video
feeds, file exchange, and a range of other capabilities.
– Presence Server: Presence provides information about a person's availability to
every person or application that subscribes to that person's status. Chats and
other real-time services can be initiated from the associated user interface.
– Discussion forum: An interactive message board for sharing information,
questions, and comments.
■ Wiki is server software that allows users to freely edit and create Web page content
using a Web browser. This ease of interaction and operation makes Wiki an
effective tool for collaborative communication.
Oracle JDeveloper
Oracle JDeveloper is an integrated development environment (IDE) for building
service oriented applications using the latest industry standards for Java, XML, Web
services, and SQL. Oracle JDeveloper supports the complete software development life
cycle, with integrated features for modeling, coding, debugging, testing, profiling,
tuning, and deploying applications. Oracle JDeveloper's visual and declarative
approach and the Oracle Application Development Framework(ADF) work together
to simplify application development and to reduce mundane coding tasks. For
example, code for many standard user interface widgets, such as buttons, list of
values, and navigation bars, are pre-packaged for you. All you have to do is select the
appropriate widget from the Component Palette and drop it into your application.
As you work through this tutorial, you will become more familiar with Oracle
JDeveloper and the advantages it offers. For more information about Oracle
JDeveloper, access one of the many educational aids from the Oracle JDeveloper Start
Page (Figure 1–3), accessible from Oracle JDeveloper's Help menu.
■ MyPage, upon which you will place a Java portlet, the Rich Text portlet, and
images from your file system.
■ MyContent, upon which you will publish content from your file system.
■ MyWeather, through which you will learn how to use OmniPortlet and the
Parameter Form Portlet, and how to enable communication between the two.
The logical flow between the pages is illustrated in the following graphic (Figure 1–4):
Note that you will not develop these pages in the order they are presented in the
graphic. Rather, you will start with a very basic page, MyPage, then move gradually
from there into more complex topics.
This tutorial is designed for the chapters to be completed in the same sequence as they
are presented. Due to dependencies, completing them in a different order may result in
missing resources or even errors. The path through this tutorial is as follows:
■ Chapter 2, "Getting Started" tells you what you need to do before you can
complete the steps in this tutorial. Be sure to complete all the steps described in
this chapter.
■ Chapter 3, "Building and Testing Your First Portlet" shows you how to build a
basic page, MyPage, add a simple portlet, then enhance the portlet to embrace
more sophisticated logic.
■ Chapter 4, "Customizing Your Page" introduces you to the means by which you
enable customization for your application. In this lesson, you'll continue to work
with MyPage.
■ Chapter 5, "Adding the Rich Text Portlet" shows you how to place the Rich Text
portlet on MyPage.
■ In Chapter 6, "Making Portlets Communicate", you'll create a new page,
MyWeather, and add a Parameter Form Portlet and OmniPortlet to it. You'll also
learn how to set up parameters between the two portlets to enable simple
communication.
■ Chapter 7, "Adding Content to Your Page" shows you how to add content from
your file system onto a page called MyContent. You'll also learn how to add a
search form to the page.
■ In Chapter 8, "Providing Security", you'll learn how to implement security by
creating a Welcome page and a Login page. Only privileged users will have access
to MyPage, MyWeather, MyContent, and secure content on the Welcome page.
■ Chapter 9, "Deploying Your WebCenter Application" will show you the steps
involved in deploying your sample application.
If you've never used JDeveloper before, by the end of this tutorial you should have a
fairly solid grasp of the fundamental purpose and capability of the tool. Of course,
JDeveloper, as well as the framework it rests upon, ADF, both offer tremendous
powers that are only briefly explored in this tutorial. You will no doubt want to learn
more about both products before you begin developing in earnest. Here are two
excellent resources, both available on Oracle Technology Network,
http://www.oracle.com/technology/:
■ Application Development Framework Tutorial
■ Application Development Framework Developer's Guide
Let's get started!
This chapter tells you how to download the correct version of Oracle JDeveloper and
some files you'll need to complete the lessons in this tutorial.
4. Make a note of the location where the sample content is now stored, as you'll need
to access it occasionally as you work through the tutorial.
Next, set up some user data required to complete Chapter 8, "Providing Security".
You're now ready to move to your first lesson, Step 1: Using the JSR 168 Java Portlet
Wizard in Chapter 3, "Building and Testing Your First Portlet".
In this lesson you will learn how to build your first portlet. After you create the
portlet, you will test it, create a simple page, drop the portlet on the page, test it again,
then add some additional logic to the portlet. By the end of this lesson, you should
have a good handle on what's involved with building and testing a simple portlet.
Figure 3–1 shows a conceptual picture of what you'll have at the end of this lesson: a
WebCenter application named MySample containing a page called MyPage
(MyPage.jspx). You'll also create a portlet called MyJavaPortlet, which you'll place
upon MyPage and then customize.
Introduction
We will build a portlet and test it in the following steps:
■ Step 1: Using the JSR 168 Java Portlet Wizard
■ Step 2: Setting Up Your Connection
■ Step 3: Deploying Your Portlet
■ Step 4: Creating a JSF Page
■ Step 5: Registering Your Portlet with Oracle WebCenter Framework
■ Step 6: Testing the Portlet
■ Step 7: Adding Some Simple Logic to the Portlet
The process will be roughly the same no matter what type of portlet you build using
JDeveloper.
9. Click OK.
In the Applications Navigator as shown in Figure 3–4, you can see that a
WebCenter application consists of three projects:
■ Model, in which you define the JavaBeans and other data controls you need if
the application is to perform any back-end logic.
■ Portlets, in which you'll create your portlet.
■ ViewController, in which you'll create the JavaServer Faces page that will
consume the portlet.
Now let's invoke the JSR 168 Java Portlet Wizard to create your portlet.
10. In the Applications Navigator, right-click Portlets, and select New.
11. In the Categories pane as shown in Figure 3–5, expand the Web Tier category, and
click Portlets.
The JSR 168 Java Portlet Wizard generates a skeleton for the portlet, to which you
add your own logic. Let's see how this is done.
13. Click Next to move beyond the Welcome page.
14. Leave the default specified on the Web Application page (Figure 3–7). The servlet
version makes certain tag libraries available. Because they are backward
compatible, it's always best to select the latest version, unless you have a specific
reason for selecting an older version.
16. On the General Portlet Properties page, change the Name and Class names to
MyJavaPortlet (no spaces) as shown in Figure 3–8.
It's usually a good idea to make the class name the same as the display name, so
the portlet that displays on the page has the same name as what appears in the
Applications Navigator.
20. On the Name and Attributes page, enter the values shown in Figure 3–9.
On the Content Types and Portlet Modes page, notice that text/html is the default
content type. That means that the portlet will support text encoded with HTML.
View and edit are listed as the default portlet modes for text/html. View is always
available as a portlet mode; edit mode provides a page that allows users to
personalize the portlet instance.
Later on in this tutorial we'll want to test the difference between Personalize and
Customize using this portlet. That means we need to enable customization for the
portlet now. We do that by adding the edit_defaults content type to the
portlet's configuration.
22. In the Content Types and Portlet Modes pane as shown in Figure 3–10, highlight
view, and click Add.
The Portlet Modes window is displayed.
23. Highlight edit_defaults, and use the arrow to move it to the Selected pane.
We're not going to do anything with this page now, but in the future you can use it
to add other customization options for the portlet. For example, if your portlet
accepted a Zip Code parameter, you might want to allow users to personalize the
Zip Code label. If this were the case, you would use the Add button to make the
Zip Code label personalizable.
27. Click Next.
Assuming that this is the first time you have started this OC4J, you will see a
message asking if you want to install the WebCenter Preconfigured OC4J.
2. Click Yes.
Wait for the message stating that the OC4J instance has initialized before you
proceed (see Figure 3–15).
When you first start the preconfigured OC4J, its readme file displays in the
JDeveloper Editor. This document describes how to start, stop, test, and connect to
the preconfigured OC4J, lists the port defaults, and provides some useful
troubleshooting tips. If you need to access this file in the future, select Help,
WebCenter Preconfigured OC4J Readme from the main JDeveloper menu.
The preconfigured OC4J has been installed on your computer, but you still have to
establish a connection to it (so JDeveloper knows where to find it).
3. Click Connections Navigator (next to the Applications Navigator).
4. Right-click the Connections node, and choose New Application Server
Connection as shown in Figure 3–16.
8. Click Next.
9. Enter oc4jadmin as the username, and the password welcome.
welcome is the default password for the WebCenter Preconfigured OC4J.
10. Select Deploy Password to forgo the requirement of a password each time the
connection is established (Figure 3–18).
5. Click OK.
6. In the Create Deployment Profile - WAR File dialog box(Figure 3–21), enter the
following:
7. Click OK.
8. In the WAR Deployment Profile Properties window, select Specify J2EE Web
Context Root, and then enter TutorialPortlets as shown in Figure 3–22.
9. Click OK.
10. In the Applications Navigator, expand the Resources node.
You should see the deployment profile TutorialPortlets.deploy as shown in
Figure 3–23.
Wait for the Deployment Finished message in the Deployment Log (bottom of the
JDeveloper window) to verify that the deployment succeeded.
Now let's run the portlet to make sure it's functioning properly.
13. Bring up a browser window, and enter this URL:
http://<host>:<port>/<context-root>/portlets/wsrp2?WSDL
where:
Parameter Value
host The host name you used to connect to the WebCenter
Preconfigured OC4J. Earlier in this lesson, we accepted the
default, localhost.
(If you chose to use your computer's IP address, rather than
localhost, enter this here instead.)
port The HTTP Listener port. For the WebCenter Preconfigured OC4J,
use 6688, the default port on which this preconfigured OC4J
listens.1
context-root TutorialPortlets, as established in step 8 in this lesson.
1
To change the port on which the preconfigured OC4J listens, go to
JDEVHOME\jdev\extensions\oracle.adfp.seededoc4j.10.1.3.2.0\j2ee\home\config\default-web-
site.xml and change the following entry: <web-site .... port="6688" ...>
So, for this tutorial the URL looks something like this:
http://localhost:6688/TutorialPortlets/portlets/wsrp2?WSDL
Make a note of this URL. You'll need it in Step 5: Registering Your Portlet with
Oracle WebCenter Framework.
14. In the browser, you should now see XML similar to that shown in Figure 3–24.
The portlet you just deployed has now been exposed as a Web service. What appears
in the browser is the Web Services Description Language (WSDL) that describes this
Web service. Assuming your WSDL looks something like Figure 3–24, the next step is
to create a JSF page that will consume the portlet.
7. Click Next.
8. We won't be adding any back-end logic to this page (at least, not in this lesson), so
we don't need a new managed bean. Leave the default setting as is (Do Not
Automatically Expose UI Components in a Managed Bean) as shown in
Figure 3–26.
Figure 3–26 Component Binding Page of the Create JSF JSP Wizard
9. Click Next.
10. On the Tag Libraries page, use the double arrows to move all the libraries from the
Available Libraries pane to the Selected Libraries pane. The following libraries
should be included:
■ ADF Faces Components 10_1_3_2_0
■ ADF Faces HTML 10_1_3_2_0
■ ADF Portlet Components 10_1_3_2_0
■ Customizable Components Core 10_1_3_2
■ JSF Core 1.0
■ JSF HTML 1.0
11. Click Next.
12. We don't need any special HTML options, so click Finish on the page shown in
Figure 3–27.
You should now be able to see the page as shown in Figure 3–28 you just created
in the Applications Navigator, under ViewController, Web Content, MyPage.jspx.
You should also see your page open in the Visual Editor, ready for us to begin
adding components.
Proxy information isn't necessary for this tutorial as you're using a local
preconfigured OC4J.
8. Click Next.
9. Click Next again to accept the default timeout value of 30 seconds.
10. Click Next to accept the default security settings.
The page now knows where to locate the portlet MyJavaPortlet and how to access it.
Let's verify to make sure.
2. On the far right side of the JDeveloper window, click the Component Palette
drop-down list as shown in Figure 3–34, and verify that TutorialProducer is listed
there.
3. Select TutorialProducer. You should see your portlet MyJavaPortlet listed there.
4. Select MyJavaPortlet, and drag it across to h:form, the last entry in the Structure
window. You want to make sure that the portlet is included IN the form, and the
Structure window makes it easy to do this.
You should now see something that looks like Figure 3–35.
You should be able to locate several newly generated files and folders in the
Applications Navigator. The expanded Navigator looks like Figure 3–36. These
internal files are created when consuming portlets of WSRP producers. You won't
need to edit any of these files.
9. Click OK.
The portlet is redisplayed in the browser, with the name you chose displayed in
the header.
We now know that this portlet is working properly, but it isn't very interesting.
Let's now add some logic so that users can paste HTML into a text box for the
portlet to render.
This code will retrieve the preferences set in Personalize or Customize mode and
display them in the portlet's View mode so that users can see them.
5. Click the Save icon in JDeveloper's toolbar.
6. Double-click edit.jsp to open it in the Visual Editor.
7. Click the Source tab.
8. Add the code as shown in Figure 3–41 to implement a form field called Content.
Here is the code to copy and paste:
<%
String[] str = {"Portlet Content"};
str = prefs.getValues("portletContent",str);
%>
<tr><td width="20%">
<p class="portlet-form-field" align="right"> Content</p>
</td><td width="80%">
<textarea rows="10" cols="60" class="portlet-form-input-field"
name="portletContent"><%
for (int i=0; i<str.length; i++)
{%><%= (i<str.length-1) ? str[i]+", " : str[i] %><%}%>
</textarea>
</td></tr>
You've edited the file that will store the changes made through Personalize mode,
but now you must make the same changes to the file that stores the changes made
through Customize mode—that is, edit_defaults.jsp.
11. Double-click edit_defaults.jsp, and add the same code in the same location. Don't
forget to click the Save icon when you are through.
MyJavaPortlet.java, the file containing the java code for this portlet, must now be
edited as well.
12. In the Applications Navigator, under Portlets, Application Sources, portlet, double
click MyJavaPortlet.java to open it in the Visual Editor's Source view.
13. Scroll down to the processAction method and locate the code line that says
//Save the preferences. Insert the following two lines of code (indicated in
bold):
// Save the preferences.
PortletPreferences prefs = request.getPreferences();
String param = request.getParameter(PORTLETTITLE_KEY);
prefs.setValues(PORTLETTITLE_KEY, buildValueArray(param));
String contentParam = request.getParameter("portletContent");
prefs.setValues("portletContent", buildValueArray(contentParam));
prefs.store();
14. Click the Save All icon to save your changes to view.jsp, edit.jsp, edit_defaults.jsp,
and MyJavaPortlet.java.
Because you've made some changes, you need to redeploy the portlet to your
preconfigured OC4J.
15. In the Applications Navigator, under Portlets, Resources, right-click
TutorialPortlets.deploy.
16. Click Deploy to MyLocalOC4J.
23. Copy and paste the following HTML text in the Content field as shown in
Figure 3–44.
<p>Read <em>The Path to Portlet Interoperability</em> by John Edwards in
<strong>Oracle Magazine</strong> - Nov-Dec 2005. </p>
<p>It discusses JSR 168 and WSRP open portals. </p>
If you want to remove the default text (Welcome, this is the view mode.), simply
double-click view.jsp, remove the final line of code, redeploy the portlet to your
preconfigured OC4J, then re-run the page.
In the next lesson, you'll add some additional content to your page in the form of
images.
In this lesson you will extend the page created in the previous lesson by adding
customizable components to the page and experimenting with ways to affect the
component's look and feel. Along the way you will test your page to confirm that your
page is developing the way you expect it to.
Figure 4–1 shows how the components on your page will be laid out once you
complete this lesson.
Introduction
We will customize the page by completing the following steps:
■ Step 1: Allowing Users To Customize the Page
■ Step 2: Running and Customizing the Page
■ Step 3: Making Additional Customizations
■ Step 4: Testing the New Customizations
■ Step 5: Changing the Look and Feel
Let's begin by examining some of the benefits that Oracle WebCenter Framework
provides.
Tip: When you drop a component inside a form, make sure that
h:form has a box around it.
Working with the Structure view provides greater certainty where a component is
being placed but you can also drag and drop components directly onto the Visual
Editor.
6. In the Component Palette, highlight ShowDetailFrame, and drag it to the
Structure window. Drop it over cust:panelCustomizable.
cust:showDetailFrame becomes a child of cust:panelCustomizable, as
shown in Figure 4–4.
In the Visual Editor (shown in Figure 4–5), you can see showDetailFrame1
within a grey box. The grey box indicates the cust:panelCustomizable, so we
know that we safely dropped showDetailFrame within it. The area that is
circled represents the control that users will use to customize the content of
showDetailFrame.
Tip: You can drag and drop images directly from your file system,
for example C:\TutorialContent\camera.gif, onto a
ShowDetailFrame component. An ObjectImage is created
automatically, and the image is copied to the project.
Let's add another image so you can see how users will be able to move the images
around the page.
14. In the Component Palette drop-down list, select Customizable Components Core,
and select ShowDetailFrame.
15. Drag ShowDetailFrame to the Structure window and drop it on
cust:panelCustomizable.
16. In the Component Palette drop-down list, select ADF Faces Core, and select
ObjectImage.
17. Drag ObjectImage to the Structure window. Drop it on top of the second
cust:showDetailFrame.
18. Use the ... button to locate hula.gif (see Downloading Sample Tutorial Files),
and click OK.
A dialog opens asking you if you want to locate the image under the document
root.
19. Choose Yes.
Each image has its own actions icon on the showDetailFrame header, so each
can be acted upon independently.
Now let's run the page and see what kind of customizations are possible.
Notice that MyJavaPortlet is unaffected by this action. That's because the portlet is
not part of this panelCustomizable.
4. Click the Actions menu, and then click Restore to return the image to its original
size.
5. On either of the images, click Move, Down or Move, Up to see the images switch
places on the page. Again, because MyJavaPortlet is not controlled by this
panelCustomizable, it remains stationary as the images trade places.
Figure 4–11 shows the browser after Move, Down was used on the first graphic,
the camera. The hula graphic is now on top of the camera graphic.
The portlet automatically goes to the bottom of the list of objects, and the Design
view follows suit. The portlet now appears beneath the second image.
Notice that we dropped the portlet directly onto cust:panelCustomizable
without inserting a showDetailFrame first. That's because the portlet comes
automatically equipped with the customization capabilities provided by the
portlet chrome; that is, the ability to maximize/minimize and to reposition the
portlet on the page.
Now let's choose a different orientation for the portlet and images. Rather than
displaying them vertically, let's display them horizontally.
3. In the Structure window, highlight cust:panelCustomizable.
4. In the Property Inspector, under General, click the field beside Layout.
The Property Inspector is to the right of your JDeveloper screen (Figure 4–13).
You can see in the Visual Editor that the portlets and images are now side by side,
rather than on top of one another as seen in Figure 4–15.
This displays a header area at the top of the layout so that there is room for the
Action icon to appear as part of the menu. (If for some reason you don't want to
display the header in your own applications, you can keep DisplayHeader set to
false. As long as you complete the next step, the menu actions for the component
are displayed by hovering over the panelCustomizable area.)
7. In the Property Inspector, under Actions, locate IsSeededInteractionAvailable, and
change it to true.
The IsSeededInteractionAvailable attribute makes it possible to display whatever
menu actions are supported by the component. In this case, the user will be able to
hide or show any content that appears within the layout.
Now let's change the name of MyJavaPortlet through the Property Inspector, just
so you can see how it's done.
Note that once you make changes through the Property Inspector, you can never
again customize or personalize the portlet's name at runtime. Although this
behavior is acceptable for the purposes of this tutorial, it's something you'll want
to keep in mind as you develop your own applications in the future.
8. In the Structure window, highlight adfp:portlet so that the Property Inspector now
reflects the portlet's properties.
9. In the Property Inspector, under General, locate the Text field, and enter: Sample
Portlet as shown in Figure 4–17.
This changes the name that appears in the portlet header.
All the other page customizations we made in Step 3 are also there:
■ The title of the portlet has changed to Sample Portlet. Now that the portlet title
is driven by the Text property you can no longer customize or personalize the
title at runtime. If you click the Actions icon and choose Customize, you'll see
this for yourself.
■ The components are displayed horizontally, instead of vertically. If you click
the Actions icon on one of the images, you can see that the Move action now
says Left and Right instead of Up and Down.
■ Because we changed DisplayHeader to true, the container object,
panelCustomizable, now displays a header area. Recall that the layout had no
such header in Step 3, before we changed the DisplayHeader setting.
Everyone who runs the page will see these page customizations.
4. Before moving on, let's remove the permanent portlet title customization we made
through the Property Inspector. In Chapter 8, "Providing Security" we use the
portlet's title property to demonstrate page personalization so we must be able to
change the name at runtime:
a. Close the browser, and return to JDeveloper.
b. In the Structure Window for MyPage.jpsx, highlight adfp:portlet.
c. In the Property Inspector, click the Text field, and then click the Reset to
Default icon in the Property Inspector toolbar. This will remove the text
Sample Portlet.
In the Visual Editor, the name in the portlet header should change back to
MyJavaPortlet1.
In the future, you may want to use multiple panelCustomizable components on a
page, each containing one or more portlets or objects within a showDetailFrame
component. Because each layout has its own Move, Maximize, and Show/Hide
capabilities, placing multiple layouts on the page enables you to treat blocks of
components and portlets as separate entities. You'll find more information in the Oracle
WebCenter Framework Developer's Guide.
Step 5a: Changing showDetailFrame Background Using the Default ADF Faces Skin
In this step, you'll use the default ADF Faces skin (called Oracle) to influence
style-related properties.
1. In the Structure window, highlight one of the cust:showDetailFrame entries.
We'll use this component to see how to specify style property values.
2. In the Property Inspector, expand the Background property.
The default ADF Faces skin offers three settings, light, medium, and dark. Let's
choose a dark background for this component.
3. Change the value to dark, as shown in Figure 4–20.
Now let's see how to create a brand new skin and override the styles defined by
the default ADF Faces skin.
e. Click OK.
Your new style sheet appears in the Applications Navigator under ViewController,
Web Content, css and also displays in the Editor. Notice the default style selectors
BODY, H1, H2, and H3.
In the steps that follow, you'll register a new skin with your application. This
involves creating a file named adf-faces-skins.xml, and populating it with a
short list of tags that identify the skin's ID, location, .css, and the like.
2. Let's create adf-faces-skins.xml:
f. The file must be stored in the WEB-INF folder, so just click OK to create the
file.
An empty XML file displays in the Editor. It appears in the Applications
Navigator under WEB-INF.
3. Add tags to adf-faces-skins.xml to identify your new skin (and point to your
new style sheet mystyle.css):
a. Copy and paste the following code into the XML Editor:
<?xml version="1.0" encoding="ISO-8859-1"?>
<skins xmlns="http://xmlns.oracle.com/adf/view/faces/skin">
<skin>
<id>mystyle</id>
<family>mystyle</family>
<render-kit-id>oracle.adf.desktop</render-kit-id>
<style-sheet-name>css/mystyle.css</style-sheet-name>
</skin>
</skins>
This code specifies the color for the text that displays in a showDetailFrame
component's header and a portlet's header. We've chosen purple text for
header-light and header-medium, and white text for header-dark. Choose
another color scheme if you prefer.
c. Copy the following code, and paste it at the bottom of the file:
af|showDetailFrame::content-light, af|showDetailFrame::content-medium,
af|showDetailFrame::content-dark
{
color: Black;
background-color: Silver;
border-left:1px black solid;
border-right:1px black solid;
border-bottom:1px black solid;
}
During this lesson you've experimented with ways to affect the look and feel of
your application. You'll find more detailed information in the Oracle WebCenter
Framework Developer's Guide.
Before moving on, let's change back to the default Oracle skin.
10. To remove the custom skin:
The Rich Text portlet is a useful tool for posting enterprise announcements and news
items at runtime. Once you add the portlet to a page, authorized users can use the
Actions icon to invoke a toolbar with all the rich-text editing tools needed to insert,
update, and format display text. Depending on the security privileges set for the page,
the Rich Text portlet can be used to broadcast information to a wide audience, or to a
more narrowly defined group.
The Rich Text portlet is available through the WebCenter Preconfigured OC4J.
Figure 5–1 shows what your page will look like at the end of the lesson.
Introduction
This lesson shows you how to work with the Rich Text portlet through the following
steps:
■ Step 1: Registering the Rich Text Producer
■ Step 2: Adding the Rich Text Portlet To Your Page
■ Step 3: Customizing the Rich Text Portlet at Run Time
Prerequisites
The Rich Text portlet is available through the WebCenter Preconfigured OC4J
(installed and initialized during Chapter 3 Step 2: Setting Up Your Connection). If this
OC4J instance is no longer running, click the Start WebCenter Preconfigured OC4J
icon at the far right of the JDeveloper toolbar before you begin this lesson.
The test page displays two Rich Text producer registration URLs (WSDL
documents). You'll use the WSRP v2 WSDL URL in this WebCenter application:
http://localhost:6688/richtextportlet/portlets/wsrp2?WSDL
Tip: Test pages for every portlet producer available through the
WebCenter Preconfigured OC4J are accessible from:
http://localhost:6688/
Figure 5–3 Registering the Rich Text Portlet with the Application
Because you already have one portlet producer registered, you can use this
right-click shortcut rather than having to navigate through the New... gallery.
3. Click Next to exit the wizard's Welcome screen.
4. In the Name field, enter: RichTextProducer
5. Click Next.
6. In the URL Endpoint field, enter:
http://localhost:6688/richtextportlet/portlets/wsrp2?WSDL
This tutorial assumes that localhost can be used in a URL to successfully refer
to the local computer on which your preconfigured OC4J installation resides. (If
this is not the case, replace localhost with your computer's IP address.)
7. Click Next.
8. Click Finish to exit the wizard.
9. Click OK to close the message box.
Now you are ready to drop the Rich Text portlet onto your page.
3. Select Rich Text Portlet, and drop it on top of h:form in the Structure window as
shown in Figure 5–5.
4. Select Rich Text Portlet1 in the Visual Editor and you'll see its properties
displayed in the Property Inspector.
5. In the Property Inspector, under Display Options, set AllModesSharedScreen to
true.
This directs the page to render all changes made through personalize/customize
inline, rather than by refreshing the entire page.
6. Select File, Save All to save your work.
7. Select Run, Run MyPage.jspx, or click the green arrow in the JDeveloper toolbar.
A new browser opens to display the page (Figure 5–6).
This is what the user sees when the page is displayed. The next step shows you how
easy it is to customize the Rich Text portlet, and may suggest some uses as you plan
your WebCenter application.
3. Enter some text of your own, and change the font size, type, and color, and
choosing a background color. For example, see Figure 5–9.
4. Experiment with the other controls. For example, display an image in the portlet:
a. Click the Insert Image icon.
In this lesson you'll add two portlets to a page and learn how to configure them so that
one portlet drives the content of the other. To demonstrate inter-portlet
communication, you'll use a Parameter Form Portlet (one of the sample WSRP 2.0
portlets) and an instance of OmniPortlet (an Oracle PDK portlet). Both portlets are
available through the preconfigured OC4J you installed in Chapter 3, "Building and
Testing Your First Portlet".
Figure 6–1 illustrates what the page (called MyWeather.jspx) will look like at the end of
the lesson.
Introduction
You'll make two portlets communicate in the following steps:
■ Step 1: Registering Portlet Producers
■ Step 2: Placing the Parameter Form Portlet on a Page
■ Step 3: Customizing the Parameter Form Portlet
■ Step 4: Placing an OmniPortlet on a Page
■ Step 5: Building an OmniPortlet That Uses a Web Service
■ Step 6: Configuring the Portlets Together
■ Step 7: Testing Portlet Interaction
Prerequisites
Both of the portlets we use in this lesson are available through the WebCenter
Preconfigured OC4J (installed and initialized during Chapter 3 Step 2: Setting Up Your
Connection). If this OC4J instance is no longer running, click the Start WebCenter
Preconfigured OC4J icon at the far right of the JDeveloper toolbar before you begin
this lesson.
Figure 6–3 Successfully Registered Producer for the Sample WSRP Portlets
Open the Component Palette through the View menu, and expand its drop-down
list. Locate and select SampleWSRPPortletsProducer from this list. Several
portlets are available for selection. Among these, you will find the Parameter Form
Portlet, which you will use in this lesson. (If you can't see anything in the
Component Palette, try displaying a Java Server Faces page in Design view, such
as MyPage.jspx. This should reveal all the portlets).
You'll come back to the Parameter Form Portlet later. First you must register the
OmniPortlet producer.
10. First, check that the OmniPortlet producer is up and running. In a browser, enter
the following producer test page URL:
http://localhost:6688/portalTools/omniPortlet/providers/omniP
ortlet
If the producer is available, you'll see the OmniPortlet's Producer Test Page.
Now, let's register the OmniPortlet producer. So far in this tutorial you've
registered only WSRP producers. As OmniPortlet is an Oracle PDK portlet, you'll
be using a different wizard to register this producer.
11. Right-click Portlet Producers in the Applications Navigator, and click New Oracle
PDK Producer.
12. When the PDK Portlet Producer Registration Wizard appears, click Next.
18. Open the Component Palette again, and click the drop-down list to make sure that
OmniPortletProducer is displayed. Select OmniPortletProducer from this list.
Several portlets are available for selection. Among these, you'll find OmniPortlet,
which you will use in this lesson.
Now both producers are registered with the tutorial application you can drop their
portlets onto a page.
c. Select PanelCustomizable, and drag it over the h:form tag in the Structure
window.
The panelCustomizable component should display at the top of the page
(Figure 6–8).
Before you run the page, let's take a look at the underlying page definition to see
how JDeveloper responds to a portlet with built-in parameters like this one.
Right-click MyWeather.jspx in the Applications Navigator, and choose Go to Page
Definition. Click Yes if the Page Definition doesn't exist yet.
In the Structure window (Figure 6–10) you should see an entry for each of the
Parameter Form's portlet parameters (ora_wsrp_navigparam_Parameter1,
ora_wsrp_navigparam_Parameter2 and ora_wsrp_navigparam_
Parameter3). You should also see three page variable entries with corresponding
When a portlet is dropped on a page, JDeveloper checks to see if the portlet has
public portlet parameters and, if it does, automatically adds the corresponding
number of page variables and maps them to the portlet parameters.
Use the Property Inspector to examine one of the mappings. You should see that
ora_wsrp_navigparam_Parameter1, for example, is mapped to the page
variable named ParameterFormPortlet1_1_ora_wsrp_navigparam_
Parameter1 (Figure 6–11).
Now let's run the page to see what a default Parameter Form Portlet looks like.
5. First, save all your changes. Click the Save All icon on the JDeveloper toolbar.
6. In the Applications Navigator, right-click MyWeather.jspx, and choose Run.
The default Parameter Form Portlet displays in your browser (Figure 6–12).
As you can see, the initial version of the portlet displays some default text. In the
next step, you'll customize the portlet so that it invites users to enter a US ZIP
code. Remember, the purpose of this lesson is to work with this portlet so it will
accept a parameter value (such as a ZIP code) and pass it to another portlet.
6. Click OK.
When displayed in the browser, the portlet should look like Figure 6–14.
Before moving on to the next step, let's review what you've built so far. First, you
created a page called MyWeather.jspx, and added a single Parameter Form Portlet.
Then, through portlet customization, you set up one of its parameters, ora_wsrp_
navigparam_Parameter1, to accept a US ZIP code. You may recall that JDeveloper
automatically mapped this particular parameter to a page variable named
ParameterFormPortlet1_1_ora_wsrp_navigparam_Parameter1. Later on,
you'll use this variable to pass the ZIP code on to another portlet.
But first, let's add the second portlet—an OmniPortlet.
In Step 6: Configuring the Portlets Together you'll use these portlet parameters to
configure inter-portlet communication. But first, let's see what an OmniPortlet
portlet looks like.
6. First, save all your changes. Click the Save All icon on the JDeveloper toolbar.
7. Before running the page again, stop the embedded OC4J Server. Choose Run,
Terminate, Embedded OC4J Server from the main menu.
Alternatively, click the red square Terminate icon in the Embedded OC4J Server
Log window.
8. In the Applications Navigator, right-click MyWeather.jspx, and choose Run.
OmniPortlet displays in the browser underneath the Parameter Form Portlet
(Figure 6–18).
As you can see, the initial version of the portlet is blank. In the next step you'll use
OmniPortlet to build a weather portlet based on a Web Service.
7. Under Portlet Parameters, set a Default Value for Param1. Enter: 94065
This tells the Web Service to return weather information for ZIP code 94065
(Redwood City, CA) by default.
8. Click Next, and then Next again as you don't need to set any filter options.
9. On the View Page, enter the values shown in Table 6–1.
10. Click Next, then specify the Column Label, Column, and Display As properties
for the weather data as shown in Table 6–2.
11. Click Finish to display weather information for Redwood City. You should now
see both portlets in your browser (Figure 6–19).
The Omniportlet displays a weather forecast for Redwood City, CA, which has the ZIP
code 94065. The Web Service providing this data can return weather information for
other areas if it is passed a valid US ZIP code. In the next step you'll learn how to link
these two portlets and make the first portlet (Parameter Form Portlet) drive the
content of the Omniportlet.
Figure 6–20 OmniPortlet Param1 Mapped to Same Page Variable as the Parameter Form
Portlet
d. Click OK.
4. Click Save All in the JDeveloper toolbar.
Now, let's run the page to see the portlets working together.
The Weather Forecast portlet should change, showing weather information for
New York (something like Figure 6–21).
Congratulations! You've completed this lesson and made two portlets communicate
with each other.
In the next lesson, you will learn how to publish file system content in your
WebCenter application.
In this lesson you will learn how to publish content that resides on a file system in
your WebCenter application. You'll see how easy it is to build content rich applications
with Oracle JDeveloper and experiment with the various ways you can present file
and folder information.
Figure 7–1 illustrates what your page (MyContent.jspx) will look like at the end of the
lesson.
Introduction
You'll add content to the tutorial application in the following steps:
■ Step 1: Creating a Data Control
■ Step 2: Adding Content to a Page at Design Time
■ Step 3: Displaying Folder Content in a Table
■ Step 4: Displaying Folder Content in a Tree
■ Step 5: Searching Folder Content
Prerequisites
During this lesson you'll need access to the sample you downloaded in Chapter 2,
"Getting Started". Before you start, make a note of the location where the sample
content is stored, see also Downloading Sample Tutorial Files.
9. If you get an error message, click OK and edit the Base Path, taking care to specify
the full path. If the test is successful, click OK to close the message box.
10. Click Next.
File system data controls expose several default attributes (name, path, URI,
primaryType) and optionally, one custom attribute (lastModified) —see
Figure 7–3.
Take a look at the Applications Navigator. You should see several new entries
under Model, Application Sources (Figure 7–4). For more information about data
controls and the files they generate, see Oracle WebCenter Framework Developer's
Guide.
12. The new data control should be available in the Data Control Palette, so let's
display that now. From the View menu, select Data Control Palette.
Under MyTutorialContent, you should see a hierarchical list of objects, collections,
methods, parameters, and operations for the new data control (Figure 7–5).
File system data controls (such as MyTutorialContent) provide several methods for
accessing and displaying file and folder information:
■ search - Enables you to perform searches on the content exposed through the
data control.
■ advancedSearch - Enables you to perform advanced searches on the content
exposed through the data control.
■ getItems - Returns files and folders stored in a specific location of the content
repository.
■ getAttributes - Returns a list of attributes and their values for a given file or
folder.
■ getURI - Returns the URI of a file. In this release, direct access to folders
through URIs is not supported.
You'll find detailed information about these methods in the Oracle WebCenter
Framework Developer's Guide.
Let's see how to use some of these objects.
3. Select the URI node, and drag and drop it onto MyContent.jspx.
When you drag an item from the Data Control Palette and drop it on a page,
JDeveloper displays a context menu of suitable components.
4. From the context menu, choose Links, and then ADF Go Link, as shown in
Figure 7–7.
6. Click OK.
You should see a new goLink on MyContent.jspx with default link text goLink1.
7. In the Structure window, double-click af:goLink - goLink1 to edit the default
properties.
8. The default link text is goLink1. Replace this text with the word Help
(Figure 7–9).
The expression in the Destination field, #{bindings['getURI_
returnURI'].inputValue}, fetches the URI of the Help page.
11. Before running the page, stop the embedded OC4J Server. Choose Run, Terminate,
Embedded OC4J Server from the main menu.
12. Right-click MyContent.jspx, and select Run to see the Help link in action.
When the page appears in your browser window, you should see the new Help
link. Click the link to check that the correct file is displayed. Your browser should
look like the one displayed in Figure 7–10.
Figure 7–10 File Link Through the File System Data Control
3. First, let's create a table that lists every file and folder available through this data
control. To do this, highlight the Return node, drag it onto the page, and drop it
below the Help link (af:goLink - Help).
When you drag an item from the Data Control Palette and drop it on a page,
JDeveloper displays a context menu of suitable UI components. File system items
can be displayed in a form, table, tree, or navigation item.
4. Choose Tables from the context menu, and then ADF Read-only Table, as shown
in Figure 7–13.
You should now see the Action Binding Editor (Figure 7–14).
5. To display everything under the data control's base path, enter / for the path
parameter. Make sure that you enter a forward slash, not a backslash here.
6. Leave the type blank for now. This implies that the table must display both files
and folders. Later on you'll configure the table to show files only.
7. Click OK.
You should see the Edit Table Columns window (Figure 7–15).
Let's take a quick look at some of the display options available on this page. In
addition to the file/folder name (name), you can publish additional content
attributes such as path, URI, primaryType, and lastModified. All attributes
are published by default, with default labels but you can customize the content
displayed. You can remove attributes, edit display labels, and change the display
order to suit your precise requirements.
For now, let's just edit the Display Labels to make them more meaningful.
8. Click <bound to attr label> (next to name) and enter: Name
Now edit the Display Label for the other attributes (path, URI, primaryType,
lastModified). Enter new Display Labels such as Path, URI, File or Folder,
and Last Modified as shown in Figure 7–16.
9. Click OK.
You should see a table on MyContent.jspx that looks something like Figure 7–17.
10. Let's see the page in a browser. Right-click MyContent.jspx, and select Run.
When the page appears in your browser window, you should see a list of all the
file and folders available through the MyTutorialContent data control (for
example, everything under the directory C:\TutorialContent) as shown in
Figure 7–18.
15. Click OK, and then click OK again to confirm the conversion.
For this tutorial, we want the GoLinks to display file/folder names (name) as
hyperlinks. To do this, you'll need to edit the default GoLink properties.
16. In the Structure window, right-click the new af:goLink - goLink 1, and click
Properties to display the default settings.
17. The default link text is goLink 1. To display file/folder names instead (name), use
the binding editor to build the required expression #{row.name} as shown in
Figure 7–21:
a. For the Text field, click Bind.
b. Expand JSP Objects, and then expand row.
c. Double-click name to select the expression #{row.name}.
d. Click OK.
18. To generate URIs for the HTTP hyperlinks:
19. Before running the page again, stop the embedded OC4J Server. Choose Run,
Terminate, Embedded OC4J Server from the main menu.
20. Run MyContent.jspx again.
This time you should see a list of hyperlinked file/folder names like the one
shown in Figure 7–22.
a. In the Structure window, right-click the af:table -table1 node, and choose
Properties.
b. Click the Column Summary tab. Use the Delete button to remove all but the
Name column (Figure 7–23).
e. Click OK.
24. To configure the table to show files only (not folders), you'll need to edit the page
definition file:
a. Right-click MyContent.jspx, and select Go to Page Definition.
b. In the Structure window, expand bindings and getItems (Figure 7–25).
c. Double-click type.
d. The type options are nt:file and nt:folder. To specify display files only,
enter nt:file in the NDValue field, and click OK as shown in Figure 7–26.
25. Let's take a moment to examine a couple of binding settings for the data control
that are set by default in the page definition file. You may want to use these
settings for your own application, so it's important to understand what they do:
a. In Structure view, expand the executables section.
b. Select the method iterator getItemsIter.
c. From the View menu, choose Property Inspector to view the default settings.
d. The RangeSize property controls how many file/folder items are displayed on
each page. For this tutorial, let's keep the default RangeSize 10.
e. The CacheResults property determines whether table content is cached. By
default, the results are cached (true) but caching may not be desirable for
some applications where content changes frequently and real time updates are
critical. Set this property to false.
When you run the page, you'll see that the file list updates dynamically
whenever the page is refreshed.
26. Click the Save All icon in the JDeveloper toolbar.
28. Test that caching is disabled. Rename one of the files on your file system, and then
refresh the browser.
As you chose not to cache the table content, you'll see the new file name
immediately.
In this lesson you learnt how to publish file system content in a table. In the next
lesson you'll display the same content in a tree.
Now, let's publish content available through this data control in an hierarchal tree
format.
11. In the Applications Navigator, double click MyContent.jspx to open the page in
the Visual Editor.
12. In the Data Control Palette, expand the GetItems node under
MyTutorialContent2 (Figure 7–30).
13. Highlight the Return node, drag it onto the page, and drop it below the table
(af:Table - table1).
14. From the context menu, select Create Trees, ADF Tree as shown in Figure 7–31.
Rules define how tree data controls fetch and display hierarchical data. The
default rule settings (Figure 7–33) show getItems is the root of the tree, that tree
nodes (or branches) may display only the name attribute, and that tree nodes may
not display children—Branch Rule Accessor is <none>.
In the next few steps you'll edit these default settings and define a rule that will
expose files/folders under each node in a hierarchical format and enable you to
hyperlink file names.
17. In the Display Attribute list, multi-select the attributes name, URI, and
primaryType as shown in Figure 7–34.
You'll use the name attribute to display file/folder names in the tree, and you'll
use the URI, and primaryType attributes to build hyperlinks to file content. The
other attributes (path and lastModified) are not used in this tutorial so there is
no need to select them here.
This enables tree nodes to display any children that may exist in a hierarchical
format.
19. Click Add New Rule.
You should see the message shown in Figure 7–35.
20. Click OK to close the message box and display the Show Rules tab (Figure 7–36).
Now you should see a tree structure similar to Figure 7–37 displayed on
MyContent.jspx.
22. Before running the page again, stop the embedded OC4J Server. Choose Run,
Terminate, Embedded OC4J Server from the main menu.
23. Let's see the page in a browser. Right-click MyContent.jspx, and select Run.
When the page appears in your browser window, you should see a list of files and
folders available through the MyTutorialContent2 data control, for example,
everything under the directory C:\TutorialContent. Expand the More_
Images node to see access content in this subdirectory (Figure 7–38).
Now let's hide the URI and primaryType attribute. In a moment, you'll use these
attributes to build hyperlinks but they don't need to be displayed in the tree.
24. In the Applications Navigator, select MyContent.jspx.
25. In Structure window, right-click af: tree - tree1, and choose Properties.
26. Change the Node Stamp Value to #{node.name}, and click OK.
27. Let's see what the tree looks like now. Right-click MyContent.jspx, and select Run.
You should see file and folder names only (Figure 7–39).
Trees will display the first ten items (by default) but you can customize this
through the RangeSize property for the GetItems method in the page's
definition file.
By default, the tree displays file/folder names as read-only text, but let's display
them as hyperlinks as you did for the table. Like last time, you want to add
hyperlinks to the file names (not folders). Unlike last time, you cannot hide the
folders as they're required for navigation through the tree. As an alternative, you
can display the folder names as read only text. To accommodate this dual
functionality, let's use an ADF Faces Switcher component (af:switcher) with
two facets - one for folders and one for files.
28. In the Structure window, navigate down to the nodeStamp facet to reveal the
current display format af:outputText - #{node.name} (Figure 7–40).
31. Folder names require no additional formatting. Let's reuse the default display
format af:outputText -#{node.name} to display folder names in plain text:
a. In the Structure Window, select af:outputText - #{node.name}.
b. Drag and drop the af:outputText component on top of f:facet - nt:folder
(Figure 7–43).
a. Right-click f:facet - nt:file, and then choose Insert Inside f:facet - nt:file, ADF
Faces Core.
b. Choose GoLink, and click OK.
c. Right-click af:goLink - goLink 1, and click Properties.
d. For the link's Text, enter the expression: #{node.name}
e. For the link's Destination, enter the expression: #{node.URI}
f. Click OK.
Use the Structure window to check the af:switcher configuration. It should
look like Figure 7–44.
This time, you'll see a tree of hyperlinked file names similar to Figure 7–45.
35. Click any file name. You should see the content of that file displayed in a new
browser window.
Notice that folder names are plain text, a result of our Switcher component.
1. In the Data Control Palette, expand the Search node under MyTutorialContent2
(Figure 7–47).
2. Highlight the search node, drag it over to the Structure window, and drop it below
the tree (af:Tree - tree1).
3. From the context menu, select Create Method, ADF Command Button as shown
in Figure 7–48.
a. In the Data Control Palette, expand the Parameters node, and select keyword.
b. Drag and drop the keyword parameter above the Search button.
c. From the Create menu, choose Texts, ADF Input Text w/ Label.
d. In the Structure window, double-click af:inputText #{bindings.keyword...,
and enter a suitable label such as:
Find files containing this word or phrase:
e. Click OK.
Your page should look like Figure 7–50.
Figure 7–51 Edit Display Labels for the Search Results Table
f. Click OK.
10. Click the Save All icon in the JDeveloper toolbar.
Now let's display the search form in a browser and run some searches.
11. Before running the page again, stop the embedded OC4J Server. Choose Run,
Terminate, Embedded OC4J Server from the main menu.
12. Right-click MyContent.jspx, and select Run.
You should see a search form similar to that shown in Figure 7–52.
13. The first field on the form exposes the namePattern parameter. Enter some file
name criteria, click the search button, and examine the content displayed in the
search result table. Only files matching the name pattern you specify should be
displayed.
Try the following searches:
■ To search for files with the .html file extension, enter %html. Three files should
match this pattern.
■ To search for filenames containing the word help, enter %help%. Only
help.html should match.
14. The second field on the form exposes the keyword parameter. This parameter
enables you to search for content inside files. Enter a word or phrase, click the
search button, and examine the content displayed in the search result table. Only
files containing the words you specify should be displayed.
Remove %help% from the field above, and try the following keyword searches:
■ To search for files containing the word WebCenter, enter WebCenter. Two
files should display.
■ To search for files containing the words WebCenter and tutorial, enter
WebCenter AND tutorial. Only one file contains both these words.
This completes the content integration lesson. You've learnt how to publish file system
content in a WebCenter application and discovered how to add search capabilities too.
For more detailed information, on this subject, refer to the Oracle WebCenter Framework
Developer's Guide.
In the next lesson you'll use Oracle ADF security to secure the pages you've created
during this tutorial.
In this lesson you'll learn how to secure the pages of a WebCenter application using
Oracle ADF security. Figure 8–1 shows you what the tutorial application will look like
at the end of the lesson.
Introduction
We will add security to the tutorial application and test it in the following steps:
■ Step 1: Creating a Login Page
■ Step 2: Configuring ADF Security Settings
■ Step 3: Creating a Welcome Page
■ Step 4: Securing Pages
■ Step 5: Mapping Security Roles in orion-web.xml
Prerequisites
In this chapter you'll authenticate users against the lightweight XML resource provider
system-jazn-data.xml supplied with the embedded OC4J. Before starting these
exercises, you'll need to add the following user data to this file:
13. Click the Design tab to view the login form (Figure 8–4).
The login page uses the standard J2EE security container login method j_
security_check to validate user credentials. This security check method
appears on the <form> element. The form itself contains two input fields, one to
accept the user name and the other for the password. Values entered into these
fields get assigned to the container's login bean attributes j_username and j_
password, respectively.
14. Now, let's apply a style sheet to the login page. From the Components Palette
pulldown menu, choose CSS.
15. Drag JDeveloper, and drop it on the page.
The login page refreshes with the new style sheet applied as shown in Figure 8–4.
Now let's set Oracle ADF Security options for the tutorial application.
If you want users logging into your application to see a particular page after
authentication, you would choose Redirect After Successful Authentication and
name the required page. However, you're not going to configure the tutorial
application like this. Instead, you'll use the default behavior, which sends
authenticated users back to the page they tried to access prior to authentication.
5. Click Next to move on to the next page of the wizard.
6. Choose Lightweight XML Provider (Figure 8–7).
Oracle ADF Security authenticates users against a given resource provider. For this
tutorial you'll use the lightweight resource provider system-jazn-data.xml
that you set up at the beginning of the lesson.
7. Click Next to display the next page of the wizard.
8. Set JAAS Mode to doAsPrivileged (Figure 8–8).
Oracle ADF Security requires this option to be set.
The default realm is jazn.com. Note that for this release, Oracle ADF security only
reads permissions at the system-level (JAZN file) and not at the application-level.
9. Click Next.
10. On the Login page, choose Form-Based Authentication as shown in Figure 8–9.
This specifies that the tutorial application will use a form to facilitate
authentication.
There is no need to generate default pages for the login form and login error
message (login.html and error.html) because you'll be using the login form
in Login.jspx.
11. For Login Page, enter: Login.jspx
Although it's fairly simple to create a separate error page, for this tutorial you'll
use the same page. If you do want to create an error page (say, LoginError.jspx),
create a page that is identical to Login.jspx and add an error message that indicates
authentication failure.
13. Click Next to display the final page of the wizard - Resources (Figure 8–10).
This page defines resources within your application that should be secured, and
specifies which J2EE security roles can access each resource.
15. Click Add, and enter the name ValidUsers (Figure 8–11).
Later on, you'll map this J2EE role to an identity store role named users (defined
in system-jazn-data.xml, the resource provider that you set up at the
beginning of the lesson). The users role maintains a list of every valid user.
From a security perspective, allocating permissions to this role effectively defines
an authenticated Public resource. That is, it would be available to all users without
needing a specific permission to be defined.
Figure 8–12 ADF Security Wizard - Granting Access to the adfAuthentication Resource
Tip: You can expand any tab to fill the JDeveloper window by
double-clicking the tab. Double-clicking again, toggles the feature off.
One way to review file changes is through the History Tool. If you click the History
tab, you'll see the additions highlighted down the right-hand side. You can click
change highlights individually or use the Go to Next Difference icon to scroll through
the additions one by one. You'll find more information about these entries in the
Security Chapter of the Oracle WebCenter Framework Developer's Guide.
Now let's create a welcome page for the tutorial application.
Authenticated users will see different information on the welcome page. After logging
in, authenticated users get redirected back to the welcome page, but this time they'll
see links to secured pages and a logout link as shown in Figure 8–14.
11. Earlier, we applied the JDeveloper style sheet to the login page. Let's apply the
JDeveloper style sheet to the welcome page too. Click Add, double-click the css
folder, and then choose jdeveloper.css.
12. Click Finish.
An empty page named Welcome.jspx displays in Design view.
13. Let's use an ADF Faces PanelPage component to present content on the welcome
page:
a. From the Components Palette pulldown, choose ADF Faces Core.
b. Select the PanelPage option, and then drag and drop it on to the page. Use the
Structure window to verify that the PanelPage component gets placed inside
the h:form tag, as shown in Figure 8–15.
Now lets's add some Login/Logout links to the area named menuGlobal—one of
the PanelPage facets.
14. You'll use an af:goLink, another ADF Faces Core component, for the login link:
The page content you see now (Figure 8–18) is the public view of the Welcome page.
A little bit later on you'll add some page navigation buttons but you'll add some
code that will hide them from unauthenticated users.
Similarly, you'll need to add some code that will hide the Login link from
authenticated users. Clearly, there is no need to display a login link to users who are
already logged in! So let's add a backing bean that determines whether the current
user is authenticated and bind it to the login link.
15. First, double-click Welcome.java to open the file in the Editor.
You'll find this file under ViewController, Application Sources, view.backing.
16. Add some code that determines whether or not the current user is logged in, see
highlighted code shown in Figure 8–19.
You can copy and paste the bold code shown here to the appropriate section of
Welcome.java:
package view.backing;
import javax.faces.component.html.HtmlForm;
import oracle.adf.share.ADFContext;
import oracle.adf.view.faces.component.core.layout.CorePanelPage;
import ...
The boolean property of the backing bean is TRUE if the current user is logged in
and FALSE if he is not. You can use this property to show/hide the links on the
Welcome page based on whether the user is logged in.
17. Before moving on, let's check that the updates to Welcome.java compile correctly.
Right-click Welcome.java, and choose Make.
You should see a Successful compilation message in the Messages Log
window.
18. Now bind this code to the Login link. Remember, we want to display the Login
link to unauthenticated users only:
a. In the Applications Navigator, double-click Welcome.jspx to display the page
in the Visual Editor.
b. In the Structure window, double-click af:goLink - Login to open the GoLink
Properties dialog.
c. Click the Advanced Properties tab, and select the Rendered property.
d. Click the Bind to Data icon in the toolbar (see Figure 8–20).
e. Expand JSF Managed Beans and drill into the backing bean for the Welcome
page backing_Welcome. You should see the authenticated attribute listed
here.
f. Double-click authenticated. The expression #{backing_
Welcome.authenticated} should appear in the Expression field.
g. We want to display a Login link to users who are not authenticated. The
Authenticated property will be TRUE if the user is logged in, so you must
negate the expression to show the link only when the user is not logged in.
Add the ! operator to the expression like this: #{!backing_
Welcome.authenticated}
h. Click OK.
The Rendered property should now display the expression #{!backing_
Welcome.authenticated}.
i. Click OK again to close the GoLink Properties dialog.
19. Now let's add a logout link that's displayed only to authenticated users:
The adfAuthentication servlet will prompt users to log out and the
parameter end_url specifies which page to display once the user is logged
out.
f. Now let's hide the Logout link from unauthenticated users. Click the
Advanced Properties tab, and select the Rendered property.
g. Click the Bind to Data icon in the toolbar.
h. To display this link to authenticated users, enter into the expression field:
#{backing_Welcome.authenticated}
i. Click OK.
j. Click OK again to close the properties dialog.
You should see a Logout hyperlink on the Welcome page (Figure 8–21).
Finally, let's add some command buttons to the Welcome page that allow
authenticated users to navigate to the pages in your tutorial (MyPage.jspx,
MyWeather.jspx, and MyContent.jspx).
20. Let's use an ADF Faces panelGroup component to accommodate the page
navigation buttons. With this component you can arrange the content horizontally
or vertically.
a. From the Component Palette pulldown, choose ADF Faces Core.
b. Select the PanelGroup option, and then drag and drop it on top of the
af:panelPage component. Again, use the Structure window to verify that it
is placed inside the af:panelPage tag as shown in Figure 8–22.
21. Before you can add a command button that navigates from Welcome.jspx and to
MyPage.jspx, you'll need to create a JSF navigation rule between the two pages.
Then you may drop an ADF command button onto the page, and add some button
code that ensures the button displays to authorized users only.
a. First, let's define the navigation rule between Welcome.jspx and MyPage.jspx.
You do this in the configuration file faces-config.xml. In the Applications
Navigator, double-click faces-config.xml (under ViewController, Web
Content, WEB-INF).
b. Click the Diagram tab.
c. Drag Welcome.jspx from the Applications Navigator to the empty diagram,
and then do the same for MyPage.jspx (Figure 8–24).
Notice that the Component Palette automatically displays the JSF Navigation
Modeler components.
d. From the Component Palette, choose JSF Navigation Case to activate it. You'll
use this component to add a navigation rule.
e. On the diagram, click the icon for the source page (Welcome.jspx) and then
click the icon for the destination page (MyPage.jspx).
JDeveloper draws the navigation rule on the diagram as a solid line ending
with an arrow between the two pages,
f. By default, the link outcome says -success. Click this text, and change it to
something more explanatory, like Go To MyPage (Figure 8–25).
g. Now let's follow similar steps to create a navigation rule from MyPage.jspx to
Welcome.jspx. First, choose JSF Navigation Case from the Component Palette.
Next, click MyPage.jspx (on the diagram) followed by Welcome.jspx. Finally,
click the default -success text and change it to Go To Welcome Page
(Figure 8–26).
Now that navigation rules exist between the two pages, you can add a
Command button on the Welcome page for user navigation to MyPage.
h. In the Applications Navigator, double-click Welcome.jspx to display it in the
Visual Editor.
i. Choose ADF Faces Core from the Component Palette pulldown menu.
j. Select the CommandButton option, and then drag and drop it on top of
af:panelGroup. You can use the Structure window to verify this.
k. Right-click the new button (commandButton 1), and then choose Properties.
l. For the button Text, enter Go To MyPage as shown in Figure 8–27, and click
OK.
m. You define what the button actually does through the button's Action
property. You'll need to display the Property Inspector to do this, so select
View, Property Inspector from the JDeveloper menu.
n. In the Property Inspector, select Action, and then choose Go To MyPage from
the drop down list.
Now, let's hide the button from unauthenticated users—just like you did for
the Logout link. In addition, we'll add some code that will hide the button if
the logged-in user is not authorized to view MyPage.jspx. This time we'll use
the Property Inspector to enter the expression.
o. Select the Rendered property. In the Property Inspector, this property is
located under the Core section.
p. Now click the Bind to data icon in the Inspector's toolbar.
q. Enter the expression: #{backing_Welcome.authenticated &&
bindings.permissionInfo['MyPagePageDef'].allowsView}
Check there are no extra spaces at the beginning or end of this expression.
r. Click OK.
In JDeveloper, your Welcome page should look like Figure 8–28.
22. Now add two more buttons to the Welcome page that will enable authorized user
navigation to MyWeather.jspx and MyContent.jspx. Repeat step 21 very carefully.
a. First, add MyWeather.jspx and MyContent.jspx to the navigation diagram.
When complete, check that your navigation diagram looks similar to
Figure 8–29.
b. Now, add two more navigation buttons to Welcome.jspx, and set the button
Text, Action, and Rendered properties.
When you edit the Text, Action, and Rendered properties for these navigation
buttons, remember to substitute the appropriate page names (as shown in
Table 8–1) and check for extra spaces at the beginning/end of the Rendered
expression.
5. Click OK.
Changes made through the Authorization Editor are saved in the embedded
OC4J's system-jazn-data.xml file, for immediate testing, and simultaneously
saved to app-jazn-data.xml in the application's .adf/META-INF directory.
The app-jazn-data.xml file packages application specific security policies along
with the application itself, to facilitate the deployment of secure WebCenter
applications. You'll learn more about app-jazn-data.xml in Chapter 9,
"Deploying Your WebCenter Application".
Let's secure MyPage.jspx next. First you'll add a logout link, and then you'll edit
page authorization details. Instead of creating a new Logout link from scratch,
copy the logout link you created for the Welcome page.
6. In the Applications Navigator, select Welcome.jspx.
7. In the Structure window, right-click af:goLink - Logout, and choose Copy.
8. In the Applications Navigator, select MyPage.jspx.
9. In the Structure window, select h:form, right-click, and select Paste.
af:goLink - Logout is placed at the bottom of the page by default. Drag it
above cust:panelCustomizable to move it to the top of the page
(Figure 8–33).
Now let's authorize access to this page and specify permissable actions on a role
by role basis. As before, this configuration takes place in the page's definition file
(MyPagePageDef.xml).
10. Right-click MyPage.jspx in the Applications Navigator.
Let's take a closer look at these settings. When a user assigned with the
page-customizer role logs in to the tutorial application (such as Harvey), that user
may view, personalize, and customize aspects of MyPage.jspx, but may not edit
page content or grant page permissions to any other users. Logged-in users with
the page-viewer role (such as Singh) are more restricted; those users can view
MyPage.jspx but no other page actions are allowed.
Notice that users with the restricted-user role (such as King) are not authorized to
view the page at all.
14. Click OK to save these selections.
Now that MyPage.jspx is secure, repeat exactly the same steps for MyWeather and
MyContent.
15. To secure MyWeather and MyContent, repeat steps 8 through 14.
After you copy and paste the Logout links, remember to move them to the top of
your pages (under the h:form).
16. Click the Save All icon in the JDeveloper toolbar.
All the pages in your application are now secure.
First, you'll create the configuration file where such security role mappings are stored;
that is, the tutorial application's OC4J deployment descriptor file (orion-web.xml).
Let's create the file now.
1. In the Applications Navigator, right-click ViewController, and select New.
4. Select OC4J Deployment Descriptor Wizard, and then click OK (Figure 8–35).
This brings up the OC4J Deployment Descriptor wizard. This wizard lets you
select the specific deployment descriptor type and version you require, and then
generates the .xml file. For this tutorial you need to select orion-web.xml 10.0
as the deployment descriptor. Later on you'll use this .xml file to package the
tutorial application before deployment to the application server.
5. Click Next to move beyond the Welcome page.
6. Select orion-web.xml (located at the bottom of the list), and then click Next.
The file name will be greyed out if the file already exists.
7. Select 10.0, and then click Finish.
After you click Finish, orion-web.xml displays in the Applications Navigator,
under ViewController, Web Content, WEB-INF.
8. Right-click orion-web.xml, and select Properties to set some additional
deployment options.
9. Select Security Role Mappings from the panel on the left.
This displays a panel on the right where you'll add the following security role
mapping:
a. Click Add.
This displays a window, as shown in Figure 8–36, where you'll enter the J2EE
security role name—ValidUsers.
e. Click the Add button to the right of the Group Names panel.
f. For Group Name, enter: users (Figure 8–39).
This the default identity store role which maintains a list of every valid user:
Singh, Cho, Harvey, JtaAdmin, and oc4jadmin. For details, see Appendix A,
"How to Set Up the Tutorial Identity Store".
Figure 8–39 Deployment Descriptor - Mapping Group of Users to the J2EE Security Role
g. Click OK.
In this step you mapped the J2EE security role ValidUsers to the identity store
role users (Figure 8–40).
Figure 8–40 Deployment Descriptor - J2EE Security Role Mapped to the users Role
11. Choose JAZN in the panel on the left, and select Run as Mode and Do as
Privileged Mode as shown in Figure 8–41.
This completes the OC4J Web application deployment descriptor configuration. Now
you're ready to run the application and see the new security features in action.
2. Click Login.
You should be directed to Login.jspx which contains an entry form for user
credentials as shown in Figure 8–43.
3. Enter login credentials for the user Singh. Both name and password are
case-sensitive, so take care when typing them in. For Name enter Singh, and for
Password enter welcome.
4. Click Login.
If authentication is successful, you should see Welcome.jspx with a Logout link at
the top of the page, as shown in Figure 8–44. Remember, you defined
Welcome.jspx as the success URL when you configured the Login link on the
Welcome page.
5. As user Singh, you should also see several command buttons. Click the button that
says Go To MyPage.
As user Singh you have privileges to view this page but you should not be able to
personalize or customize anything on the page. To verify this, take a look at the
Actions menu for MyJavaPortlet.
6. Click the Actions icon in the portlet banner to reveal the available options. As you
are logged in as Singh (with view privileges) only the Refresh option should be
available, as shown in Figure 8–45.
7. Click Logout.
You should get directed back to the Welcome page.
3. Click Login.
If authentication is successful, you should see the Welcome page with a Logout
link at the top of the page and all three page navigation buttons.
4. Click Go To MyPage.
As user Cho you have privileges to both view and personalize portlets but you
should not be able to customize the page or portlets in any way. To verify this, take
a look at the Actions menu for MyJavaPortlet.
5. Click the Actions icon in the portlet banner to reveal the available options. As you
are logged in as Cho you should see two options: Refresh and Personalize, as
shown in Figure 8–47.
6. Click Personalize.
7. Change the Portlet Title, for example, enter: Cho's Java Portlet
This title is only displayed when Cho is the logged on user. No other user will see
this title.
8. Click OK to see the personalizations for user Cho.
9. Click Logout.
3. Click Login.
If authentication is successful, you should see Welcome.jspx with a Logout link at
the top of the page and several page navigation buttons as before.
4. Click Go To MyPage.
As user Harvey you have privileges to view, personalize portlets, and customize
this page. To verify this, take a look at the Actions menu for MyJavaPortlet.
5. Click the Actions icon in the portlet banner to reveal the available options. As you
are logged in as Harvey you should see five options: Move, Maximize, Refresh,
Customize, and Personalize, as shown in Figure 8–49.
You can, as user Harvey, customize or move any content on this page and when
you do so you'll modify the page for all users. This differs from personalizations
which are only applicable to the user who is making the changes. Notice that as
user Harvey, you do not see the portlet title personalizations made earlier by user
Cho.
6. Click Logout.
3. Click Login.
If authentication is successful, you should see Welcome.jspx but you wont' see any
page navigation buttons as user King is not authorized to view MyPage,
MyWeather, or MyContent.
4. Click Logout.
As user Harvey is authorized to view MyPage, you should see MyPage in your
browser.
3. Click Logout.
4. Try to access MyPage again. In your browser, enter the same URL used in Step 1.
5. Now login as user King who is not authorized to view MyPage. Enter
King/welcome, and click Login.
This time, you should see an "Unauthorized" message.
To authorize access, you must grant permissions through the data control's
executables and bindings. Let's do that now.
Let's work through all the steps for the table data control to see how this is done.
5. First, edit authorizations for the table data control executable getItemsIter:
a. Under executables, right-click getItemsIter, and select Edit Authorization.
b. Let's grant full permissions to any logged-in user. To do this, check all the
boxes for the users role as shown in Figure 8–53.
c. Click OK.
6. Now edit authorizations for the methodAction binding of table data control
getItems:
a. Under bindings, right-click getItems, and select Edit Authorization.
b. To grant permission to any logged-in user, check the boxes for the users role as
shown in Figure 8–54.
c. Click OK.
7. And finally, edit authorizations for each attributeValues binding of table data
control getItems1:
a. Right-click getItems1, and select Edit Authorization.
b. To grant full permissions to the first attribute
MyTutorialContent.getItems.name, check all the boxes for the users role as
shown in Figure 8–55.
c. Repeat for every attribute listed in the Grant Permissions box. For example,
expand the Grant Permissions box, choose MyTutorialContent.getItems.path,
check all the boxes, and repeat.
d. Click OK.
8. Before running the page again, stop the embedded OC4J Server. Choose Run,
Terminate, Embedded OC4J Server from the main menu.
9. Run MyContent.jspx again, and login with valid credentials such as
Harvey/welcome.
This time you should see files listed in the table data control as shown in
Figure 8–56.
If you want, you can enable access to the other data controls on MyContent.jspx by
repeating steps 5 through 7.
Congratulations! You've completed the lesson and secured your first WebCenter
application. In the final lesson you'll learn about deployment and how to use
Enterprise Manager (a browser-based tool that enables administrators to deploy,
configure, and manage WebCenter applications).
In this lesson you will deploy your tutorial application to the WebCenter
Preconfigured OC4J. Deploying an application involves packaging up all the required
files in a standard J2EE format and directory structure—a WAR file or an EAR file.
All the packaging and deployment instructions for a WebCenter application are
configured through a deployment profile. A deployment profile is a configuration file
that names the pages, portlets, customizations, and metadata comprising the
application, the type and name of the archive file to be created, dependency
information, platform-specific instructions, and more.
There is a special deployment profile, specifically for WebCenter applications—the
WebCenter Application Deployment Profile. This profile handles content that is unique to
WebCenter applications such as portlets, content repository data controls,
customizable component, and so on.
You can deploy WebCenter applications directly from Oracle JDeveloper to a
standalone OC4J instance providing that the standalone OC4J and Oracle JDeveloper
are on the same computer or have access to a common network drive. You'll learn
more about single-step deployment in this lesson. You'll also learn how to manage
WebCenter applications through the Application Server Control Console.
Introduction
You'll deploy the tutorial application by completing the following steps:
■ Step 1: Creating a WebCenter Application Deployment Profile
■ Step 2: Deploying Directly to the Preconfigured OC4J
■ Step 3: Migrating Your Security Policy
■ Step 4: Running Your Deployed Application
■ Step 5: Using Application Server Control Console to Manage WebCenter
Applications
Prerequisites
Before you deploy your WebCenter application:
1. Check that:
■ A connection exists between the WebCenter Preconfigured OC4J and Oracle
JDeveloper.
■ The WebCenter Preconfigured OC4J is running.
For more detail, see Step 2: Setting Up Your Connection (Chapter 3).
2. Migrate the tutorial users/roles to the WebCenter Preconfigured OC4J—the
deployment target. Run the JAZN Migration Tool in realm mode to merge the users
and roles on the target OC4J:
a. Before running the JAZN Migration Tool, update your class path to contain
references to: JDEVHOME\j2ee\home\jazn.jar and
JDEVHOME\BC4J\lib\adfshare.jar
For example, enter the following in a command prompt:
set
CLASSPATH=JDEVHOME\j2ee\home\jazn.jar;JDEVHOME\BC4J\lib\ad
fshare.jar
Where JDEVHOME points to your JDeveloper installation, for example
C:\myjdev.
b. Next, go to JDEVHOME, and open a command prompt.
c. Run the JAZN Migration Tool, as follows:
java oracle.security.jazn.tools.JAZNMigrationTool -sr
jazn.com -dr jazn.com -st xml -dt xml -sf
WEBCENTERSAMPLE\TutorialContent\system-jazn-data.xml -df
JDEVHOME\jdev\extensions\oracle.adfp.seededoc4j.10.1.3.2.0
\j2ee\home\config\system-jazn-data.xml -m realm
Where WEBCENTERSAMPLE points to where you installed the sample
tutorial files, for example: C:, and JDEVHOME points to your JDeveloper
installation, for example: C:\myjdev. See Figure 9–1.
5. Click OK.
You should see the new deployment profile displayed under ViewController,
Resources (Figure 9–3).
8. Select Platform from the list on the left, and then choose the connection named
MyLocalOC4J from the Target Connection dropdown list (Figure 9–5).
You defined this connection earlier on, in Chapter 3, "Building and Testing Your
First Portlet".
You don't need to set any more deployment options on this page. If your
application required special libraries, you would select them here.
9. Click OK.
10. Click Save All in the JDeveloper tool bar.
During development, you can deploy WebCenter applications in a single step directly
from JDeveloper to a standalone OC4J. You'll see how this works in the next step.
You can deploy your WebCenter applications in a production environment using
Application Server Control Console. In the process, you package your WebCenter
application in a generic EAR or WAR file. After that, you run the Predeployment tool
against this file to remap the WebCenter application's external dependencies, for
example, portlet producer end points and the MDS location. The Predeployment tool
generates a targeted EAR file that is ready to deploy on the remote system.
3. Click OK.
4. Wait for the Configure Application window to be displayed (Figure 9–7), and then
click OK.
WAR and EAR files are generated and deployed to the preconfigured OC4J. The
EAR file contain a WAR file and a number of configuration (.xml) files. WAR files
contain all the files and libraries used by the application.
At the end of deployment you should see -- Deployment finished -- in the
Deployment-Log window. If you get this message you should be able to access the
deployed application but you won't be able to log-in. You still need to migrate your
application's security policy (stored in app-jazn-data.xml) to the preconfigured
OC4J's system-jazn-data.xml file. Let's do that now.
Note: You'll find more about the JAZN Migration Tool in the Oracle
WebCenter Framework Developer's Guide
This tutorial assumes that localhost can be used in a URL to refer to the local
computer on which your preconfigured OC4J installation resides. (If this is not the
case, replace localhost with your computer's IP address.)
2. Log in as user Harvey, and enter the password welcome.
3. Click each page navigation button to check that your application works as
expected.
Congratulations! You've just deployed your first WebCenter application.
From here you can use the buttons to redeploy and undeploy the application. You
can also stop and restart the application from here.
Under Related Links you should see a Producers and Portlets link. The
information available from here is specific to WebCenter applications and it
appears only when producer/portlet metrics are available. Statistics become
available when a page containing portlets is accessed for the first time. If you did
not display a page containing portlets during Step 4: Running Your Deployed
Application, do so now (open MyPage or MyWeather), and then refresh the
Application Server Control Console.
6. Click Producers and Portlets to browse the metrics available for your tutorial
application.
You should see the Portlet Producers page (similar to that shown in Figure 9–10).
From this page, you can monitor the status and performance of producers and
portlets used by your WebCenter application.
Summary
In this tutorial you built a simple, secure WebCenter application. You tested and
deployed it, then used the Application Server Control Console to monitor its portlet
producers.
Now you're more familiar with Oracle JDeveloper and Oracle WebCenter Framework
functionality, you can start building your own application. For further assistance, refer
to the Oracle WebCenter Framework Developer's Guide.
This Appendix describes how to set up an identity store—a requirement for Chapter 8,
"Providing Security".
Oracle ADF Security authenticates users against a given resource provider. In this
tutorial, we make use of the lightweight XML resource provider
system-jazn-data.xml supplied with the embedded OC4J. Well-suited to small
scale applications like this tutorial, this resource provider is located at:
JDEVHOME\jdev\system\oracle.j2ee.10.1.3.xx.xx\embedded-oc4j\conf
ig
Note: The system directory is created when you open JDeveloper for
the first time.
Only follow the instructions in this Appendix if you would like to enter these tutorial
users/roles from scratch for yourself. Maybe you want to learn more about the
process, or perhaps you are already building secure applications with JDeveloper and
you do not want to overwrite the users, roles, and policies that you've added.
To set up the identity store, completing the steps in the following sections:
■ Creating Users
■ Creating Roles and Assigning User Members
■ Making Tutorial Users and Roles Available to JDeveloper's Authorization Editor
a. Click Add.
b. For Name, enter Singh.
c. In the Credentials field, enter the password welcome.
d. Click OK. Singh should appear in the Users list.
e. For Description, enter This User may view pages.
5. Now repeat Step 4. Create three more users named Cho, Harvey, and King. Use the
credentials and descriptions shown in the following table:
All four new users should appear in the Users list as shown in Figure A–2.
Figure A–3 Default Roles for the Global Security Realm jazn.com
4. Create a new role named page-viewer, and assign user Singh to this role.
a. Click Add.
b. Enter the Name page-viewer, and click OK.
c. Click the Member Users tab, and move Singh to the list on the right.
5. Now repeat Step 4. Add three more roles and assign a member user to each role as
outlined in this table:
6. Place all the users (except anonymous) into the users role:
a. Select the users role.
b. Click the Member Users tab, and move users (Singh, Cho, Harvey, King,
JtaAdmin, and oc4jadmin) to the list on the right as shown in Figure A–5.
The users role maintains a list of every valid user. In Chapter 8, "Providing
Security", you map this role to a J2EE security role called ValidUsers (for details,
see Step 2: Configuring ADF Security Settings).
7. Click OK to save the role definitions to the embedded OC4J's
system-jazn-data.xml file.
In the next step, you'll make these users/roles available through the Authorization
Editor in Oracle JDeveloper. You assign page permissions through this editor in
Chapter 8 Step 4: Securing Pages.
A defining, 7-2
see also file system data control, 7-2
ADF Security deployment, 9-1
see Oracle ADF Security, 8-1 deploying to preconfigured OC4J, 9-5
ADF, see Application Development Framework, 1-6 using Enterprise Manager, 9-8
adfAuthentication servlet, 8-6 deployment descriptor
granting access to, 8-8 defining, 8-26
ADFContext library, 8-14 deployment profile
advancedSearch method, 7-4 WAR file, 3-13
anyone role, 8-23 WebCenter Application WAR, 9-2
app-jazn-data.xml Do As Privileged mode, 8-6, 8-29
about, 8-24
migrating security information, 9-6
Application Development Framework (ADF), 1-6 E
authentication EAR deployment, 9-1
defining users and roles, A-1 embedded OC4J
enabling, 8-5 copying sample users and roles, 2-2
form-based, 8-7 defining users and roles, A-1
testing, 8-30 terminating, 3-29
Authorization Editor testing applications, 3-25
data controls, 8-36 Enterprise Manager
pages, 8-23 accessing the Application Server Control
console, 9-8
B monitoring producers and portlets, 9-9
buttons (page navigation)
adding, 8-18 F
hiding from unauthorized users, 8-20 faces-config.xml, 8-18
file system data control
C applying security, 8-35
default attributes, 7-3, 7-10, 7-20
CacheResults property (content), 7-16
defining, 7-2
connection to preconfigured OC4J, 3-10
methods, 7-4
Content DB, 1-5
publishing a file, 7-5
content publishing, 7-1
publishing content in a table, 7-8
content repository data control, 7-2
publishing content in tree format, 7-17
context root, 9-3
files
customizable components
publishing a file link, 7-5
definition, 4-2
publishing content in a table, 7-8
editing properties, 4-9
publishing content in a tree, 7-17
customize mode
folders
enabling, 3-6
publishing content in a table, 7-8
testing, 3-25
publishing content in a tree, 7-17
D
data control
Index-1
G Login page
creating, 8-2
getAttributes method, 7-4
error page, 8-7, 8-35
getItems method, 7-4
Login.jspx, 8-2
publishing content in a table, 7-8
logout link
publishing content in tree format, 7-17
hiding from unauthenticated users, 8-17
getURL method, 7-4
on MyContent.jspx, 8-25
publishing file links, 7-5
on MyPage.jpsx, 8-24
graphics
on MyWeather.jspx, 8-25
adding to a page, 4-4
on Welcome.jspx, 8-16
adding to the Rich Text Portlet, 5-5
M
I
MDS repository, 9-5
identity store
MyContent.jspx
assigning page privileges, 8-23
authorizing access to data controls, 8-35
creating roles, A-4
authorizing access to the page, 8-25
creating users, A-2
creating, 7-5
setting up system-jazn-data.xml, A-1
MyPage.jspx
using tutorial sample, 2-2
authorizing access to, 8-24
images
creating, 3-16
adding to a page, 4-4
MyTutorialContent (data control), 7-2
adding to the Rich Text Portlet, 5-5
MyTutorialContent2 (data control), 7-17
MyWeather.jspx, 6-1
J authorizing access to, 8-25
creating, 6-5
J2EE security roles
MyWeatherPageDef.xml, 6-7, 6-11
configuring, 8-8
mapping identity store roles, 8-25
J2EE Web Context Root, 9-3 N
JAAS Mode, 8-6 navigation rule
JavaServer Faces page see JSF navigation rule, 8-18
creating, 3-16 NDValue, 7-15
running, 3-25 nt file, 7-15
JAZN Migration Tool nt folder, 7-15
merging application security policy, 9-6
merging users/roles, 9-2
setting class path, 9-2 O
JAZN settings, 8-7, 8-29 OC4J
jazn.com, 8-7, A-2 deployment descriptor, 8-26
JCR adapters, 1-4 JDeveloper’s embedded, 3-25
JCR data controls, 1-4 starting the preconfigured, 3-10
JDeveloper OmniPortlet, 6-1
see Oracle JDeveloper, 1-6 adding to a page, 6-10
JSF navigation rule configuring a Web Service, 6-12
defining, 8-18 description, 1-3
JSF Navigation Diagram, 8-19 portlet parameters, 6-11
JSR 168 Java portlet producer registration, 6-2
building, 3-4 using, 6-10
deploying, 3-13 Oracle ADF Security, 8-1
registering, 3-20 enabling, 8-5
testing, 3-22 Security Wizard, 8-5
settings, 8-5
L Oracle Content Database, 1-5
Oracle JDeveloper
library requirements, 3-18
and ADF, 1-6
lifecycle support, 1-4
downloading, 2-1
lightweight XML provider, 8-6
embedded OC4J, 3-25
login link
Oracle PDK portlet producer, 6-2
defining, 8-12
Oracle Technology Network, viii
hiding from authenticated users, 8-14
Oracle WebCenter Suite, 1-2
Index-2
orion-web.xml, 8-25 installing, 3-10
OTN migrating security policy, 9-2
see Oracle Technology Network, viii readme, 3-11
starting and stopping, 3-10
test pages, 5-2
P
Predeployment Tool, 1-5, 9-4
page navigation producer registration
command buttons, 8-18 Omniportlet, 6-2
see JSF navigation rule, 8-18 Rich Text portlet, 5-2
page navigation buttons sample WSRP portlets, 6-2
adding, 8-18
hiding from unauthorized users, 8-20
page permissions, 8-22
R
page variables RangeSize property (content), 7-16, 7-23
mapping portlet parameters, 6-16 Rich Text portlet
OmniPortlet parameter mappings, 6-11 adding to a page, 5-3
Parameter Form Portlet parameter mappings, 6-7 customizing at run time, 5-5
panelCustomizable description, 1-4
description, 4-2 producer registration, 5-2
using, 4-3 roles
Parameter Form Portlet, 6-1 anyone role, 8-23
adding to a page, 6-5 assigning page privileges, 8-23
customization, 6-9 default roles (embedded OC4J), A-4
passing parameters, 6-15 defining (embedded OC4J), A-4
portlet parameters, 6-5, 6-7 mapping in orion-web.xml, 8-25
producer registration, 6-2 migrating to preconfigured OC4J, 9-2, A-6
parameters see also J2EE security roles, 8-8
portlet parameters, 6-5, 6-10 rules (Tree Binding Editor), 7-20
Web Service parameters, 6-12 Run As mode, 8-29
personalize mode, 3-6, 8-32
portlet
S
allowing users to customize, 3-7
allowing users to personalize, 3-6 sample files
building a JSR 168, 3-4 copying sample system-jazn-data.xml, 2-2
deploying to OC4J, 3-10, 3-13 downloading, 2-1
exposing as a web service, 3-16 search method, 7-4
files generated for, 3-10 security
registering with WebCenter Framework, 3-20 ADF Security settings, 8-5
testing, 3-22 authorizing access to data controls, 8-35
portlet communication, 6-1 authorizing access to pages, 8-22
configuring, 6-15 creating a login page, 8-2
testing, 6-16 creating a Welcome page, 8-10
portlet parameters setting up an identity store, A-1
mapping to page variables, 6-8 showDetailFrame
OmniPortlet, 6-11 description, 4-2
Parameter Form Portlet, 6-5, 6-7 using, 4-6
passing parameters, 6-15 system-jazn-data.xml
portlet producers adding users and roles, A-1
accessible through Preconfigured OC4J, 3-11 Authorization Editor, 8-23
monitoring through Enterprise Manager, 9-9 copying sample data, 2-2
Oracle PDK portlets, 6-2 defining permissions on data controls, 8-36
WSRP portlets, 6-2 defining permissions on pages, 8-23
portlet provider making available to Authorization Editor, A-6
see WAR file, 3-13 Oracle ADF Security, 8-6
preconfigured OC4J preparing user data, 8-2
accessing sample portlets, 6-1
accessing the Application Server Control T
console, 9-8
connecting to, 3-10 tag library requirements, 3-18
deploying tutorial application, 9-5
Index-3
U
users
assigning to roles (embedded OC4J), A-4
default users (embedded OC4J), A-2
defining users (embedded OC4J), A-2
migrating to preconfigured OC4J, 9-2, A-6
W
WAR file
creating, 3-13, 9-2
deployment, 9-1
Weather Web Service
configuring, 6-12
parameters, 6-12
web application archive
see WAR file, 3-13
Web Clipping portlet, 1-4
Web Service see Weather Web Service, 6-12
WebCenter application
context root, 9-3
creating new, 3-2
deployment, 9-1
deployment profile, 9-2
security, 8-1
WAR, 1-4, 9-2
WebCenter Framework, description, 1-3
WebCenter Services, 1-5
web.xml, 8-5, 8-9
Welcome page
authorizing public access, 8-22
creating, 8-10
login link, 8-12
logout link, 8-17
page navigation buttons, 8-18
Welcome.jspx, 8-10
WSDL
publishing a portlet as, 3-16
WSRP portlet producer
creating, 3-20
Parameter Form Portlet, 6-2
X
XML resource provider, 8-5
Index-4