tags:

views:

370

answers:

1

Hi everyone,

I have an application that was coded with JSPs and now we are in the process to migrate to the pages to Facelets.

One of our PhaseListeners is manipulating the component tree, because it needs to find out some components in the tree and extract some of its values. But with Facelets, UIViewRoot does not return any children.

How can I get the same type of functionality with Facelets?

Thanks in advance, Paulo

+2  A: 

Retrieving UIViewRoot with this line should work:

FacesContext.getCurrentInstance().getViewRoot

My guess is that you are trying to manipulate the component tree in the first phase of JSF lifecycle. (link)

The first phase consists of retrieving the view, that is, the component tree, for the requested page. Therefore you can just explore the component tree after this phase has completed.

Use

phaseEvent.getPhaseId()

to see which phase you are working in.

ckarmann
The listener was being called during the RESTORE_VIEW phase, which worked without problems for the JSP pages.It was not so with Facelets, but thanks to your remark, I have tried another phase, RENDER_REPONSE, and now it works as before.
Paulo Pinto