<html> | |
<head> | |
<title>GroovyPages Test</title> | |
</head> | |
<body> | |
<h2 align="center">Visible Syntax</h2> | |
<table border="0" cellpadding="2" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber4"> | |
<tr> | |
<td> | |
<i>Links:</i></td> | |
<td> | |
<i> | |
<a href="default.htm">Examples Home</a></i></td> | |
<td> | |
<i> <a href="simple.gsp">Simple Example</a></i></td> | |
<td> | |
<i> | |
<a href="visible.gsp?arg=This+is+a+test+argument&lastCount=${session.count}"> | |
Visible Syntax</a></i></td> | |
<td> | |
<i> | |
<a href="jsp.gsp?arg=This+is+a+test+argument&lastCount=<%=session.count%>"> | |
JSP Syntax</a></i></td> | |
</tr> | |
</table> | |
<p> This is an example of GroovyPages showing the use of the editor | |
visible syntax. This syntax uses curly braces like %{ groovlet }% and ${ | |
expression }, instead of the less-than greater-than of JSP, like <% groovlet %> | |
and <%= expression %>. Though both syntaxes are supported in GroovyPages, | |
using visible syntax is sometimes preferable when the programmer is also the | |
page designer or when they want to see and edit their in the web editor's | |
formatted, normal view, rather than in raw, noisy HTML all of the time. | |
It's perfectly acceptable to mix both syntaxes on the same page.</p> | |
<p><i><b>Make sure count is set and increment it on each refresh</b></i><br> | |
^p%{<br> | |
if (session.count == null) session.count = 1<br> | |
}%</p> | |
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1"> | |
<tr> | |
<td valign="top" width="50%"> | |
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2"> | |
<tr> | |
<td colspan="2" align="center"><b>Page Arguments</b></td> | |
</tr> | |
<tr> | |
<td>Argument</td> | |
<td>Value</td> | |
</tr> | |
<tr> | |
<td colspan="2"><i><b>For each parameter</b></i><br> | |
^tr%{ for (it in request) { }%</td> | |
</tr> | |
<tr> | |
<td>${ it.key }</td> | |
<td>${ it.value }</td> | |
</tr> | |
<tr> | |
<td colspan="2">^tr%{ } }% <i><b>Comments are safe before and after | |
stripping tags</b></i></td> | |
</tr> | |
</table> | |
</td> | |
<td valign="top" width="50%"> | |
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber3"> | |
<tr> | |
<td colspan="2" align="center"><b>Session Variables</b></td> | |
</tr> | |
<tr> | |
<td>Variable</td> | |
<td>Value</td> | |
</tr> | |
<tr> | |
<td colspan="2"><i><b>For each session variable</b></i><br> | |
^tr%{ session.each() { }%</td> | |
</tr> | |
<tr> | |
<td>${ it.key }</td> | |
<td>${ it.value }</td> | |
</tr> | |
<tr> | |
<td colspan="2">^tr%{ } }% <i><b>because they will get | |
stripped off</b></i></td> | |
</tr> | |
</table> | |
</td> | |
</tr> | |
</table> | |
<p><i><b>Increment the count on each refresh</b></i><br> | |
^p%{ | |
session.count++ | |
}%</p> | |
<h3>The Source Code</h3> | |
<p> You will note that the source code below appears more noisy when | |
compared with JSP syntax. It is when you look at the raw HTML. But | |
web editors help you to stay out of HTML mode, and when you edit your page that | |
way most of the noise goes away.</p> | |
<pre><p><i><b>Make sure count is set</b></i><br> | |
<span style="background-color: #99FF99">^p%{<br> | |
if (session.count == null) session.count = 1<br> | |
}%</span></p> | |
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1"> | |
<tr> | |
<td valign="top" width="50%"> | |
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2"> | |
<tr> | |
<td colspan="2" align="center"><b>Page Arguments</b></td> | |
</tr> | |
<tr> | |
<td>Argument</td> | |
<td>Value</td> | |
</tr> | |
<tr> | |
<td colspan="2"><span style="background-color: #99FF99"><i><b>For each parameter</b></i><br> | |
^tr%{ for (it in request) { }%</span></td> | |
</tr> | |
<tr> | |
<td><span style="background-color: #99FF99">${ it.key }</span></td> | |
<td><span style="background-color: #99FF99">${ it.value }</span></td> | |
</tr> | |
<tr> | |
<td colspan="2"><span style="background-color: #99FF99">^tr%{ } }% <i><b>Comments are safe before and after | |
stripping tags</b></i></span></td> | |
</tr> | |
</table> | |
</td> | |
<td valign="top" width="50%"> | |
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber3"> | |
<tr> | |
<td colspan="2" align="center"><b>Session Variables</b></td> | |
</tr> | |
<tr> | |
<td>Variable</td> | |
<td>Value</td> | |
</tr> | |
<tr> | |
<td colspan="2"><span style="background-color: #99FF99"><i><b>For each session variable</b></i><br> | |
^tr%{ session.each() { }%</span></td> | |
</tr> | |
<tr> | |
<td><span style="background-color: #99FF99">${ it.key }</span></td> | |
<td><span style="background-color: #99FF99">${ it.value }</span></td> | |
</tr> | |
<tr> | |
<td colspan="2"><span style="background-color: #99FF99">^tr%{ } }% <i><b>because they will get | |
stripped off</b></i></span></td> | |
</tr> | |
</table> | |
</td> | |
</tr> | |
</table> | |
<p><i><b>Increment the count on each refresh</b></i><br> | |
<span style="background-color: #99FF99">^p%{ session.count++ }%</span></p> | |
</pre> | |
</body> | |
</html> |