<apex: commandLink> Component in Visualforce PageThe <apex:commandLink> component is one of the most important components of Visualforce. When the user presses the link, the action defined by the controller executes. Then either the page navigates to a different page or refreshes the current page based on the returned PageReference's variable. We use the nested <apex:param> components to add the request parameters to an <apex:commandLink> component. The HTML pass-through attributes are also supported by this component using the "html-" prefix. This component must always be the child of the <apex: form> component. The <apex:commandLink> component has the following attributes: 1. accesskeyThe accesskey attribute is of type string that is used for specifying the shortcut key that puts the command link in focus. Syntax: 2. actionThe action attribute is of type ApexPages.Action that is used for defining the action method that will be invoked by the AJAX request to the server. The page simply refreshes when an action is not specified. Syntax: 3. charsetThe charset attribute is of type String that is used to specify the character set that will be used to encode the specified URL. By default, its value is set to "ISO-8859". Syntax: 4. coordsThe coords attribute is of type String that is used for specifying the position and shape of the hot spot on the screen used for the commandLink. Syntax: 5. dirThe dir attribute is of type String that is used for specifying the direction in which the generated HTML component should be read. LTR and RTL are the two possible values for this attribute. Syntax: 6. hreflangThe hreflang attribute is of type string that is used to specify the base language that will be used for the resource referenced by this commandLink. The values can be "en" or "en-US" etc. Syntax: 7. idThe id attribute is of type string that is used to allow this component to be referenced by other components on the page. Syntax: 8. immediateThe immediate attribute is of type Boolean. If its value is true, the action associated with the component will happen immediately. The validation rules associated with the fields on the page will not be processed by the function. Syntax 9. langThe lang is of type string that is used to specify the base language that will be used for the generated HTML output. The values can be "en" or "en-US" etc. Syntax: 10. onblurThe onblur attribute is of type string that is used to invoke the JavaScript method when the onblur event occurs or simply focus moves off of the command button. Syntax: 11. onclickThe onclick attribute is of type string that is used to invoke the JavaScript method when the onclick event occurs or simply when the user clicks the command button. Syntax: 12. oncompleteThe oncomplete attribute is of type string that is used to invoke the JavaScript method when the result of an AJAX update request completes on the client Syntax: 13. ondblclickThe ondblclick attribute is of type string that is used to invoke the JavaScript method when the ondblclick event occurs or simply when the command button is clicked twice. Syntax: 14. onfocusThe onfocus attribute is of type string that is used to invoke the JavaScript method when the onfocus event occurs or simply focus on the command button. Syntax: 15. onkeydownThe onkeydown attribute is of type string that is used to invoke the JavaScript method when the onkeydown event occurs or simply when the user presses a keyboard key. Syntax: 16. onkeypressThe onkeypress attribute is of type string that is used to invoke the JavaScript method when the onkeypress event occurs or simply when the user holds down or presses a keyboard key. Syntax: 17. onkeyupThe onkeyup attribute is of type string that is used to invoke the JavaScript method when the onkeyup event occurs or simply when the user releases a keyboard key. Syntax: 18. onmousedownThe onmousedown attribute is of type string that is used to invoke the JavaScript method when the onmousedown event occurs or simply when the user presses the mouse button. Syntax: 19. onmousemoveThe onmousemove attribute is of type string that is used to invoke the JavaScript method when the onmousemove event occurs or simply when the user moves the mouse pointer. Syntax: 20. onmouseoutThe onmouseout attribute is of type string that is used to invoke the JavaScript method when the onmouseout event occurs or simply when the user moves the mouse pointer away from the command button. Syntax: 21. onmouseoverThe onmouseover attribute is of type string that is used to invoke the JavaScript method when the onmouseover event occurs or simply when the user moves the pointer over the command button. Syntax: 22. onmouseupThe onmouseup attribute is of type string that is used to invoke the JavaScript method when the onmouseup event occurs or simply when the user releases the mouse button. Syntax: 23. relThe rel attribute is of type string that is used for specifying the relationship from the current document to the URL specified by this command link. The value of this attribute is a space-separated list of link types. Syntax: 24. revThe rev attribute is of type string that is used for specifying the reverse link from the current document to the URL specified by this command link. The value of this attribute is a space-separated list of link types. Syntax: 25. renderedThe rendered attribute is of type Boolean that is used for specifying whether this component is rendered on the page or not. By default, its value is set to true. Syntax: 26. reRenderThe reRender attribute is of type Object that is basically Id of one or more components which we need to redraw when the client receives the result of the action method. Its value can be a single Id, comma-separated Id, or collection of Ids. Syntax: 27. statusThe status attribute is of type string that is used to specify the ID of an associated component that displays the status of an AJAX update request. Syntax: 28. styleThe style attribute is of type string that is used to specify the CSS that will be applied to it. Inline CSS is used as a value for this attribute. Syntax: 29. styleClassThe styleClass attribute is of type string that is used to specify the external CSS stylesheet that will be applied to it to display the command button. Syntax: 30. tabindex The tabindex attribute is of type string that is used for specifying the order in which this button is selected compared to other page components when the user presses the Tab key repeatedly. Syntax: 31. timeout The timeout attribute is of type integer that is used to specify the amount of time before an AJAX update request should time out. Syntax: 32. titleThe title attribute is of type string that is used to specify the text that will be displayed as a tooltip when the mouse hovers this component Syntax: 33. targetThe target attribute is of type string that is used to specify the name of the frame where the resource retrieved by this command link should be displayed. Syntax: 34. typeThe type attribute is of type string that is used to specify the MIME content type of the resource designated by this commandLink. Syntax: 35. valueThe value attribute is of type string that is used to specify the text that will be displayed on the commandLink as its label. Syntax: Let's take an example to understand how we can use the apex:commandLink component inside the VF page: ApexCommandLinkExample.vfp ApexCommandLinkController.apxc Output Next Topic |