6.7.  < a4j:htmlCommandLink >

6.7.1. Description

The <a4j:htmlCommandLink> component is very similar to the same component from the JSF HTML library, the only slight difference is in links generation and problem solving that occurs when an original component is used.

Table 6.13. a4j : htmlCommandLink attributes

Attribute NameDescription
accesskeyThis attribute assigns an access key to an element. An access key is a single character from the document character set. Note: Authors should consider the input method of the expected reader when specifying an accesskey
actionMethodBinding pointing at the application action to be invoked, if this UIComponent is activated by you, during the Apply Request Values or Invoke Application phase of the request processing lifecycle, depending on the value of the immediate property
actionListenerMethodBinding pointing at method accepting an ActionEvent with return type void
bindingThe attribute takes a value-binding expression for a component property of a backing bean
charsetThe character encoding of a resource designated by this hyperlink
coordsThis attribute specifies the position and shape on the screen. The number and order of values depends on the shape being defined. Possible combinations: * rect: left-x, top-y, right-x, bottom-y. * circle: center-x, center-y, radius. Note. When the radius value is percentage value, user agents should calculate the final radius value based on the associated object's width and height. The radius should be the smaller value of the two. * poly: x1, y1, x2, y2, ..., xN, yN. The first x and y coordinate pair and the last should be the same to close the polygon. When these coordinate values are not the same, user agents should infer an additional coordinate pair to close the polygon. Coordinates are relative to the top, left corner of the object. All values are lengths. All values are separated by commas
dirDirection indication for text that does not inherit directionality. Valid values are "LTR" (left-to-right) and "RTL" (right-to-left)
disabledWhen set for a form control, this boolean attribute disables the control for your input.
hreflangBase language of a resource specified with the href attribute; hreflang may only be used with href
idEvery component may have a unique id that is automatically created if omitted
immediateTrue means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase
langCode describing the language used in the generated markup for this component
onblurJavaScript code. The onblur event occurs when an element loses focus either by the pointing device or by tabbing navigation. It may be used with the same elements as onfocus
onclickHTML: a script expression; a pointer button is clicked
ondblclickHTML: a script expression; a pointer button is double-clicked
onfocusJavaScript code. The onfocus event occurs when an element gets focus
onkeydownHTML: a script expression; a key is pressed down
onkeypressHTML: a script expression; a key is pressed and released
onkeyupHTML: a script expression; a key is released
onmousedownHTML: script expression; a pointer button is pressed down
onmousemoveHTML: a script expression; a pointer is moved within
onmouseoutHTML: a script expression; a pointer is moved away
onmouseoverHTML: a script expression; a pointer is moved onto
onmouseupHTML: script expression; a pointer button is released
relThe relationship from the current document to the anchor specified by this hyperlink. The value of this attribute is a space-separated list of link types
renderedIf "false", this component is not rendered
revA reverse link from the anchor specified by this hyperlink to the current document. The value of this attribute is a space-separated list of link types
shapedefault|rect|circle|poly [CI] This attribute specifies the shape of a region. Possible values: * default: Specifies the entire region. * rect: Define a rectangular region. * circle: Define a circular region. * poly: Define a polygonal region.
styleCSS style(s) is/are to be applied when this component is rendered
styleClassCorresponds to the HTML class attribute
tabindexThis attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros
targetThis attribute specifies the name of a frame where a document is to be opened. By assigning a name to a frame via the name attribute, authors can refer to it as the "target" of links defined by other elements
titleAdvisory title information about markup elements generated for this component
typeThe content type of the resource designated by this hyperlink
valueThe current value for this component

Table 6.14. Component identification parameters

NameValue
component-typejavax.faces.HtmlCommandLink
component-familyjavax.faces.Command
component-classjavax.faces.component.html.HtmlCommandLink
renderer-typeorg.ajax4jsf.HtmlCommandLinkRenderer

6.7.2. Creating the Component with a Page Tag

Component definition on a page is the same as for the original component from the JSF HTML library.

Example:


<a4j:htmlCommandLink value="value" action="action"/>

6.7.3. Creating the Component Dynamically Using Java

Example:


import javax.faces.component.html.HtmlCommandLink;
...
HtmlCommandLink myCommandLink = new HtmlCommandLink();
...

6.7.4. Key attributes and ways of usage

The difference with the original component is that all hidden fields required for command links with the child <f:param> elements are always rendered and it doesn't depend on links rendering on the initial page. It solves the problem with invalid links that weren't rendered on a page immediately, but after some Ajax request.

Example:


<a4j:form>
    ...
    <a4j:htmlComandLink action="action" value="link" rendered="#{bean.rendered}">
        <f:param .../>
    <a4j:htmlComandLink>
    ...
</a4j:form>

In this example <a4j:htmlCommandLink> works as standard <h:commandLink> , but here hidden fields required for correct functionality are rendered before the first downloading of a page, though it doesn't happen if its attribute isn't set to "false".

6.7.5. Relevant resources links

Here you can found some additional information for <a4j:htmlCommandLinks> component usage.

Here you can found some additional information about <f:param> component.