public interface LinkGenerator
Generates links for a Grails application based on URL mapping rules and/or base context settings.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public java.lang.String |
getContextPath()Obtains the context path from which this link generator is operating. |
|
public java.lang.String |
getDefaultNamespace(java.lang.String controller, java.lang.String pluginName)Resolves the effective namespace to use for a link/redirect that targets the given controller when the caller did not supply an explicit namespace attribute. |
|
public java.lang.String |
getServerBaseURL()The base URL of the server used for creating absolute links. |
|
public java.lang.String |
link(java.util.Map params)Generates a link to a controller, action or URI for the given named parameters. |
|
public 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. |
|
public java.lang.String |
resolveNamespace(java.lang.String controller, java.lang.String pluginName, java.util.Map attrs)Resolves the namespace to pass to reverse URL mapping when a caller may have supplied an explicit namespace attribute. |
|
public java.lang.String |
resource(java.util.Map params)Generates a link to a static resource for the given named parameters. |
Obtains the context path from which this link generator is operating.
Resolves the effective namespace to use for a link/redirect that targets the given controller
when the caller did not supply an explicit namespace attribute.
Implementations infer the namespace from the registered controllers so that links generated
from controller and action alone "just work" without a namespace attribute. The
contract is:
null when that single controller is non-namespaced).null and must be disambiguated by specifying the namespace explicitly.Callers must only use this when no explicit namespace attribute was supplied; an
explicit namespace (including an explicit blank one) must always take precedence so that
namespace="" (or namespace: null) can be used to target a non-namespaced
controller.
When a pluginName is supplied the target lives in a plugin, so cross-controller
inference from the application's own controllers is not performed.
controller - The logical name of the target controllerpluginName - The name of the plugin providing the target controller, or nullnull for the default namespaceThe base URL of the server used for creating absolute links.
Generates a link to a controller, action or URI for the given named parameters. Possible named parameters include:
params - The named parametersGenerates a link to a controller, action or URI for the given named parameters. Possible named parameters include:
params - The named parametersencoding - The character encoding to use Resolves the namespace to pass to reverse URL mapping when a caller may have supplied an
explicit namespace attribute.
An explicit namespace always wins, including an explicit null or blank value. Blank
values are normalised to null because reverse mappings key non-namespaced controllers on
null. Only when the attribute is absent is getDefaultNamespace(String, String)
consulted.
controller - The logical name of the target controllerpluginName - The name of the plugin providing the target controller, or nullattrs - The attributes that may contain ATTRIBUTE_NAMESPACEnull for the default namespaceGenerates a link to a static resource for the given named parameters. Possible named parameters include:
params - The named parameters