英文:
FW/1 Controller changes not updating in view
问题
抱歉,以下是您要翻译的内容:
晚来的参与者,但本周在尝试 FW/1 时遇到了与控制器和实时更新有关的问题。我现在有以下代码来模拟身份验证。
application.cfc
controller("user.checkAuthorization");
}
user.cfc
rc.authenticated = true;
}
在我的视图中,我基于 rc.authenticated 切换某些内容。所有这些都运行正常,但如果我将 rc.authenticated 从 true 切换到 false,则屏幕上什么都不会改变,直到我重置应用程序。然后,我才会在屏幕上看到更新后的更改。
我不确定为什么在不重新初始化应用程序的情况下不会进行更改。这是 FW/1 中的某种问题吗?是 Lucee 中的某种问题吗?Commandbox 等等?
英文:
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?
答案1
得分: 1
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 controller 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
}
英文:
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
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论