coldfusionluceefw1

FW/1 Controller changes not updating in view


Way late to the party, but was messing around with FW/1 this week and I am having a problem with controllers and real time updates. I have the following code to simulate authentication for now.

application.cfc

public function setupRequest()  { 

    controller("user.checkAuthorization");
 }

user.cfc

function checkAuthorization(any rc) {
    rc.authenticated = true;

}

In my view I toggle certain things based on rc.authenticated. All of this works fine, but if I toggle rc.authenticated from true to false nothing changes on the screen until I reset the app. Then I see the updated changes on the screens.

I'm not sure why changes aren't being made on page without the app re-init. Is this something in FW/1? Something in Lucee? Commandbox etc?


Solution

  • Controllers are cached by the framework so any changes won't be reflected until you reload the cache. You can do this on an ad hoc basis by adding ?reload=true to the URL.

    If you are in a dev environment and making frequent changes to controllers you could add some logic to the setupRequest() method in Application.cfc to clear the contoller cache on every request:

    public void function setupRequest(){
      if( isDevEnvironment ) // use your own way of determining this
        application[ variables.framework.applicationKey ].cache.controllers = {} // clear the controller cache on every request
    }