簡體   English   中英

自定義組件和對后備bean的訪問

[英]Custom component and access to backing bean

在JSF2中是否可以從自定義組件(在encodeBegin方法中)訪問FacesContext和托管bean?

謝謝。

是。 甚至, FacesContext可以作為encodeBegin()方法的方法參數。

然后,要訪問托管bean,請使用Application#evaluateExpressionGet()

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

公共對象getSessionBean(String beanName){
FacesContext context = FacesContext.getCurrentInstance(); sessMap = context.getExternalContext()。getSessionMap(); 返回sessMap.get(BeanName); }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM