ScaffoldingViewResolver.loadView() don't look for viewName being a scaffolded view!

Details

Description

The ScaffoldingViewResolver#loadView() method first looks for viewName being resolved by super class (GrailsViewResolver), and then directly gets the controller action name to generate the corresponding view.

There is no second try for viewName being a scaffolded view to be generated and then rendered.

The result is that when a scaffolded 'editAsNew' action tries to render the scaffolded 'create' view, the following error is produced:

Benjamin Gandon
added a comment - 17/Jun/09 7:11 AM From a fresh grails project. The domain class is:
public class Book {
String title
}
The scaffolded controller:
class BookController {
def scaffold = Book
def editAsNew =
{
def bookInstance = Book.get(params.id)
render(view:'create',model:['bookInstance':bookInstance])
}
}
Some BootStrap code:
def init =
{ servletContext ->
new Book(title:"starwars").save()
}
Then < http://localhost:8080/grails-issue-demo/book/editAsNew/1 > and you get the error.
HTTP ERROR: 404
/WEB-INF/grails-app/views/book/create.jsp
RequestURI=/grails-issue-demo/WEB-INF/grails-app/views/book/create.jsp
Whereas the /book/create.gsp view should be generated.
The problem looks like it resides in ScaffoldingViewResolver#generateViewSource(GrailsWebRequest, GrailsDomainClass) around line 125
templateGenerator.generateView(domainClass,webRequest.getActionName(),sw);
always get the action name instead of the actually requested viewName. It looks like it should be something like this instead:
templateGenerator.generateView(domainClass,viewName,sw);
cheers