Blog

Brad Wood

July 03, 2012

Spread the word


Share your thoughts

 

Everyone should be familiar with the setView method in the event object which is used for a handler's action to tell the framework which view file should be used to render the event:

 

event.setView(view="general/index");

 

What you may not realize is that calling setView() is optional.  If you don't explicitly set a view file, ColdBox will then look for the view according to the executing event's syntax. So if the incoming event is called general.index and no view is explicitly defined in your handler, ColdBox will look for a view in the general folder called index.cfm.

 

So this event URL:

http://www.example.com/index.cfm/general/index

 

Would default to the following view:

<web root>/views/general/index.cfm

 

Even if you don't use implicit views, it is recommended that your folder structure and naming conventions match beween your handlers and views for uniformity.

 

More info here: http://wiki.coldbox.org/wiki/Layouts-Views.cfm#Implicit_Views

 

P.S. If you depend on implicit views, remember that ColdBox lower cases the view name by default.  To switch this behavior, use the caseSensitiveImplicitViews setting.

 

Add Your Comment

Recent Entries

Into the Box is Going Online, Register Now!

Into the Box is Going Online, Register Now!

Dive into the Future of Web Development with Into the Box 2024 - now going global and online! No matter where you are, you're invited to join us for an amazing and enriching two-day experience on May 16th and 17th, packed with groundbreaking insights, expert sessions, and game-changing announcements.

Maria Jose Herrera
Maria Jose Herrera
May 01, 2024
Into the Box 2024: Your Gateway to the Future of Tech!

Into the Box 2024: Your Gateway to the Future of Tech!

Are you ready to advance your coding skills? The future of Modern Web Development awaits at Into the Box 2024, and we're thrilled to announce that due to high demand, we're extending our Early Bird pricing for an additional week!

Maria Jose Herrera
Maria Jose Herrera
April 26, 2024