JSF System Listener 和动态用户授权设置

JSF SystemListner and dynamic user autorization setting

我试图实现 中提到的动态用户访问级别。但是,在解析时我没有看到完整的 DOM 树。解析时我只能看到模板页面的子元素。我错过了什么?

代码片段:

脸-config.xml

<system-event-listener>
    <system-event-listener-class>com.xyz.listner.FieldDisableListener</system-event-listener-class>
    <system-event-class>javax.faces.event.PostAddToViewEvent</system-event-class>
    <source-class>javax.faces.component.UIViewRoot</source-class>
</system-event-listener>

JSF 页面

<ui:composition template="/WEB-INF/templates/samplePage.xhtml">
<ui:param name="focusElement" value="frmWelcome:newProfileLink" />
<ui:define name="pageContents">
<h:form id="pendingsearchForm" styleClass="content-body">
<h:commandLink action="#{searchBean.release}" 
                id="searchcmdbtn" <<-- updated
                value="Release" 
                immediate="true"
                rendered="#{searchBean.resultFound}" >
</h:commandLink>

监听代码

@Override
public void processEvent(SystemEvent event) throws AbortProcessingException    {
UIViewRoot root = (UIViewRoot) event.getSource();
loadUserAccessConfig();
processViewTree(root);
}
@Override
public boolean isListenerForSource(Object source) {
if (source instanceof UIViewRoot)
  return true;
return false;
}

我在我的 JSF 树解析逻辑中做了以下更改以使我的代码工作:

facesContext.getViewRoot().getFacetsAndChildren();