浏览 1879 次
锁定老帖子 主题:jsf bean
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2007-11-23
那我在别的bean中该怎么得到这个id值? 实在不知道该怎么得到了 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2007-11-24
搞定!
public static AdminBean getAdminBean() { return (AdminBean) getManagedBean(BeanNames.ADMIN_BEAN); } /** * Get managed bean based on the bean name. * * @param beanName * the bean name * @return the managed bean associated with the bean name */ public static Object getManagedBean(String beanName) { Object o = getValueExpression(getJsfEl(beanName)).getValue( FacesContext.getCurrentInstance().getELContext()); return o; } public static ValueExpression getValueExpression(String el) { return getApplication().getExpressionFactory().createValueExpression( FacesContext.getCurrentInstance().getELContext(), el, Object.class); } private static Application getApplication() { ApplicationFactory appFactory = (ApplicationFactory) FactoryFinder .getFactory(FactoryFinder.APPLICATION_FACTORY); return appFactory.getApplication(); } 注:BeanNames.ADMIN_BEAN 为您要取的bean |
|
返回顶楼 | |