JSF - h:outputLink


Advertisements


The h:outputLink tag renders an HTML "anchor" element.

JSF Tag

<h:outputLink value="page1.jsf" >Page 1</h:outputLink>

Rendered Output

<a href="page1.jsf">Page 1</a>

Tag Attributes

S.N.Attribute & Description
1id

Identifier for a component

2binding

Reference to the component that can be used in a backing bean

3rendered

A boolean; false suppresses rendering

4styleClass

Cascading stylesheet (CSS) class name

5value

A component’s value, typically a value binding

6valueChangeListener

A method binding to a method that responds to value changes

7converter

Converter class name

8validator

Class name of a validator that’s created and attached to a component

9required

A boolean; if true, requires a value to be entered in the associated field

10accesskey

A key, typically combined with a system-defined metakey, that gives focus to an element

11accept

Comma-separated list of content types for a form

12accept-charset

Comma- or space-separated list of character encodings for a form. The accept-charset attribute is specified with the JSF HTML attribute named acceptcharset.

13alt

Alternative text for nontextual elements such as images or applets

14border

Pixel value for an element’s border width

15charset

Character encoding for a linked resource

16coords

Coordinates for an element whose shape is a rectangle, circle, or polygon

17dir

Direction for text. Valid values are ltr (left to right) and rtl (right to left).

18hreflang

Base language of a resource specified with the href attribute; hreflang may only be used with href.

19lang

Base language of an element’s attributes and text

20maxlength

Maximum number of characters for text fields

21readonly

Read-only state of an input field; text can be selected in a readonly field but not edited

22rel

Relationship between the current document and a link specified with the href attribute

23rev

Reverse link from the anchor specified with href to the current document. The value of the attribute is a space-separated list of link types.

24size

Size of an input field

25style

Inline style information

26tabindex

Numerical value specifying a tab index

27target

The name of a frame in which a document is opened

28title

A title, used for accessibility, that describes an element. Visual browsers typically create tooltips for the title’s value

29type

Type of a link; for example, stylesheet

30width

Width of an element

31onblur

Element loses focus

32onchange

Element’s value changes

33onclick

Mouse button is clicked over the element

34ondblclick

Mouse button is double-clicked over the element

35onfocus

Element receives focus

36onkeydown

Key is pressed

37onkeypress

Key is pressed and subsequently released

38onkeyup

Key is released

39onmousedown

Mouse button is pressed over the element

40onmousemove

Mouse moves over the element

41onmouseout

Mouse leaves the element’s area

42onmouseover

Mouse moves onto an element

43onmouseup

Mouse button is released

44onreset

Form is reset

45onselect

Text is selected in an input field

Example Application

Let us create a test JSF application to test the above tag.

StepDescription
1Create a project with a name helloworld under a package com.tutorialspoint.test as explained in the JSF - First Application chapter.
2Modify home.xhtml as explained below. Keep rest of the files unchanged.
3Compile and run the application to make sure business logic is working as per the requirements.
4Finally, build the application in the form of war file and deploy it in Apache Tomcat Webserver.
5Launch your web application using appropriate URL as explained below in the last step.

home.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   <title>JSF Tutorial!</title>
</head>
<body>
   <h2>h:outputLink example</h2>
   <hr />
   <h:form>
       <h:outputLink value="page1.jsf" >Page 1</h:outputLink>
   </h:form>
</body>
</html>

Once you are ready with all the changes done, let us compile and run the application as we did in JSF - First Application chapter. If everything is fine with your application, this will produce following result:

JSF h:outputLink
jsf_basic_tags.htm

Advertisements