Grails
  1. Grails
  2. GRAILS-4691

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

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 1.1.1
    • Fix Version/s: None
    • Component/s: Scaffolding
    • Labels:
      None

      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:

      ERROR [12869346@qtp0-0] (ScaffoldingViewResolver.java:101) - Error generating scaffolded view [/utilisateur/create]: C:\grails-1.1.1\src\grails\templates\scaffolding\editAsNew.gsp (File not found)
      java.io.FileNotFoundException: C:\grails-1.1.1\src\grails\templates\scaffolding\editAsNew.gsp (File not found)
      at java.io.FileInputStream.open(Native Method)
      at java.io.FileInputStream.<init>(FileInputStream.java:106)

      This error is only produced when the scaffolded view (the 'create' view, in the above example) has not been rendered yet (by the 'create' action, for example).

        Issue Links

          Activity

          Hide
          Graeme Rocher added a comment -

          Please attach an example that reproduces the problem

          Show
          Graeme Rocher added a comment - Please attach an example that reproduces the problem
          Hide
          Benjamin Gandon added a comment -

          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

          Show
          Benjamin Gandon added a comment - 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
          Hide
          Yury Emelyanov added a comment -

          Still persists in 1.2.1
          ScaffoldingViewResolver#generateViewSource() should take viewName into account, not actionName from request.

          Show
          Yury Emelyanov added a comment - Still persists in 1.2.1 ScaffoldingViewResolver#generateViewSource() should take viewName into account, not actionName from request.
          Hide
          Lari Hotari added a comment -

          Fixed by GPSCAFFOLD-62

          Show
          Lari Hotari added a comment - Fixed by GPSCAFFOLD-62

            People

            • Assignee:
              Unassigned
              Reporter:
              Benjamin Gandon
            • Votes:
              4 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Last Reviewed:

                Development