I wrote 开发者_开发百科a PhaseListener and would like to know if it is possible to access a controller through it.
You can evaluate an EL expression programmatically by Application#evaluateExpressionGet()
. Wrap this in a convenience method like follows:
@SuppressWarnings("unchecked")
public static <T> T findBean(String beanName) {
FacesContext context = FacesContext.getCurrentInstance();
return (T) context.getApplication().evaluateExpressionGet(context, "#{" + beanName + "}", Object.class);
}
Use it in your JSF code as follows:
MyBackingBean myManagedBean = JSF.findBean("myManagedBeanName");
// ...
精彩评论