I need to access jsf pages component tree on application start up. I found this source on the net
UIViewRoot viewRoot = context.getApplication().getViewHandler().createView(context, "/path/to/some.xhtml");
but the resulting viewRoot doesn’t have any children.
Does anybody know what is the best way to do it?
thanks.
You forgot to build the view. You can use
ViewDeclarationLanguage#buildView()for this. Here’s an extract of its javadoc (emphasis mine):Thus, this should do:
You can by the way also use the
ViewDeclarationLanguage#createView()directly to create the view instead of theViewHandler#createView()shorthand.