I would like to implement the following:
import org.springframework.web.servlet.support.RequestContextUtils as RCU
class HomeController {
def home = {
def locale = RCU.getLocale(request)
render view: viewExists("home_$locale") ? "home_$locale": "home"
}
}
What is the code of boolean viewExists(String viewPath) that returns true if the input argument points to a valid GSP or Template file?
You could try this:
(modified from this post) but note the caveat that getResourceForUri() is private (see here). The code works for me but it doesn’t give me a warm/fuzzy feeling.
I think the question is to frame your question in terms of the larger goal/problem and try to solve that. Grails probably has an answer.