18 Implementing Context-Sensitive Help in a Web Application
This chapter describes how to enable context-sensitive help in your web application and how to map topic IDs with the help topics.
This chapter includes the following sections:
18.1 About Implementing Context-Sensitive Help In a Web Application
Oracle Help for the Web (OHW) provides a context-sensitive help mechanism that launches help topics that are associated with some context in the Web application user interface. Typically, help topics are written to describe the function of a particular page, table, or input field in a Web application. When a user requests help for a user interface control—for example, by clicking a Help button—the appropriate topic for that context (or control) is displayed.
To provide context-sensitive help for a Web application, the help system must include one or more map files, and the appropriate help code must be added to the application code.
18.2 Mapping Topic IDs to Help Topics
OHW context-sensitive help systems rely on one or more map files that map topic IDs to help topic HTML files. In a helpset, the map file is saved in XML file format as
The map file is usually created by the help author. As a Web application developer, when associating Web application controls with context-sensitive topics you must use the topic IDs specified in the author's map file. Thus, you will have to coordinate your efforts with the help author.
Here is a sample map file in XML format:
<?xml version='1.0' ?> <map version="1.0"> <mapID target="topic_1" url="file_1.html" /> <mapID target="topic_2" url="file_2.html#a1" /> <mapID target="topic_3" url="file_3.html" wintype="intro" /> </map>
target attribute specifies a unique ID for the associated HTML file within a helpset. The
url attribute specifies the location of the file to associate with the ID. The
wintype attribute is optional; it specifies the name of a window type that the topic will be displayed in. For more information about the elements used in the map file, see Section 5.3, "Map Files".
18.3 Creating Context-Sensitive Links to the Help System
Applications that rely on OHW for context-sensitive help request the context-sensitive topics via specially formulated URLs to the OHW servlet. Any user interface control with a URL destination (links, images, etc.) can be associated with a context-sensitive topic.
When creating a link to OHW for context-sensitive help, you can either use the URL destination for the front main page, which is a tripane-layout UI with the Contents, Index, and Search navigators on the left side, or you can create a URL destination for displaying a topic in tripane-layout UI using the topic ID. You can also specify a locale and a group in the URL destination.
18.3.1 Linking to the Front Main Page
The URL to the front main page is simply the URL to the OHW servlet:
<server> is the name of your server running the servlet container,
<port> is the port used by the servlet container, and
<servlet mapping> is the servlet mapping set up in the
web.xml file for the OHW servlet (
For example, in the
web.xml, it has the following servlet definition and servlet mapping:
<!-- configuration for product1 help front servlet --> <servlet> <servlet-name>product1</servlet-name> <servlet-class>oracle.help.web.rich.OHWServlet</servlet-class> <init-param> <param-name>ohwConfigFileURL</param-name> <param-value>/helpsets/product1/ohwconfig.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>product1</servlet-name> <url-pattern>/product1/*</url-pattern> </servlet-mapping>
In this example, the URL to the front main page is:
When a user requests help for a user interface control that is linked to the front main page, the OHW tripane-layout main page will be displayed in the user's browser, showing the Contents, Index, and Search navigators on the left side.
18.3.2 Linking to a Topic
To create the URL for linking to a topic, add a topic parameter to the URL of the OHW servlet. The value of the topic parameter is the topic ID of the help topic:
For example, the following URL requests the topic associated with the topic ID
When a user requests help for a user interface control that is linked to a topic ID, OHW displays the tripane-layout UI with the topic file shown in the Topic Navigator (the right side), and Contents Navigator is shown in the left side with the topic highlighted in the TOC tree.
18.3.3 Specifying the Locale and Group
When you link to any OHW page, including topic pages or front pages, you can include a locale and a group in the URL of the OHW servlet with the locale and group query parameter.
The topic syntax is:
and the front page syntax is:
If you specify the locale, OHW switches to the localized helpset if it is available, and will keep using the specified locale until it is overridden or removed. If the specified localized helpset is not available, the parameter is ignored.
For more information about locale and group, see Chapter 8, "Oracle Help for the Web Configuration File".