The earliest moment to visitTree() on fully built Component Tree?

前端 未结 1 2006
陌清茗
陌清茗 2021-01-24 02:18

Good morning, JSF experts!

Let me fugure out the problem I\'m trying to solve. The application has many forms. And elements in forms can be marked to require authorizati

相关标签:
1条回答
  • 2021-01-24 02:59

    That's the PostAddToViewEvent of the UIViewRoot itself. You can hook into it using a SystemEventListener implementation like below:

    public class YourSystemEventListener implements SystemEventListener {
    
        @Override
        public boolean isListenerForSource(Object source) {
            return (source instanceof UIViewRoot);
        }
    
        @Override
        public void processEvent(SystemEvent event) throws AbortProcessingException {
            UIViewRoot view = (UIViewRoot) event.getSource();
            // ...
        }
    
    }
    

    Which is registered in <application> of faces-config.xml like below:

    <system-event-listener>
        <system-event-listener-class>com.example.YourSystemEventListener</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>
    
    0 讨论(0)
提交回复
热议问题