The Hyperlink Web component creates a hypertext link that when clicked, opens another file.
mailto:joe@somecompany.com | Send mail to Joe
mailto:joe@somecompany.com?subject=Hello Joe | Send mail to Joe
mailto:joe@somecompany.com?subject=Hello Joe&cc=Pete&body=Hello Joe.
You can use the Hyperlink Web component as a standalone Web component, or you can embed it in a Table Web component. Each use gives you the option of encoding substitution variables for the URL and the Text fields.
As
a standalone Web component, you enter the variable within braces in the static
URL and text fields. The variable is the name of the Web component. As shown
in the following image, the Web component name is HYPERLINK1.
Therefore the substitution variable is also entered as HYPERLINK1.
If a variable is included in the static URL or Text fields, then at run time the URL and text is formed by replacing the substitution variable with the value returned by the host program. The value returned by the host program can have a URL portion and a label portion in the form url | label. The delimiter distinguishes the URL and the label. For example, if the value returned from the host program is http://www.ibm.com | Link to IBM, the substitution variable in the static URL is replaced by the URL portion of the value returned by the host program. Similarly, the substitution variable in the static text is replaced by the label portion of the value returned by the host program.
In another example of replacing a variable in the
URL and Text fields of a hyperlink, assume that a hyperlink on a page displays
the name of an employee's manager. In this case, the hyperlink name is managerlink,
with a URL of getperson.do?personid={managerlink}. The Text is
specified as {managerlink}.
The Hyperlink Web component
is mapped to an output field in the host program. If the program returns a
value of 1085 | Doe, John, the URL portion of the hyperlink
is 1085 and the label portion is Doe, John.
When the page displays, the text Doe, John appears as the
hyperlink label, and the {managerlink} variable in the URL
is replaced with 1085, which results in the hyperlink URL
value of getperson.do?personid=1085. When the user clicks
the link, information about the manager is displayed.
You can also embed
Hyperlink Web components into a Table Web component by specifying the column
type as Hyperlink, as shown below.
When you click
the button in the Properties column, the Column Properties
dialog opens, in which you can enter the static URL and static text. You can
also include substitution variables enclosed in braces, as shown below.
In this example, the substitution variables col1 and col2 are valid column names that are specified for the Table Web component. At run time, the substitution variables are replaced with the data from the specified table column. Note that only the data is used from the specified table column. For example, if the specified table column is a Combo Box Web component, then the data from that column is returned in an array of name:value:true|false. This data is used as is, and it is not parsed to extract any special format. However, if the substitution variable specifies a column that is a hyperlink field, the value used for replacing the substitution variable depends on where the substitution variable is specified. If it is specified in the static URL field, it is replaced with the URL portion of the value returned by the host program. Otherwise, the substitution variable is replaced with the text portion of the value returned by the host program.
In the following example, you can use substitution values in a Hyperlink Web component that is used in a subfile.
The Name column
is a hyperlink and the ID column is hidden. The subfile
is designed so that when a user clicks a name under the Name column
in the subfile, the hidden ID associated with that name is passed to a JavaScript
function. The columns for the subfile are defined as follows:
The
hyperlink properties for the name column includes the JavaScript
in the URL field shown here:
The values within the
braces are the names of the columns in the subfile. The values in this dialog
box indicate that the text for the name column hyperlink is the value in the name column.
The URL for the hyperlink is a call to a JavaScript function getperson,
which passes the value in the hidden column hid.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.