Grails

StackOverflowError when view using g:include is rendered with "render(view:'viewname')" syntax in controller

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.2 final
  • Fix Version/s: 1.2.1
  • Component/s: View technologies
  • Labels:
    None
  • Environment:
    Grails 1.2.0 , Sun Java 1.6.0_16 32 bit , Ubuntu 9.10 64 bit
  • Testcase included:
    yes

Description

g:include recurses the call to the same action when the view using g:include is rendered with "render(view:'viewname')" syntax in the controller.

There's an example grails application showing the bug.

Start the test app with "grails run-app" and go to url http://localhost:8080/IncludeBugGrailsApp/some , click on the link "Show bug" and you'll see the recursing behaviour and StackOverflowError.

Rendering is ok if the view is rendered with "return new ModelAndView('/some/index', [:])" syntax.

Issue Links

Activity

Hide
Lari Hotari added a comment -

probably a problem in SimpleGrailsControllerHelper.handleActionResponse (grails/src/java/org/codehaus/groovy/grails/web/servlet/mvc/SimpleGrailsControllerHelper.java) .

ModelAndView explicityModelAndView = (ModelAndView)controller.getProperty(ControllerDynamicMethods.MODEL_AND_VIEW_PROPERTY);

render(view:'index') sets this property and the g:include call gets recursed because this value is retained in the included request.

Show
Lari Hotari added a comment - probably a problem in SimpleGrailsControllerHelper.handleActionResponse (grails/src/java/org/codehaus/groovy/grails/web/servlet/mvc/SimpleGrailsControllerHelper.java) .
ModelAndView explicityModelAndView = (ModelAndView)controller.getProperty(ControllerDynamicMethods.MODEL_AND_VIEW_PROPERTY);
render(view:'index') sets this property and the g:include call gets recursed because this value is retained in the included request.
Hide
Lari Hotari added a comment -

ModelAndView property is stored in requestAttributes:

(from ControllerGrailsPlugin.groovy)

mc.setModelAndView = {ModelAndView mav ->
            RCH.currentRequestAttributes().setAttribute(GrailsApplicationAttributes.MODEL_AND_VIEW, mav, 0)
        }
        mc.getModelAndView = {->
            RCH.currentRequestAttributes().getAttribute(GrailsApplicationAttributes.MODEL_AND_VIEW, 0)
        }
Show
Lari Hotari added a comment - ModelAndView property is stored in requestAttributes: (from ControllerGrailsPlugin.groovy)
mc.setModelAndView = {ModelAndView mav ->
            RCH.currentRequestAttributes().setAttribute(GrailsApplicationAttributes.MODEL_AND_VIEW, mav, 0)
        }
        mc.getModelAndView = {->
            RCH.currentRequestAttributes().getAttribute(GrailsApplicationAttributes.MODEL_AND_VIEW, 0)
        }
Hide
Graeme Rocher added a comment -

Bulk closing bunch of resolved issues

Show
Graeme Rocher added a comment - Bulk closing bunch of resolved issues

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: