如何获取当前ViewRoot的所有视图范围托管bean?

时间:2015-10-22 09:42:41

标签: jsf jsf-2 view-scope

我必须为页面上的所有视图范围托管bean实现一些bean post处理器。我已将SystemEventListenerPostConstructViewMapEvent一起实现为system-event-class。如何获取当前ViewRoot的所有视图范围托管bean? viewRoot.getViewMap()返回空映射(Mojarra JSF 2.1.19),但我有一些带有视图范围的托管bean。当然我可以在每个这样的bean中用@PostConstruct方法调用我的后处理器,但是有一个类似于Spring Framework的全局解决方案吗?

我的faces-config.xml配置:

<application>
        <system-event-listener>
            <system-event-listener-class>com.myapplicationname.ViewScopeBeanPostProcessor</system-event-listener-class>
            <system-event-class>javax.faces.event.PostConstructViewMapEvent</system-event-class>
            <source-class>javax.faces.component.UIViewRoot</source-class>
        </system-event-listener>
    </application>

0 个答案:

没有答案