JSF 2 Custom Scope usage

微笑、不失礼 提交于 2020-01-24 07:19:53

问题


I am going through all the scopes in JSF2.0. I am a little confused about when to use custom Scope. Any specific use cases it will be useful.

Initially I thought I can use it for scope spanning multiple pages like three page registration etc. But looks like we cannot use it there.


回答1:


Better late than never: I wrote an article about the usage custom scopes in JSF2 : JSF 2 Custom Scopes without 3rd party libraries




回答2:


Well, the general idea is to create your own Scope for what ever you like e.g. kind of "Conversation Scope". The problem is already adressed within JSR 299 (CDI) and imho this is where it belongs to.

My attempts to create a custom scope resulted in Exceptions thrown by the JSF implementation as soon as the context is destroyed. Since it seems that there are no working examples available, custom scopes should be considered as non-existent in JSF2.0, though announced as a key feature.

Anyway, if you are looking for custom scopes take a look at CDI (escpecially Weld and MyFaces CODI), MyFaces Orchestra (for Conversation Scopes in JSF), Seam (offers a nice solution) or create a Custom Scope using Spring.

HTH



来源:https://stackoverflow.com/questions/5055831/jsf-2-custom-scope-usage

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!