dev@javaserverfaces.java.net

Seeking Review: 1461 <f:event type="preRenderView" >not as viewRoot child.

From: Ed Burns <Ed.Burns_at_Sun.COM>
Date: Thu, 17 Dec 2009 00:21:20 -0500

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(