ICEfaces
  1. ICEfaces
  2. ICE-5754

Dynamically added components cause "duplicate id" problems

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.0-Alpha2
    • Fix Version/s: 2.0-Alpha3, 2.0.0
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      ICEfaces 2 JSF 2

      Description

      Dynamically added components can cause "duplicate id" problems if setId() is not called explicitly. It's just been noted that the BridgeSetup adds a couple of UIOutput components that don't set the id. We need to review and ensure that we are consistently setting the id of these components.

        Activity

        Hide
        Deryk Sinotte added a comment -

        Please check the BridgeSetup (and any other PostAddToView event listeners that might dynamically add components) and ensure that we are setting the id in a consistent fashion.

        Show
        Deryk Sinotte added a comment - Please check the BridgeSetup (and any other PostAddToView event listeners that might dynamically add components) and ensure that we are setting the id in a consistent fashion.
        Hide
        Deryk Sinotte added a comment -

        It's the same thing as was noted in ICE-5669. If we don't call setId and use something somewhat unique, then we'll get a duplicate id exception.

        Show
        Deryk Sinotte added a comment - It's the same thing as was noted in ICE-5669 . If we don't call setId and use something somewhat unique, then we'll get a duplicate id exception.
        Hide
        Mircea Toma added a comment - - edited

        After some digging through the JSF sources I discovered the reason why we were getting the duplicate ID problem. It turns out that UIViewRoot and any other naming container component will use its own counter for assigning IDs to components (when not assigned programmatically or in the jspx template). The counter value is saved in an associated component state helper.
        So, while UIViewRoot would generate IDs based on its counter saved in its state helper and a prefix (UIViewRoot.UNIQUE_ID_PREFIX) same will do a form in the page. The form will have its own counter, assigning IDs to child components with the same prefix (UIViewRoot.UNIQUE_ID_PREFIX ) and potentially with the same values for the counter that UIViewRoot's counter went through.

        Right now we are forced to assign IDs to components only when they are appended to a naming container, such as UIForm, and that we already do. Any components added to the tree by using UIViewRoot.addComponentResource method will not need to have an ID assigned because all these components will receive generated IDs based on the UIViewRoot's counter. Some of the components added through UIViewRoot.addComponentResource have their ID assigned because the ID is used by the Javascript code rendered by the component, not to avoid the duplicate ID issue.

        Show
        Mircea Toma added a comment - - edited After some digging through the JSF sources I discovered the reason why we were getting the duplicate ID problem. It turns out that UIViewRoot and any other naming container component will use its own counter for assigning IDs to components (when not assigned programmatically or in the jspx template). The counter value is saved in an associated component state helper. So, while UIViewRoot would generate IDs based on its counter saved in its state helper and a prefix (UIViewRoot.UNIQUE_ID_PREFIX) same will do a form in the page. The form will have its own counter, assigning IDs to child components with the same prefix (UIViewRoot.UNIQUE_ID_PREFIX ) and potentially with the same values for the counter that UIViewRoot's counter went through. Right now we are forced to assign IDs to components only when they are appended to a naming container, such as UIForm, and that we already do. Any components added to the tree by using UIViewRoot.addComponentResource method will not need to have an ID assigned because all these components will receive generated IDs based on the UIViewRoot's counter. Some of the components added through UIViewRoot.addComponentResource have their ID assigned because the ID is used by the Javascript code rendered by the component, not to avoid the duplicate ID issue.
        Hide
        Ted Goddard added a comment -

        It should be possible to create a static page for a test case, for instance 10 forms with prependID = false and several children in each form. The automatically assigned IDs of the form children will collied with the UIViewRoot assigned IDs.

        This is a JSF 2.0 bug.

        Show
        Ted Goddard added a comment - It should be possible to create a static page for a test case, for instance 10 forms with prependID = false and several children in each form. The automatically assigned IDs of the form children will collied with the UIViewRoot assigned IDs. This is a JSF 2.0 bug.

          People

          • Assignee:
            Mircea Toma
            Reporter:
            Deryk Sinotte
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: