-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FaceletContext: add static utility methods getCurrentInstance() and getCurrentInstance(FacesContext context) #2015
Comments
I cant follow? |
I'm not sure I've understood... I'm referring to the following class: |
so you wanna add this 2 new methods? |
yeah :D I probably should have specified that ... |
fixed ;) |
i think its a good small change to add in 5.0; cc @BalusC |
+1 |
If it can be a global static method to get the instance, do not forget to expose it as CDI bean. |
we dont have something like a FacesRequestScope yet |
FaceletContext has a shorter lifetime than FacesContext as well. And it can be recreated multiple times during a single "Faces Request/Context Scope". It's basically only available during view build time (which can indeed occur multiple times during a Faces request). Hence generally any attempt to obtain it in a normal backing bean is hacky. It makes totally sense in tag handlers and it makes somewhat sense in ui components and should be handled with care and a good understanding of the facelet / uicomponent lifecycle. Tag handlers and ui components are already no injection targets in first place, so exposing it as CDI bean makes no sense. And indeed as Thomas hinted, a new scope should be introduced therefor, but not "Faces Request/Context Scope". |
Basically the idea is to have the same utility method
similar to
FacesContext.getCurrentInstance()
the implementation could be something like:
The text was updated successfully, but these errors were encountered: