在 Coldbox 中使用wirebox如何从模型创建bean
我还不擅长术语,所以请原谅/纠正我。另外我不知道如何使用 Coldspring 等,所以我尝试只使用wirebox。
我不想使用 beanFactory 插件,而只是直接从我的模型调用wirebox 方法。
目前我可以使用这个
<cfproperty name="bf" inject="coldbox:plugin:BeanFactory" scope="variables" />
How do it以便我可以调用wirebox的getInstance方法而不是beanFactory的getModel?
I am not good with the terminology yet, so please forgive/correct me. Also I have no idea hw to use Coldspring, etc, so I am trying to just use wirebox.
I want to not use the beanFactory plugin and just call wirebox methods straight from my model.
Currently I can use this
<cfproperty name="bf" inject="coldbox:plugin:BeanFactory" scope="variables" />
How do I do it so that I can call wirebox's getInstance method instead of beanFactory's getModel?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在处理程序中,您可以使用属性注入让 Wirebox 注入 bean(与您发布的内容非常相似)。
基于标签
基于脚本
然后,您只需调用
myModel.someMethod()
即可在处理程序中的任何位置使用该模型。还值得注意的是,如果您使用模型的 ID 进行注入,则不需要
inject
的值。 Wirebox 将尝试使用您指定的名称查找模型。你可以简化它。基于标签
基于脚本
Within the handler, you can have Wirebox inject beans using property injection (much like what you posted).
Tag Based
Script Based
You can then use the model anywhere in the handler by simply calling
myModel.someMethod()
.It's also worth noting that if you are injecting using the model's ID, then the value of
inject
isn't required. Wirebox will attempt to look up the model using the name you gave it. You could simplify it.Tag Based
Script Based
我不确定这是否是您正在寻找的答案,但是...
在处理程序中您可以执行此操作。
在模型中你可以这样做。
这能满足您的需求吗?
I am not sure this is the answer you are looking for but...
In the handler you can do this.
In a model you can do this.
Does this answer what you need?