开发者

Custom component and access to backing bean

Is it possible in JSF2 from a custom component (in method encodeBegin) to access to the FacesContext and managed beans?

Thanks you.开发者_JAVA技巧


Yes. Even more, the FacesContext is available as method argument of encodeBegin() method.

Then, to access managed beans, use Application#evaluateExpressionGet().

Bean bean = (Bean) context.getApplication().evaluateExpressionGet(context, "#{beanName}", Bean.class);


public Object getSessionBean(String beanName) {
FacesContext context = FacesContext.getCurrentInstance(); sessMap = context.getExternalContext().getSessionMap(); return sessMap.get(BeanName); }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜