In JSF1 you can access the bean instances of your current FacesContext
by
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext()
ev.getApplicationMap().get(beanName) // get an @ApplicationScoped bean instance
ev.getSessionMap().get(bean开发者_C百科Name) // get a @SessionScoped bean instance
ev.getRequestMap().get(beanName) // get a @RequestScoped bean instance
In JSF2 @ViewScoped
has been introduced, but I can't find a corresponding getViewMap()
method on ExternalContext
? I am using latest JSF 2.1.1-b04.
Am i misunderstanding some aspects of a @ViewScoped
bean? Is there another good-practice to get a @ViewScoped
bean instance on the server side?
Thanks, Steve
Try to eval expression (evaluateExpressionGet):
context.getApplication().evaluateExpressionGet(context, "#{beanName}", BeanClass.class)
View scoped data is stored in the view root. You can get this from the context.
精彩评论