I have a grails 2.2.0 application. I have created a global filter and that has some check. if the check fails then it renders a static view file using render view: viewFileName ending the flow else it returns true saying app can continue. At login action, the action renders a login view calling render view: loginFileName but it displays the viewFileName instead. Note that filter pass has already passed by now and the check in it has passed too. This issue seems similar to earlier post Grails "respond" renders the wrong view when launched from .war file but the difference is that there are two index view files of same name but in different controller but here we have filter rendering a view if some condition passes which gets displayed even if that condition fails. To makes sure that this is an issue, i removed that render view: viewFileName in filter with render "< div>....< /div >" and then it worked all well i.e. action displayed the right page and not the static page. I can post more detail if required. I cannot rely on that page that is in string to render as that will not be long term. Here are the two classes with issue
class MainController {
def login() {
def param = getHeaderParameters()
render view: "login", model: param
}
}
class MainFilters {
private final String mainControllerName = "main"
private final String startPage = "start"
def GrailsConventionGroovyPageLocator groovyPageLocator
def filters = {
all(controller: '*', action: '*') {
before = {
if (AdminUtils.isStart(request)) {
println "rending start page...."
final fileView = "/$mainControllerName/$startPage"
render view: fileView
}
}
}
}
redirectto the action you need.redirect(controller:... action: 'login')- Alidad