Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-3931

RelocatableResourceHandler tag + inner f:facet = NullPointerException

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.12, 2.2.5
    • 2.0.23, 2.1.17, 2.2.6
    • General
    • None
    • Primefaces compatibility issue (discovered with primfaces component, but reproducible on standalone myfaces app)

    Description

      When primefaces h:head renderer is used with inner f:facet (first\middle\last) like follows:

      <h:head id="head">
          <f:facet name="first">
      	 <h:outputScript name="jquery.js"/>
          </f:facet>
      </h:head>
      

      Application crashes with NPE during some AJAX requests on ComponentTagHandlerDelegate:337

      ComponentSupport.removeFacet(ctx, parent, c, facetName);
      

      This is caused by:

      1. ComponentTagHandlerDelegate:190 - Resolves facet name from non-relocated parent _HtmlHead (id="head")
      2. ComponentTagHandlerDelegate:327 - Changes parent to re-located element UIPanel(id="j_idhead_f_first")_, resolved with HtmlOutputScriptHandler
      3. ComponentTagHandlerDelegate:337 - Uses re-located parent with non-relocated parents facet name, facet isn't found, NPE is thrown.

      Solution:
      Refresh facetName when parent is changed, see diff:

      --- a/myfaces-2.1.12/myfaces-impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java	Wed Oct 08 15:18:20 2014 +0300
      +++ b/myfaces-2.1.12/myfaces-impl/src/main/java/org/apache/myfaces/view/facelets/tag/jsf/ComponentTagHandlerDelegate.java	Wed Oct 08 15:18:33 2014 +0300
      @@ -325,6 +325,7 @@
                           {
                               // Replace parent with the relocated parent.
                               parent = c.getParent();
      +                        facetName = this.getFacetName(ctx, parent); // refresh facet name according to new parent
                           }
                       }
                       if (facetName == null)
      

      Note: Exception handling for such cases can be improved, as application crashes during render phase no response is rendered and MyFaces ExceptionHandler is unable to add exception into AJAX response - this way no exception is logged or returned, empty screen is rendered without any errors.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            lu4242 Leonardo Uribe
            shadow.ex Anton Zukovskij
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment