Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9197833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:09:26+00:00 2026-06-17T22:09:26+00:00

Say I have a very simple controller like so: <cfcomponent extends=Controller> <cffunction name=hello> <cfset

  • 0

Say I have a very simple controller like so:

<cfcomponent extends="Controller">
    <cffunction name="hello">
        <cfset time = Now()>
    </cffunction>
</cfcomponent>

In straight ColdFusion / Railo, I would be locally scoping all variables within this…but every wheels example I see does not.

This is probably going to earn me the dumbest question of the year award, but it was something I was thinking about, since nobody ever seems to demonstrate their Wheels code scoped correctly?

I would write it as follows:

<cfcomponent extends="Controller">
    <cffunction name="hello">
        <cfset local.time = Now()>
    </cffunction>
</cfcomponent>

I am just not sure if Wheels perhaps does something to remedy this regardless, and that’s why I see what I do everywhere…or is it just a case of bad programming?

Thanks!
Mikey

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:09:27+00:00Added an answer on June 17, 2026 at 10:09 pm

    Yes, you should be scoping it.

    In your first example, you are (by not scoping) in most cases setting variables.time, which is local to the component instance, not to the function – if this is intended as a function-local variable (i.e. local.time) but is in the component’s variable scope, and that component is shared/persisted, this may cause issues (though perhaps ones that only reveal themselves under heavy load).

    If putting the variable in the variables scope is deliberate, it should still be explicitly scoped (as variables.time) otherwise it may cause issues if used on a Railo server with the localmode setting enabled.

    Due to a cfWheels design decision (see links in comments), putting variables in the variables scope is required to pass variables to the view, even though they may technically be local to the function/view. (The controller instance lives for a single request, avoiding the issues this normally entails.) As mentioned in the previous paragraph, the localmode setting (described below) means it is still recommended to explicitly scope when you are not in control of all servers the code will be deployed to.

    Railo’s localmode setting

    Railo (since v1) has had an admin setting called “localmode” which defines whether assigning an unscoped variable will go to the local scope, rather than the component’s variables scope – making explicit var/local scoping not required (if you know your code will only be run on Railo servers with that setting enabled).

    Since that setting is off by default, and ColdFusion does not have such a setting, cross-engine-compatible code should always scope such variable assignments to avoid this being an issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a very simple PrototypeJS class that looks like this: var
Let's say I have a very simple task like this: @celery.task(ignore_result=True) def print_page(page): with
Let’s say that we have a very simple QML file, like this one: import
Say I have a very simple WPF grid (6 rows x 6 columns) defined
Let's say I have the following, very simple block of code: <script> function hasVal(field)
Let's say we have very simple Java class MyClass . public class MyClass {
Lets say I have a controller class like this. public class InStorePickupController : Controller
Say I have a very simple java object that only has some getXXX and
A very simple question, yet I couldn't find the answer. Let's say we have
Let's say I have a very simple C file (called foo.c): int main() {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.