JSF 2 Custom Scope usage

2019-06-28 02:21发布

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.

标签: scope jsf-2
2条回答
不美不萌又怎样
2楼-- · 2019-06-28 02:35

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

查看更多
仙女界的扛把子
3楼-- · 2019-06-28 02:40

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

查看更多
登录 后发表回答