Sharing components between views - how to improve my design?

你离开我真会死。 提交于 2019-12-04 13:01:51

If you want share data between all your application users you can use application scope.

If you still want to use view scope, you can connect your view scope with another application scope like this:

ApplicationView appView = BeanUtil.findBean("applicationView", FacesContext.getCurrentInstance());

import javax.faces.context.FacesContext;

public class BeanUtil {

@SuppressWarnings("unchecked")
public static <T> T findBean(String beanName, FacesContext context) {
    return (T) context.getApplication().evaluateExpressionGet(context,
            "#{" + beanName + "}", Object.class);
}

}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!