E Calling Oracle SES to Search Data

In custom WebCenter applications, you can provide users with the ability to search the data, or a portion of the data, presented to them on a page. To achieve this type of functionality, use a web service data control to call the searching function of Oracle Secure Enterprise Search (SES).

For more information on Oracle SES, see the Oracle Secure Enterprise Search documentation that comes with the product.

E.1 Calling Oracle SES to Search Data

This appendix demonstrates how to create a web service data control to search SES data.

This involves the following steps:

E.1.1 Creating a Data Control

You can leverage Oracle SES APIs using a data control to build custom UIs. To build a data control that uses Oracle Secure Enterprise Search:

  1. After installing Oracle Secure Enterprise Search, create a custom WebCenter application in Oracle JDeveloper.

  2. Right-click the project where you want to incorporate searching and select New from the context menu.

  3. In the New Gallery, make sure to filter by All Technologies.

  4. Expand Business Tier and select Web Services.

  5. In the Items list, select Web Service Data Control and click OK.

  6. Enter a name for the data control. The wizard page should look similar to Figure E-1.

    Figure E-1 Data Source Page of Web Service Data Control Wizard

    Description of Figure E-1 follows
    Description of "Figure E-1 Data Source Page of Web Service Data Control Wizard"

  7. Enter a Web Services Description Language (WSDL) URL. The WSDL URL for Oracle Secure Enterprise Search has the following form:



    When Oracle Secure Enterprise Search is installed, the endpoint listed in the WSDL points to a placeholder location. After the data control is created, you must correct the endpoint URL using the Structure panel. This step is described later in this procedure.
  8. If the service is not automatically provided, then click Services.

  9. Click Next.

  10. From the Data Control Operations page, select the methods you want to expose by moving them from the Available list to the Selected list. For the purposes of this example, move doOracleSimpleSearch to the Selected list. When you are done, the page should look similar to Figure E-2.

    Figure E-2 Data Control Operations Page of Web Service Data Control Wizard

    Description of Figure E-2 follows
    Description of "Figure E-2 Data Control Operations Page of Web Service Data Control Wizard"

  11. Click Finish. To review the other pages of the wizard first, click Next until you reach the end of the wizard, and then click Finish.

  12. In the Application Navigator, expand Application Sources and then view.

  13. Click DataControls.dcx and its structure will appear in the Structure panel below the Application Navigator.

  14. Right-click your data control in the Structure panel and select Edit Web Service Connection from the context menu.

  15. The Edit Web Service Connection dialog appears as shown in Figure E-3. As noted earlier, the endpoint listed in the WSDL now points to a placeholder location. Enter again the same endpoint URL.

    Figure E-3 Edit Web Service Connection Dialog

    Description of Figure E-3 follows
    Description of "Figure E-3 Edit Web Service Connection Dialog"

  16. Click OK.

E.1.2 Adding the Data Control on a Page

This section describes how to drop your new data control onto a page.

  1. To create a new page, right-click your project and select New from the context menu. Under Web Tier, select JSF. Under Items, select JSF Page, and click OK. On the Create JSP Page, accept the default settings for everything except File Name. Select a meaningful file name, and click OK.

  2. You should see your data control listed under the Data Controls section of the Application Navigator. Expand the top level node of your data control and then expand Return and Return. Now you can see all the data that is returned by the data control.

  3. For the purposes of this example, drag and drop resultElements onto your page.

  4. Select Tables, ADF Read-only Table from the context menu that appears.

  5. The Edit Table Columns dialog appears. (Figure E-4) Select lastModified and click the Delete icon. Click OK.

    Figure E-4 Edit Table Columns Dialog

    Description of Figure E-4 follows
    Description of "Figure E-4 Edit Table Columns Dialog"

  6. For the sake of simplicity, you can hard code the values for each parameter as shown in Table E-1.

    Table E-1 Parameter Values for Action Binding Editor

    Parameter Value


    The string you want to search for, for example, oracle











  7. The dialog should look like Figure E-5. Click OK, and then click OK again.

    Figure E-5 Action Binding Editor

    Description of Figure E-5 follows
    Description of "Figure E-5 Action Binding Editor"

  8. Now you can run your page. In the Application Navigator, right-click the page and select Run from the context menu.

E.1.3 Formatting the Output

At runtime, you can browse through your output and see how occurrences of a word, for example "oracle," are surrounded by <b></b> tags.

Figure E-6 shows a small sample fragment of this output. Currently, the search results are not formatted because you have not yet converted the view component that renders this column to OutputFormatted.

Figure E-6 Sample of Searched Output, Hits Unformatted

Description of Figure E-6 follows
Description of "Figure E-6 Sample of Searched Output, Hits Unformatted"

To format the search output:

  1. To format the output, return to Oracle JDeveloper and display the page containing the data control by clicking its tab in the Design view.

  2. In the Structure panel, find and expand one of the columns that contains oracle ; for example, the description column.

  3. Right-click af:outputText - #{row.snippet} for that column.

  4. In the Source view, change af:outputText to af:outputFormatted.

  5. Run the page again to see the changes. You should see output similar to that in Figure E-7. Notice how the <b></b> around the word oracle is now interpreted so that search hits appear in bold.

    Figure E-7 Sample of Searched Output, Hits Formatted

    Description of Figure E-7 follows
    Description of "Figure E-7 Sample of Searched Output, Hits Formatted"

  6. Using the Structure panel, right-click and delete any extraneous columns of your table.

  7. Repeat steps 1-5 for each of the remaining columns on your page.

  8. Save and run the page again.

E.1.3.1 Additional Formatting

The rest of this section describes some other formatting features you can include.

  1. You might see automatic pagination in the upper right corner of the table. The default number of rows for an Oracle ADF table is 10, but you chose to return 20 results.

    To enhance the page, you can provide an estimated count. From the Application Navigator , under Data Controls, drag and drop estimatedHitCount onto the page, before the table. Select Texts, ADF Output Text w/ Label from the context menu.

  2. Another useful feature for this table would be a link to open the document. Drag a Go Link from under ADF Faces in the Component Palette and drop it right in front of outputFormatted of the description column. Note that you can perform this step a little more accurately in the Structure panel.

  3. In the Property Inspector, change the Text attribute to Open. For the Destination attribute, enter the following: #{row.url}.

  4. Click the Source tab. You should see something similar to the following in the source for your page:

    <af:goLink text="Open" destination="#{row.url}"/>
  5. You could also add an input box and a Submit button to enable users to perform their own custom searches. Click the Design tab.

  6. From the Application Navigator , under Data Controls, expand the Parameters node under your data control.

  7. Drag query and drop it just above the left corner of your table. Select Texts, ADF Input Text w/ Label from the context menu.

  8. Drag doOracleSimpleSearch and drop it just below the parameter input box you just created. Select Methods, ADF Button from the context menu.

  9. To avoid getting an error when someone first runs the page, you must set a default value for the query parameter. Go to the page definition, PageDef.xml.

  10. In the Structure panel, expand variables under executables and select doOracleSimpleSearch_query.

  11. In the Property Inspector, select the DefaultValue property and enter a default search; for example, oracle.

  12. Run the page. Enter a different search term in the box and click the button you just created. The results should change.


    Because you previously limited the number of results returned, the hit count you added at the bottom of the page is now artificially limited. To get an accurate hit count, find the following line in your page definition file:
    <NamedData NDName="returnCount" NDValue="false"   NDType="java.lang.Boolean"/>

    and change it to:

    <NamedData NDName="returnCount" NDValue="true"