You are on page 1of 1

application

applicationContext
flash
grailsApplication
out
params
request
response
session
<g:set var="foo" value="bar" scope="scope"/>
<g:if test="foo"> ... </if>
<g:each in="foo" var="bar"> ... </g:each>
<g:else> ... </else>
<g:while test="foo"> .. </g:while>
<g:link action="foo" id="42"> .. </g:link>
<g:link controller="bar" action="foo"> .. </g:link>
<g:link action="foo" params="[baz:'qux']"> .. </g:link>
<g:form name="foo" url="[controller:'bar',action:'baz']">...</g:form>
<g:textField name="foo" value="bar" />
<g:passwordField name="foo" value="bar" />
<g:checkBox name="foo" value="bar" checked="baz"/>
<g:radio name="foo" value="bar" checked="baz"/>
<g:hiddenField name="foo" value="bar" />
<g:select name="foo" from="bar" value="baz"
optionKey="qux" multiple="true|false" />
<g:actionSubmit value="foo" action="bar" />
<g:render template="foo" model="[bar: baz]" />
action: foo
controller:foo, action: bar
uri: '/foo.html'
url: 'www.foo.com'
servletContext
session
request
params
flash
<g:layoutTitle
default="foo" />
<g:layoutHead />
<g:layoutBody />
def foo = {attrs, body ->
out << "bar"
}
def foo = {attrs, body ->
if (attrs.bar){
out << body()
}
}
def foo = {attrs, body ->
attrs.n.times{
out << body()
}
}
"/foo"(controller:'bar')
"/foo"(controller:'bar', action:'baz')
"/foo/$bar"(controller:'baz')
"/foo/$bar/$qux?"(controller:'baz')
"/foo/$action"(controller:'baz')
"/foo"(controller:'bar', view:'baz')
"/foo"(controller:'bar',
action:[GET: 'baz', PUT: 'qux'])
application-wide
current HTTP session
current HTTP request
request parameters
this and next request
in same controller
in different controller
URI relative to context path
absolute URL
current servletContext
current applicationContext
the ash scope object
the Grails application instance
response output stream
HTTP request parameters
HTTP request instance
HTTP response instance
current HTTP session
assign bar to foo in scope
evaluate if foo is true
evaluate if preceding <g:if> is false
repeat block for each foo assigned to bar
repeat block until foo is false
create link to action foo in current controller with id 42
create link to action foo in controller bar
create link to action foo in current controller with some extra request parameters
create form that will submit to action baz in controller bar
text eld input element with name foo and value bar
password input element with name foo and value bar
checkbox input element with name foo and value bar, checked if baz evaluates true
radio button input element with name foo and value bar, checked if baz evaluates true
hidden input element with name foo and value bar,
select input element with name foo, options drawn from collection bar, currently selected value
baz, option values given by property qux of elements
button with label foo that will submit form to action bar
render template foo with object baz assigned to variable bar
/foo maps to default action in controller bar
/foo maps to action baz in controller bar
/foo/42 maps to default action in controller baz with
variable bar set to 42
as above with optional additional variable qux e.g.
/foo/42/69 will set both bar and qux
determine action from URL
/foo maps to baz.gsp in controller bar
action depends on HTTP request type
GET baz, PUTqux,
insert target page <title> attribute
with default "foo"
insert target page <head> tag
insert target page <body> tag
<g:foo />
<g:foo bar="true">baz</g:foo>
<g:foo bar="false">qux</g:foo>
/grails-app/conf/UrlMappings.groovy
in controller:
redirect()
accessible in .gsp e.g
${ash}
embed Groovy code in tag using ${expr}
/grails-app/views/layouts/
<g:foo n="3">baz</g:foo>
bar
baz

o
w

c
o
n
t
r
o
l
l
i
n
k
s
f
o
r
m
s
bazbazbaz
GSP variables
GSP tags
URL mapping Redirects
Scopes
Layout tags
Tag libraries
grailscheatsheet.com 2.2.2
The web layer

You might also like