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

UIViewRoot.addComponentResource() adding multiple components with same ID instead of replacing

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.2-SNAPSHOT
    • 2.0.2
    • JSR-314
    • None

    Description

      Looks like when MYFACES-2854 was committed, there were two issues it caused where we break spec compliance. Both are around behavior that "If the component ID of componentResource matches the the ID of a resource that has allready been added, remove the old resource."

      The first is that it looks like the "else if (componentId != null)" statement is in the wrong place.
      If a UIComponent is added with the same ID as an existing component, we'll never get to this check since we'll be false on the isInView() check.
      This will cause duplicate ID exceptions to be thrown if multiple objects with the same ID are added.
      This is easily resolved by moving the else if to kick in whenever isInView() is false.

      The second issue, and the more important since this is breaking a TCK test, is that since we were only comparing to the parent's ID to the location prefix, we weren't handling the case where the same object gets added a second time after updating the target.
      This can be resolved by changing

      if (componentResource.getParent() != null &&
      componentResource.getParent().getId() != null &&
      componentResource.getParent().getId().startsWith(JAVAX_FACES_LOCATION_PREFIX)) ...
      to
      if (componentResource.getParent() != null &&
      componentResource.getParent().getId() != null &&
      componentResource.getParent().getId().equals(JAVAX_FACES_LOCATION_PREFIX + target))

      I'll attach a patch for review while I wait for our CTS team to try the change out. I probably wont' be able to commit until after the US Labor Day holiday since I'm away Friday.

      Attachments

        1. MYFACES-2908-patch.txt
          2 kB
          Michael Concini

        Activity

          People

            mconcini Michael Concini
            mconcini Michael Concini
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: