LinkGenerator (Grails 4.0.0)
Date: 2019-07-11

Package: grails.web.mapping

## [Java] Interface LinkGenerator

- Generates links for a Grails application based on URL mapping rules and/or base context settings.

  Authors:
    Graeme Rocher
  Since:
    2.0

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `java.lang.String` | `ATTRIBUTE_ABSOLUTE` |
    `java.lang.String` | `ATTRIBUTE_ACTION` |
    `java.lang.String` | `ATTRIBUTE_BASE` |
    `java.lang.String` | `ATTRIBUTE_CONTEXT_PATH` |
    `java.lang.String` | `ATTRIBUTE_CONTROLLER` |
    `java.lang.String` | `ATTRIBUTE_ELEMENT_ID` |
    `java.lang.String` | `ATTRIBUTE_EVENT` |
    `java.lang.String` | `ATTRIBUTE_FRAGMENT` |
    `java.lang.String` | `ATTRIBUTE_ID` |
    `java.lang.String` | `ATTRIBUTE_INCLUDE_CONTEXT` |
    `java.lang.String` | `ATTRIBUTE_MAPPING` |
    `java.lang.String` | `ATTRIBUTE_METHOD` |
    `java.lang.String` | `ATTRIBUTE_NAMESPACE` |
    `java.lang.String` | `ATTRIBUTE_PARAMS` |
    `java.lang.String` | `ATTRIBUTE_PLUGIN` |
    `java.lang.String` | `ATTRIBUTE_RELATIVE_URI` |
    `java.lang.String` | `ATTRIBUTE_RESOURCE` |
    `java.lang.String` | `ATTRIBUTE_URI` |
    `java.lang.String` | `ATTRIBUTE_URL` |
    `java.util.Set<java.lang.String>` | `LINK_ATTRIBUTES` |
    `java.util.Map<java.lang.String, java.lang.String>` | `REST_RESOURCE_ACTION_TO_HTTP_METHOD_MAP` |
    `java.util.Map<java.lang.String, java.lang.String>` | `REST_RESOURCE_HTTP_METHOD_TO_ACTION_MAP` |

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `java.lang.String` | `getContextPath()` Obtains the context path from which this link generator is operating.
    `` | `java.lang.String` | `getServerBaseURL()` The base URL of the server used for creating absolute links.
    `` | `java.lang.String` | `link(java.util.Map params)` Generates a link to a controller, action or URI for the given named parameters.
    `` | `java.lang.String` | `link(java.util.Map params, java.lang.String encoding)` Generates a link to a controller, action or URI for the given named parameters.
    `` | `java.lang.String` | `resource(java.util.Map params)` Generates a link to a static resource for the given named parameters.

- - ### Field Detail

    - #### public java.lang.String ATTRIBUTE_ABSOLUTE

    - #### public java.lang.String ATTRIBUTE_ACTION

    - #### public java.lang.String ATTRIBUTE_BASE

    - #### public java.lang.String ATTRIBUTE_CONTEXT_PATH

    - #### public java.lang.String ATTRIBUTE_CONTROLLER

    - #### public java.lang.String ATTRIBUTE_ELEMENT_ID

    - #### public java.lang.String ATTRIBUTE_EVENT

    - #### public java.lang.String ATTRIBUTE_FRAGMENT

    - #### public java.lang.String ATTRIBUTE_ID

    - #### public java.lang.String ATTRIBUTE_INCLUDE_CONTEXT

    - #### public java.lang.String ATTRIBUTE_MAPPING

    - #### public java.lang.String ATTRIBUTE_METHOD

    - #### public java.lang.String ATTRIBUTE_NAMESPACE

    - #### public java.lang.String ATTRIBUTE_PARAMS

    - #### public java.lang.String ATTRIBUTE_PLUGIN

    - #### public java.lang.String ATTRIBUTE_RELATIVE_URI

    - #### public java.lang.String ATTRIBUTE_RESOURCE

    - #### public java.lang.String ATTRIBUTE_URI

    - #### public java.lang.String ATTRIBUTE_URL

    - #### public java.util.Set<java.lang.String> LINK_ATTRIBUTES

    - #### public java.util.Map<java.lang.String, java.lang.String> REST_RESOURCE_ACTION_TO_HTTP_METHOD_MAP

    - #### public java.util.Map<java.lang.String, java.lang.String> REST_RESOURCE_HTTP_METHOD_TO_ACTION_MAP

  - ### Method Detail

    - #### public java.lang.String getContextPath()

      Obtains the context path from which this link generator is operating.

      Returns:
        The base context path

    - #### public java.lang.String getServerBaseURL()

      The base URL of the server used for creating absolute links.

      Returns:
        The base URL of the server

    - #### public java.lang.String link(@java.lang.SuppressWarnings("rawtypes") java.util.Map params)

      Generates a link to a controller, action or URI for the given named parameters. Possible named parameters include:

      - resource - If linking to a REST resource, the name of the resource or resource path to link to. Either 'resource' or 'controller' should be specified, but not both
      - controller - The name of the controller to use in the link, if not specified the current controller will be linked
      - action - The name of the action to use in the link, if not specified the default action will be linked
      - uri - relative URI
      - url - A map containing the action,controller,id etc.
      - base - Sets the prefix to be added to the link target address, typically an absolute server URL. This overrides the behaviour of the absolute property, if both are specified.
      - absolute - If set to "true" will prefix the link target address with the value of the grails.serverURL property from Config, or http://localhost:<port> if no value in Config and not running in production.
      - contextPath - The context path to link to, defaults to the servlet context path
      - id - The id to use in the link
      - fragment - The link fragment (often called anchor tag) to use
      - params - A map containing URL query parameters
      - mapping - The named URL mapping to use to rewrite the link
      - event - Webflow _eventId parameter
      Parameters:
        `params` - The named parameters
      Returns:
        The generator link

    - #### public java.lang.String link(@java.lang.SuppressWarnings("rawtypes") java.util.Map params, java.lang.String encoding)

      Generates a link to a controller, action or URI for the given named parameters. Possible named parameters include:

      - resource - If linking to a REST resource, the name of the resource or resource path to link to. Either 'resource' or 'controller' should be specified, but not both
      - controller - The name of the controller to use in the link, if not specified the current controller will be linked
      - action - The name of the action to use in the link, if not specified the default action will be linked
      - uri - relative URI
      - url - A map containing the action,controller,id etc.
      - base - Sets the prefix to be added to the link target address, typically an absolute server URL. This overrides the behaviour of the absolute property, if both are specified.
      - absolute - If set to "true" will prefix the link target address with the value of the grails.serverURL property from Config, or http://localhost:<port> if no value in Config and not running in production.
      - id - The id to use in the link
      - fragment - The link fragment (often called anchor tag) to use
      - params - A map containing URL query parameters
      - mapping - The named URL mapping to use to rewrite the link
      - event - Webflow _eventId parameter
      Parameters:
        `params` - The named parameters
        `encoding` - The character encoding to use
      Returns:
        The generator link

    - #### public java.lang.String resource(@java.lang.SuppressWarnings("rawtypes") java.util.Map params)

      Generates a link to a static resource for the given named parameters. Possible named parameters include:

      - base - The base path of the URL, typically an absolute server path
      - contextPath - The context path to link to, defaults to the servlet context path
      - dir - The directory to link to
      - file - The file to link to (relative to the directory if specified)
      - plugin - The plugin that provides the resource
      - absolute - Whether the link should be absolute or not
      Parameters:
        `params` - The named parameters
      Returns:
        The link to the static resource