Hi,

I am working with JSF/MyFaces and am about to implement my own component. The whole background story might be too complicated, but in short: During rendering, my component loads data. The loading might fail (partly) and produce FacesMessages. However, they might be produced too late, since the component responsible for displaying the FacesMessages might already be rendered. Therefore, I am trying to register to the PreRenderView event in order to pre-load the data, so that the FacesMessages are created early enough. Actually, if you know a solution for the initial problem that does not require the PreRenderView event, that would be great, too.

My current problem is that registering using getFacesContext().getViewRoot().subscribeToViewEvent(...) is not enough. First, my component might be recreated later (so I re-register in processRestoreState(), which works fine). Second, my component might be reused and therefore placed in a different view. For example, this is the case if my component or one of its ancestors has a binding attribute. After being placed in the new view (this is done by IBM WebSphere), the component is registered to the wrong/old view root, so that it does not receive the event anymore. I thought that I could unregister in PreRemoveFromView and then register in PostAddToView, but they are both raised in the new view-root, which I am trying to register to in the first place.

So my question is: Is there a reliable way for a component to always receive the PreRenderViewEvent from the view root that it currently belongs to?

Thank you for any help!

Philipp

Reply via email to