Using the showSource parameter trick with rendered templates
March 31, 2008 – 12:19 pmThis is a follow-up to my previous post about using the showSource parameter in Grails.
If you’re using templates to keep DRY, you may need to pay attention to the details of the stack trace that show which GSP contains the error. For instance, say my show.gsp renders a template like this:
<g:render template="/person/personDetails" bean="${person}"/>
If there’s an error with the _personDetails.gsp, adding showSource to the URL of “show” (like this: http://localhost:8080/[APP_NAME]/person/show/1?showSource) won’t actually do the trick. That will show you the source of the show.gsp page, not the _personDetails.gsp page. Look closely at the stacktrace and you’ll see the actual path to the GSP that threw the exception - in this case it’s grails_app_views_person__personDetails_gsp (which translates to grails-app/views/person/_personDetails.gsp). If you change the URL to point directly at the GSP in question and then append the showSource parameter, (e.g. http://localhost:8080/[APP_NAME]/person/_personDetails.gsp?showSource) you’ll get the GSP source you’re looking for.

2 Responses to “Using the showSource parameter trick with rendered templates”
That is a handy trick. Thanks!
By Matthew Taylor on Apr 1, 2008
Dude, you’re lifesaver. It works great. Thanks, much!
By Hippy on Apr 8, 2008