Skip Headers
Oracle® WebCenter Framework Tutorial
10g (10.1.3.2.0)

Part Number B31072-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

7 Adding Content to Your Page

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.

Figure 7-1 MyContent.jspx at the End of Lesson 7

Chapter Overview
Description of "Figure 7-1 MyContent.jspx at the End of Lesson 7"

Introduction

You'll add content to the tutorial application in the following steps:

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.

Step 1: Creating a Data Control

In this step you'll define a data control that can access and publish some sample tutorial content stored on your file system. A data control is a container for all the data objects, collections, methods, and operations used to create UI components within your application.

  1. In the Applications Navigator, right-click Model, and choose New.

  2. Expand the Business Tier node and select Content Repository.

  3. Select Content Repository Data Control, and then click OK to display the wizard.

    This wizard creates a data control for a content repository, even when the content is on a file system.

  4. Click Next to skip the Welcome page.

  5. Name the data control. Enter MyTutorialContent, and then click Next.

  6. We want to publish content on your file system. Click the Repository Type drop-down list, and choose File System.

    You can also set up a data control to access content in an Oracle Content DB repository, or an OracleAS Portal repository. For detailed information about how to set up these types of data controls, see the Oracle WebCenter Framework Developer's Guide.

  7. In the Base Path field, enter the path to the sample content you unzipped earlier. For example: C:\TutorialContent

    This shows the data control where to find your content.

  8. Click the Test button to check whether you've entered the connection details correctly. You should see a Success! message like Figure 7-2.

    Figure 7-2 File System Data Control - Testing the Connection

    Test Connection to the File System
    Description of "Figure 7-2 File System Data Control - Testing the Connection"

  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.

    Figure 7-3 File System Data Control - Custom Attribute Configuration

    Data Control Palette - MyTutorialContent
    Description of "Figure 7-3 File System Data Control - Custom Attribute Configuration"

  11. To accept the default attribute set, click Finish.

    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.

    Figure 7-4 Files for File System Data Control MyTutorialContent

    Files for the New Data Control
    Description of "Figure 7-4 Files for File System Data Control MyTutorialContent"

  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).

    Figure 7-5 Data Control Palette - MyTutorialContent

    Data Control Palette - MyTutorialContent
    Description of "Figure 7-5 Data Control Palette - MyTutorialContent"

    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.

Step 2: Adding Content to a Page at Design Time

In this step, you'll learn how to publish a hyperlink to a file using the data control method getURI. Let's start by creating a brand new page called MyContent.jspx on which you'll add a link to one of the sample files (help.html).

  1. Create a new Java Server Faces page named MyContent.jspx.

    1. In the Applications Navigator, right-click ViewController, and select New.

    2. In the Categories pane, under Web Tier, select JSF.

    3. Under Items, select JSF JSP, and click OK.

    4. Click Next to skip the Welcome page.

    5. In the File Name field, enter: MyContent

    6. Under Type, click JSP Document, and then click Next.

    7. Choose Automatically Expose UI Components in a New Managed Bean, and then click Next.

    8. On the Tag Libraries page, make sure the following libraries appear in the Selected Libraries pane:

      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

    9. There is no need to set any other options, so click Finish on this page.

    MyContent.jspx should open in the Visual Editor, ready for us to begin adding content from the file system. (If the page doesn't appear, click the Design tab.)

  2. In the Data Control Palette, expand the getURI(String) node for MyTutorialContent.

    You should see one parameter (path), as well as one method return attribute URI listed here (Figure 7-6).

    Figure 7-6 Data Control Palette - MyTutorialContent.getURI

    MyTutorialContent.getURL
    Description of "Figure 7-6 Data Control Palette - MyTutorialContent.getURI"

  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.

    Figure 7-7 JDeveloper Context Menu for getURI

    JDeveloper Context Menu for getURL
    Description of "Figure 7-7 JDeveloper Context Menu for getURI"

  5. To publish a link to a Help page located at C:\TutorialContent\help.html, use the path parameter to point to the file by entering: /help.html

    Make sure that you include a forward slash (Figure 7-8).

    Figure 7-8 GetURI - Action Binding Editor

    Action Binding Editor
    Description of "Figure 7-8 GetURI - Action Binding Editor"

  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.

    Figure 7-9 GoLink Properties - Configuring Help Link

    GoLink Properties
    Description of "Figure 7-9 GoLink Properties - Configuring Help Link"

  9. Click OK to close the GoLink Properties window.

  10. Click the Save All icon in the JDeveloper toolbar.

  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

    File Link Through the File System Data Control
    Description of "Figure 7-10 File Link Through the File System Data Control"

Step 3: Displaying Folder Content in a Table

In this step, you'll learn how to publish file and folder information in a table using the data control method getItems. You'll then create a table (similar to the one shown in Figure 7-11) that lists all the files located at C:\TutorialContent. Each file name in the table will contain a hyperlink to the actual file.

Figure 7-11 File System Content Displayed as Hypertext Links

Folder Content Displayed as a HypertextLinks
Description of "Figure 7-11 File System Content Displayed as Hypertext Links"

  1. In the Applications Navigator, double click MyContent.jspx to open the page in the Visual Editor.

  2. In the Data Control Palette, expand the getItems node for MyTutorialContent. You should see two parameters (path and type) and the Return options shown in Figure 7-12.

    Figure 7-12 Data Control Palette - MyTutorialContent.getItems

    MyTutorialContent.getItems
    Description of "Figure 7-12 Data Control Palette - MyTutorialContent.getItems"

  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.

    Figure 7-13 JDeveloper Context Menu for getItems

    JDeveloper Context Menu for getItems
    Description of "Figure 7-13 JDeveloper Context Menu for getItems"

    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.

    Figure 7-14 getItems - Action Binding Editor

    Action Binding Editor
    Description of "Figure 7-14 getItems - Action Binding Editor"

  7. Click OK.

    You should see the Edit Table Columns window (Figure 7-15).

    Figure 7-15 Edit Table Columns - Defaults

    Edit Table Columns
    Description of "Figure 7-15 Edit Table Columns - Defaults"

    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.

    Figure 7-16 Edit Table Columns - Customizing DIsplay Labels

    Edit Table Columns
    Description of "Figure 7-16 Edit Table Columns - Customizing DIsplay Labels"

  9. Click OK.

    You should see a table on MyContent.jspx that looks something like Figure 7-17.

    Figure 7-17 Read-Only Table for Publishing Folder Content

    Read-Only Table for Publishing Folder Content
    Description of "Figure 7-17 Read-Only Table for Publishing Folder Content"

  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.

    Figure 7-18 Browser - Folder Content Displayed in a Table

    Folder Content in Read Only Table
    Description of "Figure 7-18 Browser - Folder Content Displayed in a Table"

    By default, the table displays file/folder attributes as read-only text (af:outputText). In the next step, you'll learn how to display the Name attribute as an ADF GoLink (af:goLink).

  11. In the Structure window as shown in Figure 7-19, expand the first column of the table (af:column - Name) to reveal the default display format af:outputText - #{row.name}.

    Figure 7-19 Default Display Format for the Name Column

    Default Formatting for Name Column
    Description of "Figure 7-19 Default Display Format for the Name Column"

  12. Right-click af:outputText - #{row.name}, and click Convert.

  13. From the pull-down menu, choose ADF Faces Core.

  14. Choose GoLink (Figure 7-20).

    Figure 7-20 Convert OutputText to a GoLink

    Convert OutputText to a GoLink
    Description of "Figure 7-20 Convert OutputText to a GoLink"

  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:

    1. For the Text field, click Bind.

    2. Expand JSP Objects, and then expand row.

    3. Double-click name to select the expression #{row.name}.

    4. Click OK.

  18. To generate URIs for the HTTP hyperlinks:

    1. For the Destination field, click Bind.

    2. Expand JSP Objects, and then expand row.

    3. Double-click URI to select the expression #{row.URI}.

    4. Click OK.

    Figure 7-21 GoLink Properties - Configuring File Names as Hyperlinks

    GoLink Properties
    Description of "Figure 7-21 GoLink Properties - Configuring File Names as 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.

    Figure 7-22 Browser - Folder Content Displayed as Hyperlinks

    Folder Content Displayed as Hyperlinks
    Description of "Figure 7-22 Browser - Folder Content Displayed as Hyperlinks"

  21. Click one of the file names.

    The file you pick should display in a browser window.

  22. Click the name of a folder.

    This time you'll see an authorization error because you cannot access a folder through a direct URL. Folders may be accessed through a data control only.

    Before moving onto the next step, let's summarize what you've done so far. First you created a table based on the MyTutorialContent data control. You saw how, by default, the table publishes file system information in plain, unformatted text. You then applied some formatting to the file and folder names to display them as hypertext links.

    To finish off, let's tidy up the table. Let's configure the table to show only the Name column, and limit the display to files only.

  23. Back in JDeveloper, configure the table to show the Name column only:

    1. In the Structure window, right-click the af:table -table1 node, and choose Properties.

    2. Click the Column Summary tab. Use the Delete button to remove all but the Name column (Figure 7-23).

      Figure 7-23 Table Properties - Editing Columns

      Table Properties - Column Summary Tab
      Description of "Figure 7-23 Table Properties - Editing Columns"

    3. Click the Column Details tab.

    4. For Header Text, enter My Tutorial Files as shown in Figure 7-24.

      Figure 7-24 Table Properties - Editing Column Display Options

      Table Properties - Column Details Tab
      Description of "Figure 7-24 Table Properties - Editing Column Display Options"

    5. Click OK.

  24. To configure the table to show files only (not folders), you'll need to edit the page definition file:

    1. Right-click MyContent.jspx, and select Go to Page Definition.

    2. In the Structure window, expand bindings and getItems (Figure 7-25).

      Figure 7-25 Configure the type Property in MyContentPageDef.xml

      Table Properties - Column Details Tab
      Description of "Figure 7-25 Configure the type Property in MyContentPageDef.xml"

    3. Double-click type.

    4. 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.

      Figure 7-26 NDValue - Configuring File Display Only

      NDValue - Display Files Only
      Description of "Figure 7-26 NDValue - Configuring File Display Only"

  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:

    1. In Structure view, expand the executables section.

    2. Select the method iterator getItemsIter.

    3. From the View menu, choose Property Inspector to view the default settings.

    4. The RangeSize property controls how many file/folder items are displayed on each page. For this tutorial, let's keep the default RangeSize 10.

    5. 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.

  27. Run the page again.

    The list of files should look something like Figure 7-27. This time, no folders are displayed.

    Figure 7-27 Browser - Files Only Displayed as Hypertext Links

    Folder Content Displayed as Hypertext Links
    Description of "Figure 7-27 Browser - Files Only Displayed as Hypertext Links"

  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.

Step 4: Displaying Folder Content in a Tree

In this step you'll publish file and folder content in a hierarchal tree format using the getItems method. You'll create a tree (similar to the one shown in Figure 7-28) displaying files located at C:\TutorialContent and each file name in the tree will provide a hyperlink to the actual file. But first, let's create a new data control.

Figure 7-28 File System Content Published in a Tree

Content Published in a Tree
Description of "Figure 7-28 File System Content Published in a Tree"

  1. In the Applications Navigator, right-click Model, and choose New.

  2. Expand the Business Tier node, and select Content Repository.

  3. Select Content Repository Data Control, and then click OK.

  4. Click Next to skip the Welcome page.

  5. Name the data control. Enter MyTutorialContent2, and then click Next.

  6. We want to use this data control to publish content from a file system, so click the Repository Type drop-down list, and choose File System.

  7. In the Base Path field, enter the path to the content you unzipped earlier, for example C:\TutorialContent, and then press Enter.

  8. Click the Test button to check whether you've entered the connection details correctly. You should see a Success! message.

  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, then click Finish.

  10. 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 (Figure 7-29).

    Figure 7-29 Data Control Palette - MyTutorialContent2

    Data Control Palette - MyTutorialContent2
    Description of "Figure 7-29 Data Control Palette - MyTutorialContent2"

    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).

    Figure 7-30 MyTutorialContent2.getItems

    MyTutorialContent2.getItems
    Description of "Figure 7-30 MyTutorialContent2.getItems"

  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.

    Figure 7-31 JDeveloper Context Menu for getItems

    JDeveloper Context Menu for getItems
    Description of "Figure 7-31 JDeveloper Context Menu for getItems"

    You should see the Action Binding Editor.

  15. To create a tree that displays everything under the base path (C:\TutorialContent), enter / for the path parameter as shown in Figure 7-32. Make sure you enter a forward slash, not a backslash.

    Leave the type blank, as the tree must show both files and folders.

    Figure 7-32 Action Binding Editor

    Action Binding Editor
    Description of "Figure 7-32 Action Binding Editor"

  16. Click OK.

    The Tree Binding Editor is displayed (Figure 7-33). Let's take a quick look at this page.

    Figure 7-33 Tree Binding Editor - Default Edit Rule Tab

    Tree Binding Editor - Default Edit Rule Tab
    Description of "Figure 7-33 Tree Binding Editor - Default Edit Rule Tab"

    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.

    Figure 7-34 Tree Binding Editor - Rule Selections

    Tree Binding Editor - Rule Selections
    Description of "Figure 7-34 Tree Binding Editor - Rule Selections"

  18. For the Branch Rule Accessor, select Items.

    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.

    Figure 7-35 New Rule Confirmation Dialog

    New Rule Confirmation Dialog
    Description of "Figure 7-35 New Rule Confirmation Dialog"

  20. Click OK to close the message box and display the Show Rules tab (Figure 7-36).

    Figure 7-36 Tree Binding Editor - Show Rules Tab

    Tree Binding Editor - Show Rules Tab
    Description of "Figure 7-36 Tree Binding Editor - Show Rules Tab"

  21. Click OK.

    Now you should see a tree structure similar to Figure 7-37 displayed on MyContent.jspx.

    Figure 7-37 Tree for Navigating Folder Content

    Tree for Navigating Folder Content
    Description of "Figure 7-37 Tree for Navigating Folder Content"

  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).

    Figure 7-38 Folder Content Displayed in a Tree

    Folder Content Displayed in a Tree
    Description of "Figure 7-38 Folder Content Displayed in a Tree"

    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).

    Figure 7-39 Tree Displays File and Folder Names

    Tree Displays File and Folder Names
    Description of "Figure 7-39 Tree Displays File and Folder Names"

    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).

    Figure 7-40 Default Display Format for Trees

    Default Display Format for Trees
    Description of "Figure 7-40 Default Display Format for Trees"

  29. Add an ADF Switcher component:

    1. Right-click nodeStamp, and choose Insert Inside nodeStamp, ADF Faces Core.

    2. Choose Switcher, and then click OK (Figure 7-41).

      Figure 7-41 af:switcher Component

      outputText Converted to af:switcher Component
      Description of "Figure 7-41 af:switcher Component"

    3. Right-click af:switcher, and click Properties.

    4. For FacetName, enter the expression: #{node.primaryType}

    5. Click the Advanced Properties tab.

    6. For DefaultFacet, enter nt:file, and then click OK.

  30. Now insert two facets for the switcher:

    1. Right-click af:switcher, choose Insert Inside af:switcher, JSF Core, Facet.

    2. Name the first facet nt:folder, and click OK.

    3. Now repeat these steps, adding a second facet named nt:file (Figure 7-42).

      Figure 7-42 Switcher Component with Two Facets

      outputText Converted to af:switcher Component
      Description of "Figure 7-42 Switcher Component with Two Facets"

  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:

    1. In the Structure Window, select af:outputText - #{node.name}.

    2. Drag and drop the af:outputText component on top of f:facet - nt:folder (Figure 7-43).

      Figure 7-43 Display nt:folder Facet as outputText

      outputText Converted to af:switcher Component
      Description of "Figure 7-43 Display nt:folder Facet as outputText"

  32. Use an af:goLink component to display file names as hyperlinks:

    1. Right-click f:facet - nt:file, and then choose Insert Inside f:facet - nt:file, ADF Faces Core.

    2. Choose GoLink, and click OK.

    3. Right-click af:goLink - goLink 1, and click Properties.

    4. For the link's Text, enter the expression: #{node.name}

    5. For the link's Destination, enter the expression: #{node.URI}

    6. Click OK.

    Use the Structure window to check the af:switcher configuration. It should look like Figure 7-44.

    Figure 7-44 Switcher Showing Configured Facets

    Switcher Showing Configured Facets
    Description of "Figure 7-44 Switcher Showing Configured Facets"

  33. Click the Save All icon in the JDeveloper toolbar.

  34. Run the page again.

    This time, you'll see a tree of hyperlinked file names similar to Figure 7-45.

    Figure 7-45 Content Published in a Tree

    Content Published in a Tree
    Description of "Figure 7-45 Content Published in a Tree"

  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.

Step 5: Searching Folder Content

File system data controls provide a Search method for locating data and documents that are exposed through a data control. In this step you'll learn how to use this method to build a search form that enables users to search for content by file name and keyword, and display search results in a table.

At the end of this exercise, your search form will look similar to that shown in Figure 7-46. Let's get started!

Figure 7-46 Search Form Based On Data Control MyTutorialContent2

Content Published in a Tree
Description of "Figure 7-46 Search Form Based On Data Control MyTutorialContent2"

  1. In the Data Control Palette, expand the Search node under MyTutorialContent2 (Figure 7-47).

    Figure 7-47 MyTutorialContent2.Search

    MyTutorialContent2.getItems
    Description of "Figure 7-47 MyTutorialContent2.Search"

  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.

    Figure 7-48 JDeveloper Context Menu for the Search Method

    JDeveloper Context Menu for getItems
    Description of "Figure 7-48 JDeveloper Context Menu for the Search Method"

    Now you should see the Action Binding Editor.

  4. We want to search for everything under the base path (for example, C:\TutorialContent), so enter / for the path parameter. Make sure you enter a forward slash, not a backslash (Figure 7-49).

    Figure 7-49 Action Binding Editor for Search Method

    Action Binding Editor
    Description of "Figure 7-49 Action Binding Editor for Search Method"

  5. To automatically extend the search to all subdirectories under the location specified through the path attribute, enter true for the isRecursive parameter (Figure 7-49).

    Leave the keyword and namePattern fields blank—you're not going to pre-define any search terms or filename criteria for this search. Instead, you'll provide input fields for both these parameters on the search form so that users can drive the search.

  6. Click OK.

    You should see a command button labeled search displayed on your page. Now let's add some input fields above this button into which a users may enter search criteria.

  7. To enable users to search by file name, add the namePattern parameter:

    1. In the Data Control Palette, expand the Parameters node, and then select namePattern.

    2. Drag and drop the namePattern parameter above the Search button.

    3. From the Create menu, choose Texts, ADF Input Text w/ Label.

    4. In the Structure window, double-click af:inputText #{bindings.namePattern..., and enter a suitable label, for example: Find files with all or part of this file name:

    5. For a Tip, enter: Use % for wildcard searches

    6. Click OK.

  8. To enable users to search for phrases or keyword within file content, add the keyword parameter to the page:

    1. In the Data Control Palette, expand the Parameters node, and select keyword.

    2. Drag and drop the keyword parameter above the Search button.

    3. From the Create menu, choose Texts, ADF Input Text w/ Label.

    4. In the Structure window, double-click af:inputText #{bindings.keyword..., and enter a suitable label such as: Find files containing this word or phrase:

    5. Click OK.

    Your page should look like Figure 7-50.

    Figure 7-50 Search Form With Two Input Parameters

    Action Binding Editor
    Description of "Figure 7-50 Search Form With Two Input Parameters"

  9. Now let's add a table for the search results:

    1. In the Data Control Palette, select the return node below the Search method.

    2. Drag the method return, and drop it below the Search button.

    3. From the Create menu, choose Tables, ADF Read-only Table.

    4. Use the Edit Table Columns dialog to edit some default display settings. First, delete the URI and primaryType columns.

    5. Next, edit the Display Labels for the name, path, and lastModifed columns. For example, enter the labels Files Found, Location, and Last Modified as shown in Figure 7-51.

      Figure 7-51 Edit Display Labels for the Search Results Table

      Action Binding Editor
      Description of "Figure 7-51 Edit Display Labels for the Search Results Table"

    6. 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.

    Figure 7-52 Search Form Based On Data Control MyTutorialContent2

    Content Published in a Tree
    Description of "Figure 7-52 Search Form Based On Data Control MyTutorialContent2"

  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.