7

Is there any way to find out the current view (or gsp file) that is being evaluated?

RequestURI doesn't work due to URL Mappings and forwards.

I'm trying to retrieve resources dynamically based on the current GSP file. For example, if product/view.gsp is being executed, I want to include product/view.css and product/view.js (if they exist). The part that I'm having a problem with is getting the text "view"

Alex
  • 8,093
  • 6
  • 49
  • 79
Reverend Gonzo
  • 39,701
  • 6
  • 59
  • 77

1 Answers1

8

A gsp page is compiled into a class derived from org.codehaus.groovy.grails.web.pages.GroovyPage. You can get the whole pathname of the gsp file with ${this.getGroovyPageFileName()}, or just ${groovyPageFileName}. You'll have to trim off the path information yourself.

ataylor
  • 64,891
  • 24
  • 161
  • 189