Show TOC

Object documentationLink Locate this document in the navigation structure

 

Defines a link to another page. The text of the link becomes an underline and is displayed in a different color. An image can be defined as link as well - see the example for details. The link control can be for client side eventing. See the EventValidationComponent description for more details.

  • enabled - inherited from EventValidationComponent.

    A boolean value that enables (=true) or disables (=false) the link control. A disabled link has a different text color to show the user that it is disabled and sends no event when clicked.

  • fontSize

    Sets the font size for the link.

  • id

    Identification name of the link.

  • jsObjectNeeded - inherited from Component.

    A boolean value that defines if a JavaScript object has to be generated for the link component.

  • labeled

    Enables or disables the notification when the control has a label assigned to it.

  • linkDesign

    Design definition of the link.

    • DRAGRELATE

      In link color and underlined. On "MouseOver" color different, no underline

    • DRILLDOWN

      In link color and underlined. On "MouseOver" link color brighter and underlined. "Standard" link display.

    • FUNCTION

      In link color and underlined. On "MouseOver" link color brighter and underlined. "Standard" link display.

    • REPORTING

      In link color, no underline. On "MouseOver" link color brighter and underlined.

    • RESULT

      In text color, no underline. On "MouseOver" link color brighter and underlined.

  • onClick

    Defines the event handling method that will be processed when the user clicks on the link. If 'onClick' is specified, the event handling routine is called.

  • onClientClick

    Defines the JavaScript fragment that is executed when the user clicks on the link. If both events ('onClick' and 'onClientClick') are specified, the 'onClientClick' event handling method is activated first. By default the 'onClick' event handling method is activated afterwards. In the JavaScript fragment you can cancel the activation of the 'onClick' event handling method with the command

    htmlbevent.cancelSubmit=true;

    The 'onClientClick' event is useful to preprocess the form and only send the form to client if the preprocessing was successful (for example, date validation, valid number format etc.) to save client/server interaction.

  • reference

    Specifies the address of the page/document to be opened. If the 'onClick' attribute is defined the event handling routine is started and the 'reference' string is handed to the event handling routine. The referenced document is not opened - the event handling routine has to do that.

    If the 'onClick' attribute is not defined, the link is opening the referenced document.

  • target

    Specifies the name of the frame where the document is to be opened. The following values refer to w3c HTML-standard.

    • _blank

      The web client should load the designated document in a new, unnamed window.

    • _self

      The web client should load the document in the same frame as the element that refers to the target.

    • _parent

      The web client should load the document into the immediate FRAMESET parent of the current frame. This value is equivalent to _self if the current frame has no parent.

    • _top

      The web client should load the document into the full, original window (thus canceling all other frames). This value is equivalent to _self if the current frame has no parent.

  • text

    A text string that is displayed underlined and in different color. If no 'text' attribute is provided or a the 'text' attribute is set to an empty string, the link is not displayed.

  • tooltip

    Defines the hint of the link which is displayed as the mouse cursor passes over the link, or as the mouse button is pressed but not released.

Attributes

M

Values

Usage

enabled*

FALSE

TRUE (d)

Taglib

No tag available

Classlib

setEnabled (true)

fontSize

Taglib

No tag available

Classlib

setFontSize (LinkFontSize.fontsize)

id

*

String (cs)

Taglib

id="importantItems"

Classlib

setId("importantItems")

jsObjectNeeded**

FALSE (d)

TRUE

Taglib

No tag available

Classlib

setJsObjectNeeded (true)

labelled

FALSE (d)

TRUE

Taglib

No tag available

Classlib

setLabeled (true)

linkDesign

DRAGRELATE

DRILLDOWN (d)

FUNCTION

REPORTING

RESULT

Taglib

linkDesign="RESULT"

Classlib

setLinkDesign(LinkDesign.RESULT)

reference

String

Taglib

reference="http://www.sap.com"

Classlib

setReference("http://www.sap.com")

target

_blank

_self (d)

_parent

_top

Taglib

target="_TOP"

Classlib

setTarget("_TOP")

text

String

Taglib

text="To the beach"

Classlib

setText("To the beach")

tooltip

String

Taglib

tooltip="Enjoy and relax"

Classlib

setTooltip("Enjoy and relax")

* Method is inherited from the EventValidationComponent component. Therefor the attribute is different between the taglib and the classlib.

** Method is inherited from the Component component.

See the JavaScript API description for details how to access the component in JavaScript.

Events

M

Values

Usage

onClick

String (cs)

Taglib

onClick="ProcessLink"

Classlib

setOnClick("ProcessLink")

onClientClick

String (cs)

Taglib

No tag available

Classlib

setOnClientClick("alert('Click')")

Example

Text as link using the taglib

Syntax Syntax

  1.  <hbj:link 
        id="link1"
        text="Link to Google"
        reference="http://www.google.com"
        target="_TOP"
        tooltip="this takes you to: http://www.google.com"
        onClick="LinkClick"
        />
    
End of the code.

Text as link using the classlib

Syntax Syntax

  1.     Form form = (Form) this.getForm();
        Link link = new Link("myLink");
        link.setTarget("_TOP");
        link.setReference("http://www.google.com");
        link.setTooltip("this takes you to: http://www.google.com");
        link.addText("Link to Google");
        form.addComponent(link);
    
End of the code.
Result

Link to Google

Image as link (and getting the resource path once - at the beginning of the JSP. This is useful when the JSP uses several images) using the taglib

Syntax Syntax

  1.  <%-- Get resource url of component     --%>
     <% 
        String  ImageURL=componentRequest.getPublicResourcePath() 
                +   "/../mimes/"; 
        %>
     <hbj:link 
        id="link1"
        text=""
        reference="http://www.sap.com"
        target="_TOP"
        tooltip="this takes you to: http://www.sap.com"
        onClick="LinkClick"
        <hbj:image 
        src="<%= ImageURL+\"sap.gif\" %>"
        alt="Image not available"  />
     </hbj:link>
    
End of the code.
Result

SAP logo (SAP logo)

Text and Image as link (and getting the resource path at the control) using the taglib

Syntax Syntax

  1.   <%@ page import="com.sapportals.portal.prt.resource.IResource"  %>
      .
      .
      <hbj:link 
        id="link1"
        text="Link to SAP"
        reference="http://www.sap.com"
        target="_TOP"
        tooltip="this takes you to: http://www.sap.com"
        onClick="LinkClick"
        >
        <hbj:image 
            id="image_logo"
            alt="Image not available"
            src=""
            >
            <% 
                IResource 
                rs=componentRequest.getResource(IResource.IMAGE, 
                "../mimes/sap.gif"); 
                image_logo.setSrc
                   (rs.getResourceInformation().getURL(componentRequest)); 
                %>
        </hbj:image>
      </hbj:link>
    
End of the code.
Result

Link to Google SAP logo (SAP logo)