Skip to main content

JSF page fragments, tabs, and duplicate id errors

1 reply [Last post]
medloh
Offline
Joined: 2009-05-21
Points: 0

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]

[/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 trying 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 was edited by: medloh

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jim Driscoll

Well, without really knowing everything in your app, I can zero in on a
couple of things here, and give a recommendation:

On 5/21/09 12:55 PM, webtier@javadesktop.org wrote:
> 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.

So, the problem is that you've named a bunch of things id="foo".

There are two ways to fix this without too much work. One is to remove
the id="foo" - it's quite possible that you don't need it... the other
way is to wrap that tag in another naming container that is lacking an
id. So, for instance, form. Either way, the component will still have
an id, it'll just be an automatically generated one.

Jim

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net