5 Replies Latest reply on Nov 8, 2010 10:59 PM by kragoth

    s:fragment and ui:include says duplicate ids!!!

    deanhiller2000

      so I have two fragments that include the same player.xhtml which has controls on a page and integrates soundmanager 2 component into player.xhtml.  the issue is these fragments are meant so the javascript works when it uses the ids to reference the components BUT for some reason, even though the fragment's rendered clause is the exact opposite(same but with not in front), it parses player.xhtml for both and claims I have a duplicate id when I definitely don't.


      Is this supposed to happen(parsing of player.xhtml twice)?  I thought s:fragment would not process children if rendered was false but it seems it is doing the opposite?


      thanks,
      Dean

        • 1. Re: s:fragment and ui:include says duplicate ids!!!
          kragoth

          It's got nothing to do with parsing the xhtml twice.


          The xhtml is used to build a component tree. Just because a component doesn't get rendered doesn't mean that it isn't put into the component tree. The rendered flag is then used to determine if html should be generated for said component.


          Put these components into their own naming containers(ie, a table) and then they wont end up with the same ids.

          • 2. Re: s:fragment and ui:include says duplicate ids!!!
            deanhiller2000

            I was trying to avoid that as we have alot of javascript to wire in the soundmanager 2 component and only one of the ui include is ever rendered and I didn't want to change all the javascript to have to refer to two different ids.  I temporarily hacked it to use jquery to find by class now and got rid of all the ids in there for now.  It is quite annoying that I can't write the javascript to use it by ids in that case.

            • 3. Re: s:fragment and ui:include says duplicate ids!!!
              kragoth

              Putting them inside naming containers wouldn't change your ability to reference them by id's. :)


              Instead of matching them by exact ID use an endsWith match (seeings you are using jquery) and then it doesn't matter what their naming containers are called. (I use this matching strategy in my app for the same reason).

              • 4. Re: s:fragment and ui:include says duplicate ids!!!
                deanhiller2000

                The ids would be different then, wouldnt' they as the naming is parent:child for the ids so I would end up with parent1:child in one case and parent2:child in the other case and my javascript would stop working, right?

                • 5. Re: s:fragment and ui:include says duplicate ids!!!
                  kragoth

                  Instead of matching them by exact ID use an endsWith match (seeings you are using jquery) and then it doesn't matter what their naming containers are called. (I use this matching strategy in my app for the same reason).



                  Instead of matching them by exact ID use an endsWith match



                  use an endsWith match


                  You have jQuery, use it to help you not care about the fact that the ids are different.