Yes, it is my understanding that preRenderView event is only called for
the UIViewRoot (although, I would like to see an event available that is
called for before a component is encoded). +1 for your change.
Ken
Ed Burns wrote:
> Firstly, the tlddocs for <f:event> don't even mention preRenderView.
> I think that's in the errata, but I can't check because some hackers
> took down the wiki.
>
> Secondly, I think this is a bug. Can someone r=?
>
> Issue: 1461
>
>
> SECTION: Modified Files
> ----------------------------
> M jsf-ri/src/com/sun/faces/facelets/tag/jsf/core/EventHandler.java
>
> - make it so PreRenderView is always added to the UIViewRoot.
>
>
> SECTION: Diffs
> ----------------------------
> Index: jsf-ri/src/com/sun/faces/facelets/tag/jsf/core/EventHandler.java
> ===================================================================
> --- jsf-ri/src/com/sun/faces/facelets/tag/jsf/core/EventHandler.java
> (revision 8236)
> +++ jsf-ri/src/com/sun/faces/facelets/tag/jsf/core/EventHandler.java
> (working copy)
> @@ -43,13 +43,11 @@
> import javax.el.MethodNotFoundException;
> import javax.faces.FacesException;
> import javax.faces.component.UIComponent;
> -import javax.faces.component.UIViewRoot;
> import javax.faces.context.FacesContext;
> import javax.faces.event.AbortProcessingException;
> import javax.faces.event.ComponentSystemEvent;
> import javax.faces.event.ComponentSystemEventListener;
> import javax.faces.event.SystemEvent;
> -import javax.faces.event.SystemEventListener;
> import javax.faces.view.facelets.ComponentHandler;
> import javax.faces.view.facelets.FaceletContext;
> import javax.faces.view.facelets.TagAttribute;
> @@ -57,7 +55,8 @@
> import javax.faces.view.facelets.TagHandler;
> import java.io.IOException;
> import java.io.Serializable;
> -import java.util.List;
> +import javax.faces.component.UIViewRoot;
> +import javax.faces.event.PreRenderViewEvent;
>
> /**
> * This is the TagHandler for the f:event tag.
> @@ -75,6 +74,12 @@
> public void apply(FaceletContext ctx, UIComponent parent) throws
> IOException {
> if (ComponentHandler.isNew(parent)) {
> Class<? extends SystemEvent> eventClass =
> getEventClass(ctx);
> + UIViewRoot viewRoot = ctx.getFacesContext().getViewRoot();
> + // ensure that f:event can be used anywhere on the page
> for preRenderView,
> + // not just as a direct child of the viewRoot
> + if (PreRenderViewEvent.class == eventClass && parent !=
> viewRoot) {
> + parent = viewRoot;
> + }
> if (eventClass != null) {
> parent.subscribeToEvent(eventClass,
> new DeclarativeSystemEventListener(
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>