Package grails.web.mapping
Interface LinkGenerator
-
- All Known Implementing Classes:
CachingLinkGenerator,org.grails.web.mapping.DefaultLinkGenerator
public interface LinkGeneratorGenerates links for a Grails application based on URL mapping rules and/or base context settings.- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringATTRIBUTE_ABSOLUTEstatic java.lang.StringATTRIBUTE_ACTIONstatic java.lang.StringATTRIBUTE_BASEstatic java.lang.StringATTRIBUTE_CONTEXT_PATHstatic java.lang.StringATTRIBUTE_CONTROLLERstatic java.lang.StringATTRIBUTE_ELEMENT_IDstatic java.lang.StringATTRIBUTE_EVENTstatic java.lang.StringATTRIBUTE_FRAGMENTstatic java.lang.StringATTRIBUTE_IDstatic java.lang.StringATTRIBUTE_INCLUDE_CONTEXTstatic java.lang.StringATTRIBUTE_MAPPINGstatic java.lang.StringATTRIBUTE_METHODstatic java.lang.StringATTRIBUTE_NAMESPACEstatic java.lang.StringATTRIBUTE_PARAMSstatic java.lang.StringATTRIBUTE_PLUGINstatic java.lang.StringATTRIBUTE_RELATIVE_URIstatic java.lang.StringATTRIBUTE_RESOURCEstatic java.lang.StringATTRIBUTE_URIstatic java.lang.StringATTRIBUTE_URLstatic java.util.Set<java.lang.String>LINK_ATTRIBUTESstatic java.util.Map<java.lang.String,java.lang.String>REST_RESOURCE_ACTION_TO_HTTP_METHOD_MAPstatic java.util.Map<java.lang.String,java.lang.String>REST_RESOURCE_HTTP_METHOD_TO_ACTION_MAP
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringgetContextPath()Obtains the context path from which this link generator is operating.java.lang.StringgetServerBaseURL()The base URL of the server used for creating absolute links.java.lang.Stringlink(java.util.Map params)Generates a link to a controller, action or URI for the given named parameters.java.lang.Stringlink(java.util.Map params, java.lang.String encoding)Generates a link to a controller, action or URI for the given named parameters.java.lang.Stringresource(java.util.Map params)Generates a link to a static resource for the given named parameters.
-
-
-
Field Detail
-
ATTRIBUTE_CONTROLLER
static final java.lang.String ATTRIBUTE_CONTROLLER
- See Also:
- Constant Field Values
-
ATTRIBUTE_RESOURCE
static final java.lang.String ATTRIBUTE_RESOURCE
- See Also:
- Constant Field Values
-
ATTRIBUTE_ACTION
static final java.lang.String ATTRIBUTE_ACTION
- See Also:
- Constant Field Values
-
ATTRIBUTE_METHOD
static final java.lang.String ATTRIBUTE_METHOD
- See Also:
- Constant Field Values
-
ATTRIBUTE_URI
static final java.lang.String ATTRIBUTE_URI
- See Also:
- Constant Field Values
-
ATTRIBUTE_RELATIVE_URI
static final java.lang.String ATTRIBUTE_RELATIVE_URI
- See Also:
- Constant Field Values
-
ATTRIBUTE_INCLUDE_CONTEXT
static final java.lang.String ATTRIBUTE_INCLUDE_CONTEXT
- See Also:
- Constant Field Values
-
ATTRIBUTE_CONTEXT_PATH
static final java.lang.String ATTRIBUTE_CONTEXT_PATH
- See Also:
- Constant Field Values
-
ATTRIBUTE_URL
static final java.lang.String ATTRIBUTE_URL
- See Also:
- Constant Field Values
-
ATTRIBUTE_BASE
static final java.lang.String ATTRIBUTE_BASE
- See Also:
- Constant Field Values
-
ATTRIBUTE_ABSOLUTE
static final java.lang.String ATTRIBUTE_ABSOLUTE
- See Also:
- Constant Field Values
-
ATTRIBUTE_ID
static final java.lang.String ATTRIBUTE_ID
- See Also:
- Constant Field Values
-
ATTRIBUTE_FRAGMENT
static final java.lang.String ATTRIBUTE_FRAGMENT
- See Also:
- Constant Field Values
-
ATTRIBUTE_PARAMS
static final java.lang.String ATTRIBUTE_PARAMS
- See Also:
- Constant Field Values
-
ATTRIBUTE_MAPPING
static final java.lang.String ATTRIBUTE_MAPPING
- See Also:
- Constant Field Values
-
ATTRIBUTE_EVENT
static final java.lang.String ATTRIBUTE_EVENT
- See Also:
- Constant Field Values
-
ATTRIBUTE_ELEMENT_ID
static final java.lang.String ATTRIBUTE_ELEMENT_ID
- See Also:
- Constant Field Values
-
ATTRIBUTE_PLUGIN
static final java.lang.String ATTRIBUTE_PLUGIN
- See Also:
- Constant Field Values
-
ATTRIBUTE_NAMESPACE
static final java.lang.String ATTRIBUTE_NAMESPACE
- See Also:
- Constant Field Values
-
LINK_ATTRIBUTES
static final java.util.Set<java.lang.String> LINK_ATTRIBUTES
-
REST_RESOURCE_ACTION_TO_HTTP_METHOD_MAP
static final java.util.Map<java.lang.String,java.lang.String> REST_RESOURCE_ACTION_TO_HTTP_METHOD_MAP
-
REST_RESOURCE_HTTP_METHOD_TO_ACTION_MAP
static final java.util.Map<java.lang.String,java.lang.String> REST_RESOURCE_HTTP_METHOD_TO_ACTION_MAP
-
-
Method Detail
-
resource
java.lang.String resource(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
-
link
java.lang.String link(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
-
link
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. 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 parametersencoding- The character encoding to use- Returns:
- The generator link
-
getContextPath
java.lang.String getContextPath()
Obtains the context path from which this link generator is operating.- Returns:
- The base context path
-
getServerBaseURL
java.lang.String getServerBaseURL()
The base URL of the server used for creating absolute links.- Returns:
- The base URL of the server
-
-