Oracle® Fusion Middleware Developer's Guide for Oracle WebCenter 11g Release 1 (11.1.1) Part Number E10148-04 |
|
|
View PDF |
This chapter explains how to integrate the Tags service in a custom WebCenter application at design time.
For more information about managing and including tags, see:
"Setting up the WebCenter Repository" in the Oracle Fusion Middleware Administrator's Guide for Oracle WebCenter
"Working with the Tags Service" in the Oracle Fusion Middleware User's Guide for Oracle WebCenter
This chapter includes the following sections:
Tags enable users to apply their own meaningful terms to items, making those items more easily discoverable in search results and the Tag Center. The Tag Center is a page that displays the interactions between all the tags, tagged items, and their taggers in a WebCenter application.
Having multiple users tag objects contributes to the collective knowledge, which makes searching much more relevant. WebCenter search takes advantage of the knowledge captured by tagging by indicating the relevance of results based on the quality and frequency of their applied tags.
Tags let the users of data (instead of the publishers of data) classify information. In this way, tags act as a personal productivity tool as well as a method to increase searchability for everyone.
For example, suppose your application includes a component that provides a view of departmental human resources contacts. If you enable tags for this component, then a user who comes to it can bookmark it for themselves and assign tags like HR or contacts or department to help for others to find it as well.
The Tags service is available for pages, documents, and custom objects.
You can apply one or more meaningful terms, called tags, to remind yourself and alert other users of the content they might expect to find at the tagged location. Anywhere you see the Tags icon (Figure 23-1), you can apply a tag.
Tags let you apply your own classifications to items. For example, you could apply the tag phone
to a product page that provides useful information about new phones. When you or other users search for phone, the tagged page displays in the search results.
When you access the Tag Center, you see all users who applied the same tag anywhere else in the application. Within the Tag Center, a tag cloud (Figure 23-2) displays all currently applied tags.
A tag cloud is a visual depiction of all tags. Tags are presented according to the frequency of their use—the larger the font, the more the tag has been applied to items. Click a tag in the tag cloud to run a search that returns a list of all items that use the tag.
The Tags service requires that you set up the WebCenter schema and create a database connection to the schema. Tag information is stored in the database. For details, see Section 23.2.1, "Setting up Connections for the Tags Service."
Note:
Typically, when you add tags, you also add a search toolbar to enable searching for the objects with the tags. To add the search toolbar, follow the instructions in Section 24.2.2, "Adding the Search Service at Design Time."There are no additional requirements to use the Tags service. However, to enable the ability to tag pages, you must manually add the Page service libraries to your project. Right-click your ViewController project and select Project Properties and then Libraries and Classpath. Click Add Library and select the WebCenter Page Service and WebCenter Page Service View libraries, as shown in Figure 23-3. Click OK.
Similarly, to enable the ability to tag documents, you must manually add the Document Library service libraries to your project, as shown in Figure 23-4.
At runtime, you can tag custom components, find those tags either through a search or in the Tag Center, and access tagged items through their associated tags. By default, tagged items that are accessed through their tags are rendered in a popup window, but you can override this by specifying other types of open behavior.
For more information about the service at runtime, see Oracle Fusion Middleware User's Guide for Oracle WebCenter.
Note:
You can see the Tags service in action in the sample application, as described in Chapter 2, "Introduction to the WebCenter Sample Application."This section describes required steps for adding this service to your application.
The Tags service requires a connection to the database with the WebCenter schema installed. The script to create the WebCenter schema is included with the product.
For details about installing the database and the WebCenter schema, see Oracle Fusion Middleware Installation Guide for Oracle WebCenter.
To create the database connection:
In the Application Navigator, expand the Application Resources panel.
Right-click Connections, then click New Database.
Enter the following information for your database connection:
Connection Name: WebCenter
Connection Type: Oracle (JDBC)
Username: username
Password: password
Host: host where you install the WebCenter schema; for example, localhost
JDBC Port: port; for example, 1521
SID: system identifier for the database with the same JDBC; for example, ORCL
You must enter the Connection Name exactly as "WebCenter". There are cases when you may want to leverage an existing database connection for WebCenter services, and it may not be possible to change the database connection name to "WebCenter".
To allow WebCenter services to use another database connection by a different name, you must add the following <data-source>
tag as a child of the <wpsC:adf-service-config>
element in the adf-config.xml
file. (adf-service-config
is a child of adf-config
, and data-source
is a child of adf-service-config
or sibling of extension-registry-config
.)
For example:
<adf-config xmlns="http://xmlns.oracle.com/adf/config" xmlns:mdsC="http://xmlns.oracle.com/adf/mds/config" xmlns:wpsC="http://xmlns.oracle.com/webcenter/framework/service" xmlns:jndiC="http://xmlns.oracle.com/adf/jndi/config"> <wpsC:adf-service-config xmlns="http://xmlns.oracle.com/webcenter/framework/service"> <data-source jndi-name="java:/comp/env/jdbc/NewDatabaseConnDS"/> </wpsC:adf-service-config> </adf-config>
Note:
The syntax of the example name is"java:/comp/env/jdbc/NewDatabaseConnDS"
. This is derived from the example name NewDatabaseConn
you would have used to create the database connection in the creation wizard.Click OK.
Note:
While you can set up the connections to back-end servers at design time in Oracle JDeveloper, you can later add, delete, or modify connections in your deployed environment using Enterprise Manager Fusion Middleware Control. For more information, see Oracle Fusion Middleware Administrator's Guide for Oracle WebCenter.To enable basic tagging, you must add either the Tagging Button component or the Tagging Menu Item component and the Tagging - Dialog task flow. In addition, to tag custom objects, you must register a resource viewer to visualize the tagged component when it is discovered by users.
This section describes how to enable tagging by adding the Tagging Button and the Tagging - Dialog task flow.
Note:
To enable the ability to tag pages, you must manually add the Page service libraries to your project. For more information, see Section 23.1.2, "Requirements for the Tags Service."The following JSF components are included in the service:
Tagging Button: When you add a Tagging Button, a Tags link on the page enables you to invoke the Tag This Item (or Tag This Page) dialog at runtime.
Tagging Menu Item: When you add a Tagging Menu Item, a menu option on the page enables you to invoke the Tag This Item (or Tag This Page) dialog at runtime.
Table 23-1 lists the Tags service task flows.
Table 23-1 Tags Service Task Flows
Task Flow | Definition |
---|---|
This task flow displays a dialog that appears to tag a particular object. This does not have any visible user interface rendering when dropped onto a page. It only becomes visible when the tagging button is clicked. |
|
This task flow shows the tags created by the current user, objects tagged by those tags, and a cloud view of the tags. It allows for a service ID input parameter that you can use to filter out tagged items that are not of interest. Because this is a non-public task flow, it requires authentication. |
|
For an object identified by a unique ID, this task flow lists all the other objects that are tagged with similar tags. The input parameters are |
|
This task flow displays a tag cloud, which is a visual depiction of all the tags used. Tags are presented according to the frequency of their use. More frequently used tags display in bold fonts and varying font sizes—the larger the font, the more the tag has been applied. If this task flow and the Tagging - Tagged Items task flow are wired together, then you can click a tag in the tag cloud to see the items that use the tag. (In other words, selecting a tag in the Tagging - Tag Cloud task flow sends the tag word as an event to all interested event consumers, such as the Tagging - Tagged Items task flow.) For more information, see Section 23.3.3, "Using Tagged Cloud and Tagged Items Together." |
|
This task flow displays items or pages that have been tagged. It can refine itself to show only the items tagged with the tag passed to it. This task flow can listen for events sent by the Tagging - Tag Cloud task flow. Note: This task flow should be wired to the Tagging - Tag Cloud task flow, so that tagged items appear in the Tag Center only when a tag is selected in the tag cloud. For more information, see Section 23.3.3, "Using Tagged Cloud and Tagged Items Together." |
To add the Tags service to your WebCenter application:
Follow the steps described in Chapter 3, "Preparing Your Development Environment" to implement security and create a new customizable page in your application.
Ensure that you have set up a database connection to a database with the WebCenter schema installed.
Open the page where you included the search toolbar.
On the Component Palette (All Pages), select the Tagging Button and drop it on the page, inside a PanelGroupLayout
. Make it the first child of the PanelGroupLayout
by placing it to the left of the search toolbar. The Tagging Button enables users to start tagging.
Fill out the Insert Tagging Button dialog. Table 23-2 provides descriptions and example values for the fields in the dialog.
Table 23-2 Fields in the Insert Tagging Button Dialog
Field | Description |
---|---|
ResourceId |
The ID that uniquely identifies the object to which you are binding the Tagging Button. The value in this field need not be static. For example, you could use EL to insert a unique value for each row in a table. For example:
|
ResourceName |
The name of the object to which you are binding the Tagging Button. The value in this field need not be static. For example, you could use EL to insert a unique value for each row in a table.
|
ServiceId |
An application-wide ID. (With custom components, you add this to
|
Figure 23-6 Insert Tagging Button Dialog for a Custom Component
Click OK.
From the Resource Palette, expand WebCenter Services Catalog and Task Flows.
Drag the Tagging Dialog from the Resource Palette and drop it on the page.
When prompted, select Region as the way to create the task flow.
For custom resources, follow the steps described in Section 4.2, "Extending Your Application with Custom Components" to register a resource viewer. For services exposing resources to be tagged (and therefore searched and viewed) WebCenter provides a Resource Action Handling framework. The Tags service uses this framework to allow acting on a search result.
In the Source view where you added the Tags service, you should see something similar to Example 23-1.
Example 23-1 Tagging Button and Tagging - Dialog Task Flow Source
<af:form id="f1"> <af:region value="#{bindings.searchtoolbar1.regionModel}" id="r1"/> <tag:taggingButton resourceId="#{facesContext.viewRoot.viewId}" serviceId="oracle.webcenter.page" resourceName="#{facesContext.veiwRoot.viewId}" id="tb1"/> <af:region value="#{bindings.tagginglaunchdialog1.regionModel}" id="r2"/> </af:form>
Note:
Even if there are multiple Tagging Buttons on the page, only one Tagging Dialogaf:region
is needed.Run the page with the Tagging Button and Tagging - Dialog task flow. When the page renders in the browser, click the Tags link (Figure 23-7).
When the Tag This Page dialog appears, enter the tag home
and click Save. Note that every user of the system can perform this same operation and assign the same tag, which means that you get a weighted collection of tags.
In the search toolbar, type the search criteria home
and click the Search icon.
You should home
under Tags. (Figure 23-8)
Figure 23-8 Search Results with Tagged Items and Tags
For custom resources, you also would see Custom Component 1
under Tagged Items. Click Custom Component 1
and a dialog appears with the resource viewer you just created (Figure 23-9).
The Tags service does not require ADF security.
However, the Tagging - Personal View and Tagging - Dialog task flows do require authentication. Also, if the application is not secured, then pages are not returned in search results for tagged items.
When users are not authenticated, the user name associated with tags in the user's bookmarks are "anonymous." Multiple users using the same unprotected custom WebCenter applications risk overwriting each other's tags.
For information about configuring ADF security, see Section 3.5, "Implementing Security in Your Application."
Note:
You must register a resource viewer to allow custom objects to be found using Search or Tags. For information about how the resource viewer'sauthorizerClass
determines whether users can view the resource, see Section 4.2, "Extending Your Application with Custom Components."This section describes optional features available with this service.
While it is possible to add the Tagging Button and task flows on a page-by-page basis, typically you want to add the search toolbar and tags as part of a page template that you can apply whenever building a page that requires it. To add tags through a page template:
Open the project where you plan to create pages with the Tags service.
Right-click the project name and select New from the context menu.
Under Categories, select JSF and, under Items, select JSF Page Template.
For File Name, enter looksee1template
.
Figure 23-10 Create JSF Page Template Dialog
Click OK.
Go to the Source view and modify the code to be similar to that in Example 23-2.
Example 23-2 Sample JSF Page Template
<af:pageTemplateDef var="attrs"> <af:xmlContent> <component xmlns="http://xmlns.oracle.com/adf/faces/rich/component"> <display-name>looksee1template1</display-name> <facet> <facet-name>content</facet-name> </facet> </component> </af:xmlContent> <af:panelGroupLayout layout="vertical"> <!-- Our toolbar --> <af:panelGroupLayout id="toolbar" layout="horizontal" halign="end" inlineStyle="background-color:cyan;width:100%"> </af:panelGroupLayout> <af:panelStretchLayout startWidth="300" inlineStyle="height:600px; width:100%;"> <f:facet name="start"> <af:panelSplitter id="sidebar" orientation="vertical"> <f:facet name="first"> </f:facet> <f:facet name="second"> </f:facet> </af:panelSplitter> </f:facet> <f:facet name="center"> <af:facetRef facetName="content"/> </f:facet> </af:panelStretchLayout> </af:panelGroupLayout> </af:pageTemplateDef>
On the Component Palette, select the Tagging Button and drop it on the page, inside the PanelGroupLayout
. Make it the first child of the PanelGroupLayout
.
Fill out the Insert Tagging Button dialog as shown in Figure 23-11.
Table 23-3 provides descriptions and example values for the fields in the dialog.
Table 23-3 Fields in the Insert Tagging Button Dialog for a Page
Field | Description |
---|---|
ResourceId |
Unique identifier of your page. In this case, because the resource ID is meant for a page, enter |
ResourceName |
Name of the page. In this case, enter |
ServiceId |
Service identifier that you add to In this case, enter Note: Because |
Figure 23-11 Insert Tagging Button Dialog for a Page
Click OK.
From the Resource Palette, expand the WebCenter Services Catalog and the Task Flows.
Drag Tagging Dialog from the Resource Palette and drop it on the page inside of the panelGroupLayout
.
When prompted, select Region as the way to create the task flow.
Drag Search Toolbar and drop it after the Tagging Dialog you just added to the page template in the panelGroupLayout
.
When prompted, select Region as the way to create the task flow.
Drag Document Library - Recent Documents and drop it in the second facet of the panelSplitter
with identifier sidebar
.
When prompted, select Region as the way to create the task flow.
In the Edit Task Flow Binding dialog, for connectionName
, enter the name of the connection to your document library's content repository; for example, ${'MyFileSystem'}
. For information on how to set up a connection to your content repository, see Section 13.2, "Configuring Content Repository Connections."
The source for your page template should now look similar to Example 23-3.
Example 23-3 JSF Page Template with Tagging and Search
<af:pageTemplateDef var="attrs"> <af:xmlContent> <component xmlns="http://xmlns.oracle.com/adf/faces/rich/component"> <display-name>looksee1template1</display-name> <facet> <facet-name>content</facet-name> </facet> </component> </af:xmlContent> <af:panelGroupLayout layout="vertical"> <!-- Our toolbar --> <af:panelGroupLayout id="top" layout="horizontal" halign="end" inlineStyle="background-color:cyan;width:100%"> <tag:taggingButton resourceId="#{facesContext.viewRoot.viewId}" resourceName="#{facesContext.viewRoot.viewId}" serviceId="oracle.webcenter.page"/> <af:region value="#{bindings.tagginglaunchdialog1.regionModel}" id="tagginglaunchdialog1"/> <af:region value="#{bindings.searchtoolbar1.regionModel}" id="searchtoolbar1"/> </af:panelGroupLayout> <af:panelStretchLayout startWidth="300" inlineStyle="height:600px; width:100%;"> <f:facet name="start"> <af:panelSplitter orientation="vertical"> <f:facet name="first"> <af:region value="#{bindings.taskservicetaskflowdefinition1.regionModel}" id="taskservicetaskflowdefinition1" inlineStyle="position:absolute; left:0px; width:100%; height:100%"/> </f:facet> <f:facet name="second"> <af:region value="#{bindings.doclibrecentdocuments1.regionModel}" id="doclibrecentdocuments1"/> </f:facet> </af:panelSplitter> </f:facet> <f:facet name="center"> <af:facetRef facetName="content"/> </f:facet> </af:panelStretchLayout> </af:panelGroupLayout> </af:pageTemplateDef>
Create two new pages based upon the page template you just created. In the Create JSF Page dialog, select looksee1template1
from the Use Page Template list.
Create a page called Search.jspx
and add the Search task flow in the center facet.
Create a page called Documents.jspx
and add the Document Library - List View task flow as the center facet. In the Edit Task Flow Binding dialog, for connectionName
, enter the name of the connection to your document library's content repository; for example, ${'MyFileSystem'}
. For information on how to set up a connection to your content repository, see Section 13.2, "Configuring Content Repository Connections."
Save your pages.
To run your pages with tags:
In the Applications Navigator, run the Search.jspx
page.
After you log in and the page comes up, click the Tags link.
In the Tag this Page dialog, enter search page test customapp
for Tags (Figure 23-12).
Figure 23-12 Tag this Page Dialog for Search Page
Click Save.
Navigate to Documents.jspx
(or run it separately).
Click the Tags link.
In the Tag this Page dialog, enter doclib documents page test customapp
for Tags (Figure 23-13).
Figure 23-13 Tag this Page Dialog for Documents Page
Click Save.
In the search toolbar for the Documents.jspx
page, enter search
and click the Search icon.
Under Tags, click search
.
For WebCenter services exposing resources to be tagged (and therefore searched and viewed) WebCenter provides a Resource Action Handling framework. For example, rows in a table can be tagged.
To register a resource viewer, see Section 4.2, "Extending Your Application with Custom Components."
Using the events mechanism, you should wire together the Tagging - Tag Cloud and Tagging - Tagged Items task flows to show tagged items only for the selected tags in the tag cloud. This avoids tagged items displaying all items that have been tagged by all users, improving performance.
After adding the Tagging - Tag Cloud and Tagging - Tagged Items task flows to a page, there are two ways to wire them together.
Note:
The producer for the event is the tag cloud, and the consumer of the event is the tagged items.The first, and easiest, way is to cut and paste the following snippet to the page definition, and then replace the region name relatedresources1
with the task flow name used in your page definition.
<eventMap xmlns="http://xmlns.oracle.com/adfm/contextualEvent"> <event name="refreshAllRelated"> <producer region="*"> <consumer region="relatedresources1" handler="oracle_webcenter_tagging_view_jsf_fragments_tag_center_related_resourcesPageDef.getTagRelatedResources"> <parameters> <parameter name="p0" value="${payLoad}"/> </parameters> </consumer> </producer> </event> <event name="setShowSystemResources"> <producer region="*"> <consumer region="relatedresources1" handler="oracle_webcenter_tagging_view_jsf_fragments_tag_center_related_resourcesPageDef.setShowSystemResources"/> </producer> </event> <event name="setShowPersonalResources"> <producer region="*"> <consumer region="relatedresources1" handler="oracle_webcenter_tagging_view_jsf_fragments_tag_center_related_resourcesPageDef.setShowPersonalResources"/> </producer> </event> </eventMap>
Figure 23-14 shows an example of this.
The second way to wire the together the Tagging - Tag Cloud and Tagging - Tagged Items task flows is to follow these steps. The following example shows steps for adding the refreshAllRelated
event.
Right-click your page, then choose Go to Page Definition from the context menu.
On the Structure window, on lower left hand side, right-click bindings, and select Insert after bindings and then eventMap.
Figure 23-15 Page Definition - Structure Window
Right-click the eventMap, and select Insert inside eventMap and then event.
In the dialog, enter the event name from the snippet above. For this example, enter refreshAllRelated
.
Right-click refreshAllRelated, select Insert inside refreshAllRelated and then Producer.
When the dialog asks for the producer region, enter *
.
Right-click the producer, select Insert inside product, and select Consumer.
When the dialog asks for the handler name, enter oracle_webcenter_tagging_view_jsf_fragments_tag_center_related_resourcesPageDef.getTagRelatedResources
.
Because that dialog asks only for the consumer handler name and not the consumer region, you must add it manually. From the main window, select the consumer node. From the Property Inspector, you see a region field. Enter the related resources task flow name in your pageDef. By default, when you drag and drop the task flow to the page, Oracle JDeveloper names it relatedresources1
. If you later change the name, then make sure to use that new name instead of relatedresources1
. (Figure 23-17)
Figure 23-17 Related Resources in the Page Definition
Right-click the consumer, Insert inside consumer, and then parameters.
Right-click parameters, Insert inside parameters, and then parameter.
When the dialog asks for the parameter name, enter anything; for example, p0. For the value, enter ${payLoad}
.
Simply repeat the steps for the other events, substituting the corresponding event name and the consumer handler.
Note:
ThesetShowSystemResources
and setShowPersonalResources
events do not take parameters, so step 9 to 11 are not needed.Table 23-4 shows the information for the refreshAllRelated
event.
Table 23-4 refreshAllRelated Event
Field | Description |
---|---|
Producer region |
* |
Consumer region |
The related task flow name in your pageDef. By default, this is |
Consumer handler |
|
Parameter |
This should be some meaningful name (for example, p0); value: |
You can then click a tag in the tag cloud to see associated tagged items.
These are the only two task flows that talk to each other using events, but you can design your own task flows that listen to WebCenter events.