webtier@glassfish.java.net

JSF page fragments, tabs, and duplicate id errors

From: <webtier_at_javadesktop.org>
Date: Thu, 21 May 2009 12:55:02 PDT

I'm new to JSF. I've just started working on a JSF webapp with lots of page fragements (.jspf). Almost all of our jsp files are .jspf and are added to tabs with something like this:
[pre]

  <rich:tab binding="#{ui$shared$allTabs.tabFoo}" id="tabFoo" label="Foo" rendered="false">
    <other stuff with hardcoded coded component ids/>
    <c:import url="./bar/foo.jspf" />
   </rich:tab>
[/pre]

This has worked pretty well, but now we've run into a problem. We want multiple tabs to use the same page fragment JSP to provide the same view to a different collection of data. When I do this, I get duplicate component id errors. I assume this is because some of the component IDs are specified in the page fragment JSPs.

I'm not sure how to tackle this problem. I've done some googling and brainstorming and haven't made much progress. I was thinking of doing this but it seems kind of crazy: When a new HtmlTab is needed, programatically create it. Then grab all the child components off another HtmlTab and clone them and set unique IDs in the clones, and then add them programatically to the new HtmlTab. This seems like a lot of work, and probably would run it to problems.

Is there a better way to do it? Should we do a major refactoring and get rid of the page fragment architecture in tabs to accomplish this? Any examples on the web of providing the same view on multiple tabs to a different set of data on each tab?
[Message sent by forum member 'medloh' (medloh)]

http://forums.java.net/jive/thread.jspa?messageID=347220