{"id":4090,"date":"2011-08-28T20:31:22","date_gmt":"2011-08-28T15:01:22","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=4090"},"modified":"2016-12-19T15:06:16","modified_gmt":"2016-12-19T09:36:16","slug":"grails-console-plugin-gotcha","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/grails-console-plugin-gotcha\/","title":{"rendered":"Grails console plugin gotcha"},"content":{"rendered":"<p>Grails <a href=\"http:\/\/www.grails.org\/plugin\/console\">console<\/a> plugin is one of those which I always add to my projects. It really gives you a very handy way of debugging things and also run some quick fixes.<\/p>\n<p>Whenever you hit the console action you always gets a predefined message on it about the available variables, which is really good when you are a new user but in most of the cases you need to import few statements and you always need to write them before executing any command. <\/p>\n<p>So in my recent project I looked at the plugin code and I found a nice way to change the default statements.<\/p>\n<p>I added the following line in my project application filter.<br \/>\n[java]<br \/>\nconsoleImports(controller: &#8216;console&#8217;, action: &#8216;*&#8217;) {<br \/>\n     before = {<br \/>\n             String importStatements = &quot;&quot;&quot;import com.intelligrape.package1.*<br \/>\n             import com.intelligrape.package2.*<br \/>\n             import com.intelligrape.package3.*<br \/>\n             import com.intelligrape.package4.* &quot;&quot;&quot;<\/p>\n<p>             session[&#8216;_grails_console_last_code_&#8217;] = session[&#8216;_grails_console_last_code_&#8217;] ?:importStatements<br \/>\n      }<br \/>\n}<br \/>\n[\/java]<\/p>\n<p>\nIt could be a small but great enhancement in the console plugin to just update it to provide the starting code as a configuration option<br \/>\n<\/p>\n<p>Hope it helps<br \/>\n<a href=\"http:\/\/www.tothenew.com\/blog\/author\/uday\/\">Uday Pratap Singh<\/a><br \/>\n<a href=\"mailto:uday@intelligrape.com\">uday@intelligrape.com<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Grails console plugin is one of those which I always add to my projects. It really gives you a very handy way of debugging things and also run some quick fixes. Whenever you hit the console action you always gets a predefined message on it about the available variables, which is really good when you [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0},"categories":[7],"tags":[623,622,624,625],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/4090"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=4090"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/4090\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=4090"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=4090"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=4090"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}