Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions system/web/Renderer.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,16 @@ component

// Do we have a view To render? Else throw exception
if ( NOT len( arguments.view ) ) {
var viewNotSetDetail = "Please remember to use the 'event.setView()' method in your handler or pass in a view to render."
// Implicit views are disabled by default, so point at the most likely cause
if ( !variables.controller.getSetting( name = "ImplicitViews", defaultValue = false ) ) {
viewNotSetDetail &= " The ""implicitViews"" setting is disabled (the default since 8.3.0), so the view is not discovered from the event ('#event.getCurrentEvent()#'). Either set the view explicitly with event.setView(), or enable implicit views with the ""implicitViews = true"" setting in your config/Coldbox.cfc."
}
throw(
message = "The ""currentview"" variable has not been set, therefore there is no view to render.",
detail = "Please remember to use the 'event.setView()' method in your handler or pass in a view to render.",
detail = viewNotSetDetail,
type = "Renderer.ViewNotSetException"
);
)
}

// Cleanup leading / in views, just in case
Expand Down
24 changes: 24 additions & 0 deletions tests/specs/web/RendererTest.cfc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**

Check failure on line 1 in tests/specs/web/RendererTest.cfc

View workflow job for this annotation

GitHub Actions / TestBox Report adobe@2023-11

RendererTest.ColdBox Renderer explains that implicit views are disabled when no view is set

renderView() should have thrown
Raw output
/home/runner/work/coldbox-platform/coldbox-platform/tests/specs/web/RendererTest.cfc:171

Check failure on line 1 in tests/specs/web/RendererTest.cfc

View workflow job for this annotation

GitHub Actions / TestBox Report adobe@2025-21

RendererTest.ColdBox Renderer explains that implicit views are disabled when no view is set

renderView() should have thrown
Raw output
/home/runner/work/coldbox-platform/coldbox-platform/tests/specs/web/RendererTest.cfc:171
* Renderer integration tests
*/
component extends="tests.resources.BaseIntegrationTest" {
Expand Down Expand Up @@ -153,6 +153,30 @@
}
} )

it( "explains that implicit views are disabled when no view is set", () => {
var controller = getController()
var originalSetting = controller.getSetting( "ImplicitViews" )
controller.setSetting( "ImplicitViews", false )

try {
var event = getRequestContext()
event.overrideEvent( "main.index" )
event.setView( "" )
var thrown = ""
try {
renderer.renderView( view = "" )
} catch ( any e ) {
thrown = e
}
expect( thrown ).notToBeEmpty( "renderView() should have thrown" )
expect( thrown.type ).toBe( "Renderer.ViewNotSetException" )
expect( thrown.detail ).toInclude( "implicitViews" )
expect( thrown.detail ).toInclude( "main.index" )
} finally {
controller.setSetting( "ImplicitViews", originalSetting )
}
} )

describe( "Discovery Cache", () => {
it( "viewDiscoveryCaching setting defaults to true", () => {
expect( getController().getSetting( "viewDiscoveryCaching" ) ).toBeTrue();
Expand Down
Loading