Groovy Documentation

org.codehaus.groovy.grails.plugins.web.taglib
[Groovy] Class ApplicationTagLib

java.lang.Object
  org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib
All Implemented Interfaces:
org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean, GrailsApplicationAware

@Artefact("TagLibrary")
class ApplicationTagLib
extends java.lang.Object

The base application tag library for Grails many of which take inspiration from Rails helpers (thanks guys! :) This tag library tends to get extended by others as tags within here can be re-used in said libraries

Authors:
Graeme Rocher


Property Summary
static java.lang.Object LINK_WRITERS

static java.lang.Object SCOPES

static java.lang.Object SUPPORTED_TYPES

org.springframework.context.ApplicationContext applicationContext

groovy.lang.Closure cookie

Obtains the value of a cookie.

groovy.lang.Closure createLink

Creates a grails application link from a set of attributes.

groovy.lang.Closure createLinkTo

Creates a link to a resource, generally used as a method rather than a tag.

groovy.lang.Closure external

Render the appropriate kind of external link for use in based on the type of the URI.

GrailsApplication grailsApplication

UrlMappingsHolder grailsUrlMappingsHolder

groovy.lang.Closure header

Renders the specified request header value.

groovy.lang.Closure img

Render an img tag with src set to a static resource

attr:
dir Optional name of resource directory, defaults to "images"
attr:
file Name of resource file (optional if uri specified)
attr:
plugin Optional the name of the grails plugin if the resource is not part of the application
@attr uri Optional app-relative URI path of the resource if not using dir/file attributes - only if Resources plugin is in use

groovy.lang.Closure join

Uses the Groovy JDK join method to concatenate the toString() representation of each item in this collection with the given separator.

groovy.lang.Closure link

General linking to controllers, actions etc.

LinkGenerator linkGenerator

groovy.lang.Closure meta

Output application metadata that is loaded from application.properties.

GrailsPluginManager pluginManager

groovy.lang.Closure resource

Creates a link to a resource, generally used as a method rather than a tag.

groovy.lang.Closure set

Sets a variable in the pageContext or the specified scope.

boolean useJsessionId

groovy.lang.Closure withTag

Helper method for creating tags called like:

    withTag(name:'script',attrs:[type:'text/javascript']) {
    ...
    }
 
attr:
name REQUIRED the tag name
@attr attrs tag attributes

 
Method Summary
void afterPropertiesSet()

static java.lang.String attrsToString(java.util.Map attrs)

static java.lang.Object getAttributesToRender(java.lang.Object constants, java.lang.Object attrs)

protected java.lang.Object renderResourceLink(java.lang.Object attrs)

attr:
uri
@attr type

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Property Detail

LINK_WRITERS

static java.lang.Object LINK_WRITERS


SCOPES

static final java.lang.Object SCOPES


SUPPORTED_TYPES

static java.lang.Object SUPPORTED_TYPES


applicationContext

org.springframework.context.ApplicationContext applicationContext


cookie

groovy.lang.Closure cookie
Obtains the value of a cookie.
emptyTag:
@attr name REQUIRED the cookie name


createLink

groovy.lang.Closure createLink
Creates a grails application link from a set of attributes. This link can then be included in links, ajax calls etc. Generally used as a method call rather than a tag eg.
<a href="${createLink(action:'list')}">List</a>
emptyTag:
@attr controller The name of the controller to use in the link, if not specified the current controller will be linked
attr:
action The name of the action to use in the link, if not specified the default action will be linked
attr:
uri relative URI
attr:
url A map containing the action,controller,id etc.
attr:
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.
attr:
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.
attr:
id The id to use in the link
attr:
fragment The link fragment (often called anchor tag) to use
attr:
params A map containing URL query parameters
attr:
mapping The named URL mapping to use to rewrite the link
attr:
event Webflow _eventId parameter


createLinkTo

groovy.lang.Closure createLinkTo
Creates a link to a resource, generally used as a method rather than a tag.
eg. <link type="text/css" href="${createLinkTo(dir:'css',file:'main.css')}" />
emptyTag:


external

groovy.lang.Closure external
Render the appropriate kind of external link for use in based on the type of the URI. For JS will render