<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Piraguablog &#187; grails</title>
	<atom:link href="http://www.piragua.com/category/grails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.piragua.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 22 Jun 2010 22:03:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Grails pageScope variable in GSPs and TagLibraries</title>
		<link>http://www.piragua.com/2010/06/22/grails-pagescope-variable-in-gsps-and-taglibraries/</link>
		<comments>http://www.piragua.com/2010/06/22/grails-pagescope-variable-in-gsps-and-taglibraries/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 21:55:42 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[grails]]></category>
		<category><![CDATA[quicktip]]></category>

		<guid isPermaLink="false">http://www.piragua.com/?p=69</guid>
		<description><![CDATA[Grails pageScope variable is available to you in Tag Libraries and GSPs and contains a wealth of state information.  For instance, you can set an attribute in the model in a controller and then reference it in a TagLibrary through the pageScope variable without having to pass it through the tag attributes
Controller:

def myAction = [...]]]></description>
			<content:encoded><![CDATA[<p>Grails pageScope variable is available to you in Tag Libraries and GSPs and contains a wealth of state information.  For instance, you can set an attribute in the model in a controller and then reference it in a TagLibrary through the pageScope variable without having to pass it through the tag attributes</p>
<p>Controller:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy"><span style="color: #000000; font-weight: bold;">def</span> myAction <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">//...</span>
    <span style="color: #993333;">boolean</span> readOnly <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">true</span>
    render<span style="color: #66cc66;">&#40;</span>view: <span style="color: #ff0000;">'edit'</span>, model: <span style="color: #66cc66;">&#91;</span>bookInstance:book, readOnly:readOnly<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>GSP:</p>

<div class="wp_syntax"><div class="code"><pre>    &lt;g:myInputFieldTag name=&quot;title&quot; value=&quot;${bookInstance.title}&quot;/&gt;</pre></div></div>

<p>TagLibrary</p>

<div class="wp_syntax"><div class="code"><pre class="groovy"><span style="color: #000000; font-weight: bold;">def</span> myInputFieldTag <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span> attrs-<span style="color: #66cc66;">&gt;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>pageScope.<span style="color: #006600;">readOnly</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        out <span style="color: #b1b100;">&lt;&lt;</span> attrs.<span style="color: #006600;">value</span>
    <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
        out <span style="color: #b1b100;">&lt;&lt;</span> <span style="color: #808080; font-style: italic;">//...</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>You can also use it within a GSP or to get access to variables you have set in a GSP or to store variables in page scope in a tag library.<br />
Docs:<br />
<a href="http://grails.org/doc/latest/ref/Tag%20Libraries/pageScope.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/grails.org');">http://grails.org/doc/latest/ref/Tag%20Libraries/pageScope.html</a><br />
and<br />
<a href="http://grails.org/1.0-RC1+Release+Notes#Improved%20support%20for%20scopes" onclick="javascript:pageTracker._trackPageview('/outbound/article/grails.org');">http://grails.org/1.0-RC1+Release+Notes#Improved%20support%20for%20scopes</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.piragua.com/2010/06/22/grails-pagescope-variable-in-gsps-and-taglibraries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grails Dependency Management – Setting the Ivy Proxy</title>
		<link>http://www.piragua.com/2010/06/18/grails-dependency-management-%e2%80%93-setting-the-ivy-proxy/</link>
		<comments>http://www.piragua.com/2010/06/18/grails-dependency-management-%e2%80%93-setting-the-ivy-proxy/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 17:07:50 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[grails]]></category>
		<category><![CDATA[quicktip]]></category>

		<guid isPermaLink="false">http://www.piragua.com/?p=63</guid>
		<description><![CDATA[When dealing with corporate firewalls and proxy servers, dependency management can be a pain.  With Grails 1.3.1 I recently encountered an issue resolving dependencies that were not in a maven central repository.  I had already done &#8216;grails set-proxy&#8217; and that seemed to do the trick for the majority of the dependencies I needed, [...]]]></description>
			<content:encoded><![CDATA[<p>When dealing with corporate firewalls and proxy servers, dependency management can be a pain.  With Grails 1.3.1 I recently encountered an issue resolving dependencies that were not in a maven central repository.  I had already done &#8216;grails set-proxy&#8217; and that seemed to do the trick for the majority of the dependencies I needed, but these few turned out to be very elusive.</p>
<p>After some quick searching, I stumbled across a <a href="http://stackoverflow.com/questions/2921364/proxy-settings-with-ivy" onclick="javascript:pageTracker._trackPageview('/outbound/article/stackoverflow.com');">way to set the Ivy proxy through the ANT_OPTS environment variable</a>.  That didn&#8217;t do the trick, but passing those parameters to grails directly DID.  </p>
<p>If you&#8217;re running Grails from the command line, you can do the following:<br />
<code><br />
grails -Dhttp.proxyHost=your.proxyserver.com -Dhttp.proxyPort=80 clean<br />
</code></p>
<p>If you&#8217;re using Hudson (as I was), you can add two additional lines into the &#8220;Properties&#8221; box of your &#8220;Build with Grails&#8221; configuration<br />
<code><br />
http.proxyHost=your.proxyserver.com<br />
http.proxyPort=80 clean<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.piragua.com/2010/06/18/grails-dependency-management-%e2%80%93-setting-the-ivy-proxy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Grails Dependency Management &#8211; Excluding dependencies</title>
		<link>http://www.piragua.com/2010/05/28/grails-dependency-management-excluding-dependencies/</link>
		<comments>http://www.piragua.com/2010/05/28/grails-dependency-management-excluding-dependencies/#comments</comments>
		<pubDate>Fri, 28 May 2010 15:36:34 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[grails]]></category>
		<category><![CDATA[quicktip]]></category>

		<guid isPermaLink="false">http://www.piragua.com/?p=59</guid>
		<description><![CDATA[Sometimes you need finer control over the dependencies included in your build. In BuildConfig.groovy you can exclude dependent dependencies by using the &#8216;excludes&#8217; keyword &#8211; for example:

dependencies &#123;
        runtime &#40;group:'org.apache.tika', name:'tika-parsers', version:'0.7'&#41;&#123;
            excludes 'commons-compress'
    [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need finer control over the dependencies included in your build. In BuildConfig.groovy you can exclude dependent dependencies by using the &#8216;excludes&#8217; keyword &#8211; for example:</p>

<div class="wp_syntax"><div class="code"><pre class="java">dependencies <span style="color: #66cc66;">&#123;</span>
        runtime <span style="color: #66cc66;">&#40;</span>group:<span style="color: #ff0000;">'org.apache.tika'</span>, name:<span style="color: #ff0000;">'tika-parsers'</span>, version:<span style="color: #ff0000;">'0.7'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
            excludes <span style="color: #ff0000;">'commons-compress'</span>
        <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.piragua.com/2010/05/28/grails-dependency-management-excluding-dependencies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One week with WhenWorksForYou.com</title>
		<link>http://www.piragua.com/2009/07/13/one-week-with-whenworksforyoucom/</link>
		<comments>http://www.piragua.com/2009/07/13/one-week-with-whenworksforyoucom/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 11:25:07 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[grails]]></category>
		<category><![CDATA[groovy]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.piragua.com/?p=37</guid>
		<description><![CDATA[Last week I launched http://www.whenworksforyou.com, a new Grails website that lets you coordinate schedules with other people to find the best date for your next event.  Our first week provided lots of great feedback from users.  One of the biggest gripes was not being able to subscribe to updates on an event.  [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I launched <a href="http://www.whenworksforyou.com" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.whenworksforyou.com');">http://www.whenworksforyou.com</a>, a new Grails website that lets you coordinate schedules with other people to find the best date for your next event.  Our first week provided lots of great feedback from users.  One of the biggest gripes was not being able to subscribe to updates on an event.  Well, thanks to the <a href="http://grails.org/plugin/feeds" onclick="javascript:pageTracker._trackPageview('/outbound/article/grails.org');">feeds</a> and <a href="http://grails.org/plugin/mail" onclick="javascript:pageTracker._trackPageview('/outbound/article/grails.org');">mail</a> plugins, now you can!  It was dead simple to implement, and now I can focus my attention on the next feature rather than having to re-invent the wheel on RSS and email.</p>
<p>The site also takes advantage of several other plugins, including</p>
<ul>
<li><a href="http://grails.org/plugin/acegi" onclick="javascript:pageTracker._trackPageview('/outbound/article/grails.org');">Spring Security</a></li>
<li><a href="http://grails.org/plugin/ui-performance" onclick="javascript:pageTracker._trackPageview('/outbound/article/grails.org');">UI Performance</a></li>
<li><a href="http://grails.org/plugin/recaptcha" onclick="javascript:pageTracker._trackPageview('/outbound/article/grails.org');">Recaptcha</a></li>
<li><a href="http://grails.org/plugin/build-test-data" onclick="javascript:pageTracker._trackPageview('/outbound/article/grails.org');">Build Test Data</a></li>
<li>Test Code Coverage (of course)</li>
</ul>
<p>Thanks to all the plugin developers who took the time to build and document plugins for the Grails framework!</p>
<p>I also wrote one other plugin that wraps GreenMail and acts as a transient &#8220;Inbox&#8221; for sending emails during development.  I&#8217;m putting the finishing touches on that now, stay tuned for more information.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.piragua.com/2009/07/13/one-week-with-whenworksforyoucom/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Grails, p6spy and Sql Profiler</title>
		<link>http://www.piragua.com/2009/06/17/grails-p6spy-and-sql-profiler/</link>
		<comments>http://www.piragua.com/2009/06/17/grails-p6spy-and-sql-profiler/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 04:46:21 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[grails]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.piragua.com/?p=35</guid>
		<description><![CDATA[There are several ways to have Grails log SQL statements that Hibernate is sending to the database under the covers of GORM.  The first is the loggingSql flag in DataSource.groovy:

loggingSql=true

This will show you the prepared statement that Hibernate is generating, like this:

SELECT
        this_.id AS id6_0_,
    [...]]]></description>
			<content:encoded><![CDATA[<p>There are several ways to have Grails log SQL statements that Hibernate is sending to the database under the covers of GORM.  The first is the loggingSql flag in DataSource.groovy:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy">loggingSql<span style="color: #66cc66;">=</span><span style="color: #000000; font-weight: bold;">true</span></pre></div></div>

<p>This will show you the prepared statement that Hibernate is generating, like this:</p>

<div class="wp_syntax"><div class="code"><pre class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span>
        this_.id <span style="color: #993333; font-weight: bold;">AS</span> id6_0_,
        this_.version <span style="color: #993333; font-weight: bold;">AS</span> version6_0_,
        this_.authority <span style="color: #993333; font-weight: bold;">AS</span> authority6_0_,
        this_.description <span style="color: #993333; font-weight: bold;">AS</span> descript4_6_0_
    <span style="color: #993333; font-weight: bold;">FROM</span>
        role this_
    <span style="color: #993333; font-weight: bold;">WHERE</span>
        this_.authority<span style="color: #66cc66;">=</span>?</pre></div></div>

<p>This is a good first step &#8211; but what if I want to see the parameter that is being sent as well?  You could turn logging for the org.hibernate.type package to TRACE level:</p>

<div class="wp_syntax"><div class="code"><pre class="groovy"><span style="color: #808080; font-style: italic;">//in Config.groovy</span>
log4j <span style="color: #66cc66;">=</span> <span style="color: #66cc66;">&#123;</span>
    trace  <span style="color: #ff0000;">'org.hibernate.type'</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>YIKES!  That gets REALLY noisy, really fast:</p>

<div class="wp_syntax"><div class="code"><pre class="apache">Hibernate:
    select
        this_.id as id6_0_,
        this_.version as version6_0_,
        this_.authority as authority6_0_,
        this_.description as descript4_6_0_
    <span style="color: #00007f;">from</span>
        role this_
    where
        this_.authority=?
TRACE type.StringType  - binding <span style="color: #7f007f;">'ROLE_USER'</span> to parameter: <span style="color: #ff0000;">1</span>
TRACE type.LongType  - returning <span style="color: #7f007f;">'1'</span> as column: id6_0_
TRACE type.LongType  - returning <span style="color: #7f007f;">'1'</span> as column: version6_0_
TRACE type.StringType  - returning <span style="color: #7f007f;">'ROLE_USER'</span> as column: authority6_0_
TRACE type.StringType  - returning <span style="color: #7f007f;">'Default user role'</span> as column: descript4_6_0_</pre></div></div>

<p>Besides, what I really want is the ability to copy and paste a query, with the parameters bound, directly into a SQL editor to execute the query and see the results myself.  Enter the <a href="http://grails.org/plugin/p6spy" onclick="javascript:pageTracker._trackPageview('/outbound/article/grails.org');">p6spy plugin for Grails</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="text">grails install-plugin p6spy</pre></div></div>

<p>Swap the driver in your DataSource.groovy file from your driver to the p6spy driver (the plugin will automatically add this, you just need to comment it in):</p>

<div class="wp_syntax"><div class="code"><pre class="groovy">environments <span style="color: #66cc66;">&#123;</span>
  development <span style="color: #66cc66;">&#123;</span>
    dataSource <span style="color: #66cc66;">&#123;</span>
      <span style="color: #808080; font-style: italic;">//driverClassName = &quot;org.hsqldb.jdbcDriver&quot;</span>
      driverClassName <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;com.p6spy.engine.spy.P6SpyDriver&quot;</span>
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Fire up your Grails application &#8211; p6spy will create a spy.log file in your application directory and log a pipe delimited line &#8211; the last column has the actual SQL being executed, with the parameters!</p>

<div class="wp_syntax"><div class="code"><pre class="text">select this_.id as id2_0_, this_.version as version2_0_, this_.authority as authority2_0_, this_.description as descript4_2_0_ from role this_ where this_.authority='ROLE_USER'</pre></div></div>

<p>This is a great start, and most people stop here.  But sometimes there are so many queries being executed that it&#8217;s difficult to wade through spy.log to find the one you&#8217;re looking for.  Thanks to a tip from the excellent <a href="http://www.manning.com/gsmith/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.manning.com');">Grails In Action</a> book that was recently released &#8211; SQL Profiler can help!</p>
<p>Download SQL Profiler (<a href="http://sourceforge.net/projects/sqlprofiler" onclick="javascript:pageTracker._trackPageview('/outbound/article/sourceforge.net');">http://sourceforge.net/projects/sqlprofiler</a>) and add these lines to grails-app/conf/spy.properties:</p>

<div class="wp_syntax"><div class="code"><pre class="text">log4j.appender.SQLPROFILER_CLIENT=org.apache.log4j.net.SocketAppender
log4j.appender.SQLPROFILER_CLIENT.RemoteHost=localhost
log4j.appender.SQLPROFILER_CLIENT.Port=4445
log4j.appender.SQLPROFILER_CLIENT.LocationInfo=true</pre></div></div>

<p>Add the appender to the logger definition:</p>

<div class="wp_syntax"><div class="code"><pre class="text">log4j.logger.p6spy=INFO,STDOUT,SQLPROFILER_CLIENT</pre></div></div>

<p>Finally, make sure the Log4j Appender is enabled:</p>

<div class="wp_syntax"><div class="code"><pre class="text">#specifies the appender to use for logging
appender=com.p6spy.engine.logging.appender.Log4jLogger
#appender=com.p6spy.engine.logging.appender.StdoutLogger
#appender=com.p6spy.engine.logging.appender.FileLogger</pre></div></div>

<p>Then, in the directory in which you downloaded the SQL Profiler jar, launch the GUI with this line:</p>

<div class="wp_syntax"><div class="code"><pre class="text">java -jar sqlprofiler.jar</pre></div></div>

<p>Now, p6spy will log SQL to the SQL Profiler GUI!  You can use it to profile SQL statements, but you can also use the &#8216;Logger&#8217; tab to filter the log.  I click the little trash can icon in the upper left to clear the log, run a test in the application, then filter the results using the filter fields available.  For instance, if I only want to see queries related to the &#8216;ROLE&#8217; table, just put the word &#8216;role&#8217; in the Filter message text box, and you&#8217;ll only see queries related to that table.  It&#8217;s a great way to get straight at a particular SQL query when you&#8217;re drowning in tons and tons of SQL messages.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.piragua.com/2009/06/17/grails-p6spy-and-sql-profiler/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
