Class LinkItem

All Implemented Interfaces:
HasHandlers, HasBlurHandlers, HasChangedHandlers, HasChangeHandlers, HasClickHandlers, HasDoubleClickHandlers, HasEditorEnterHandlers, HasEditorExitHandlers, HasFocusHandlers, HasIconClickHandlers, HasIconKeyPressHandlers, HasItemHoverHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasKeyUpHandlers, HasPendingStatusChangedHandlers, HasPickerIconClickHandlers, HasShowContextMenuHandlers, HasTitleClickHandlers, HasTitleDoubleClickHandlers, HasTitleHoverHandlers, HasValueHoverHandlers, HasValueIconClickHandlers

public class LinkItem extends StaticTextItem
A form item that displays a URL. In the default read-only mode (canEdit is false) the URL is shown as a link; in editable mode the URL is shown in a textbox.

The link to open is specified as the item value with FormItem.setValue() or FormItem.defaultValue. The link title defaults to the URL unless linkTitle is specified.

Additionally, a custom action can be triggered when the link is clicked: see target for details.

  • Constructor Details

    • LinkItem

      public LinkItem()
    • LinkItem

      public LinkItem(JavaScriptObject jsObj)
    • LinkItem

      public LinkItem(String name)
  • Method Details

    • getOrCreateRef

      public static LinkItem getOrCreateRef(JavaScriptObject jsObj)
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, Canvas defaults)
      Changes the defaults for Canvas AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - Canvas defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, FormItem defaults)
      Changes the defaults for FormItem AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - FormItem defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changePickerIconDefaults

      public static void changePickerIconDefaults(FormItemIcon defaults)
    • setDisableIconsOnReadOnly

      public LinkItem setDisableIconsOnReadOnly(Boolean disableIconsOnReadOnly)
      If FormItem.canEdit is set to false, should icons be disabled by default?

      This may also be specified at the icon level. See FormItemIcon.disableOnReadOnly.

      Overrides:
      setDisableIconsOnReadOnly in class FormItem
      Parameters:
      disableIconsOnReadOnly - New disableIconsOnReadOnly value. Default value is false
      Returns:
      LinkItem instance, for chaining setter calls
    • getDisableIconsOnReadOnly

      public Boolean getDisableIconsOnReadOnly()
      If FormItem.canEdit is set to false, should icons be disabled by default?

      This may also be specified at the icon level. See FormItemIcon.disableOnReadOnly.

      Overrides:
      getDisableIconsOnReadOnly in class FormItem
      Returns:
      Current disableIconsOnReadOnly value. Default value is false
    • setIconVAlign

      public LinkItem setIconVAlign(VerticalAlignment iconVAlign)
      How should icons be aligned vertically for this form item.

      Note : This is an advanced setting

      Overrides:
      setIconVAlign in class FormItem
      Parameters:
      iconVAlign - New iconVAlign value. Default value is "center"
      Returns:
      LinkItem instance, for chaining setter calls
    • getIconVAlign

      public VerticalAlignment getIconVAlign()
      How should icons be aligned vertically for this form item.
      Overrides:
      getIconVAlign in class FormItem
      Returns:
      Current iconVAlign value. Default value is "center"
    • setLinkTitle

      public LinkItem setLinkTitle(String linkTitle)
      Optional title HTML to display for this item's link. If unset, the LinkItem's value (the URL) will be used for the link's title.

      If this method is called after the component has been drawn/initialized: Setter for linkTitle.
      Parameters:
      linkTitle - new linkTitle HTML. Default value is null
      Returns:
      LinkItem instance, for chaining setter calls
      See Also:
    • getLinkTitle

      public String getLinkTitle()
      Optional title HTML to display for this item's link. If unset, the LinkItem's value (the URL) will be used for the link's title.
      Returns:
      Current linkTitle value. Default value is null
      See Also:
    • setReadOnlyDisplay

      public LinkItem setReadOnlyDisplay(ReadOnlyDisplayAppearance readOnlyDisplay)
      If canEdit is set to false, how should this LinkItem be displayed to the user?

      Link items are, by default, canEdit:false. Note that the link remains active regardless of the readOnlyDisplay setting.

      Overrides:
      setReadOnlyDisplay in class FormItem
      Parameters:
      readOnlyDisplay - New readOnlyDisplay value. Default value is null
      Returns:
      LinkItem instance, for chaining setter calls
      See Also:
    • getReadOnlyDisplay

      public ReadOnlyDisplayAppearance getReadOnlyDisplay()
      If canEdit is set to false, how should this LinkItem be displayed to the user?

      Link items are, by default, canEdit:false. Note that the link remains active regardless of the readOnlyDisplay setting.

      Overrides:
      getReadOnlyDisplay in class FormItem
      Returns:
      Current readOnlyDisplay value. Default value is null
      See Also:
    • setTarget

      public LinkItem setTarget(String target)
      By default, clicking a link rendered by this item opens it in a new browser window. You can alter this behavior by setting this property. The value of this property will be passed as the value to the target attribute of the anchor tag used to render the link.

      If you set linkItem.target to "javascript", the default behaviour is to catch and consume mouse-clicks that would result in the link being followed. Instead, the FormItem.click() event is fired.

      Parameters:
      target - New target value. Default value is "_blank"
      Returns:
      LinkItem instance, for chaining setter calls
    • getTarget

      public String getTarget()
      By default, clicking a link rendered by this item opens it in a new browser window. You can alter this behavior by setting this property. The value of this property will be passed as the value to the target attribute of the anchor tag used to render the link.

      If you set linkItem.target to "javascript", the default behaviour is to catch and consume mouse-clicks that would result in the link being followed. Instead, the FormItem.click() event is fired.

      Returns:
      Current target value. Default value is "_blank"
    • setDefaultProperties

      public static void setDefaultProperties(LinkItem linkItemProperties)
      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties of the class instance passed to this function. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.

      Parameters:
      linkItemProperties - properties that should be used as new defaults when instances of this class are created
      See Also:
    • addClickHandler

      public HandlerRegistration addClickHandler(ClickHandler handler)
      Description copied from class: FormItem
      Add a click handler.

      Called when this FormItem is clicked on.

      Note: click() is available on StaticTextItem, BlurbItems, ButtonItem, and derivatives. Other form items (such as HiddenItem) do not support click().

      Specified by:
      addClickHandler in interface HasClickHandlers
      Overrides:
      addClickHandler in class FormItem
      Parameters:
      handler - the click handler
      Returns:
      HandlerRegistration used to remove this handler