aspose file tools*
The moose likes JSF and the fly likes HtmlDataTable and Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "HtmlDataTable and "duplicate ID"" Watch "HtmlDataTable and "duplicate ID"" New topic
Author

HtmlDataTable and "duplicate ID"

Alexander Kolesnikov
author
Ranch Hand

Joined: Feb 26, 2005
Posts: 99
Hello everyone!

I am reading "JSF in Action" by Kito Mann and trying to do this and that along the way. Just tried to create a HtmlDataTable with facets specifying both table and column headers.

First I created just a header and a footer, like this:



Everything worked fine. But then I added column headers, exactly like in the book:



But now I've got an exception:

java.lang.IllegalStateException: Duplicate component ID '_id0:_id3' found in view.

Why is that? I cannot find any difference with the code in the book, and I am using the same RI.
[ January 10, 2006: Message edited by: Alexander Kolesnikov ]

Alexander Kolesnikov<br />Java Web Developer<br />SCJP 1.4, SCWCD 1.4, SCBCD 1.3<br /><a href="http://sundraw.ws" target="_blank" rel="nofollow">Tapestry 5: Building Web Applications</a><br /><a href="http://sundraw.ws/batik.jsp" target="_blank" rel="nofollow">Java Drawing With Apache Batik</a>
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15292
    
    6

Is that all you have on your page? A lot of times, other code can affect the code you've shown, so it's usually a good idea to show us all your code. Also, it's a bit of a pain albeit good practise to give all your components the id attribute. That way, when you have an error like this, you know exactly which component is having an issue:

Duplicate component ID 'myForm:matchesHeader' found in view.

instead of

Duplicate component ID '_id0:_id3' found in view.


GenRocket - Experts at Building Test Data
Alexander Kolesnikov
author
Ranch Hand

Joined: Feb 26, 2005
Posts: 99
Thanks, Gregg!

Well, there is not much more in this simple "application". Here is the whole page:



And there is also a managed bean to imitate data as if coming from a database:


ackage jsfdating;

import java.util.ArrayList;
import java.util.List;

import com.astro.dating.MatchRecord;

public class RecordsSource {

List records = new ArrayList();

public RecordsSource() {
super();
for (int i = 0; i < 10; i++) {
MatchRecord rec = new MatchRecord();
rec.setSuid("test" + i);
rec.setUser(i);
rec.setMatch(90 - i * 2);
rec.setViewed(i % 2 == 0? true:false);
rec.setInfo(i % 2 == 0? false:true);
records.add(rec);
}
}

public List getRecords() {
return records;
}

public void setRecords(List records) {
this.records = records;
}
}


which is then configured like this:



I know, this doesn't look like having plenty of sense, but the purpose is to reproduce a piece of front end of my existing Tapestry application and see how JSF differs from Tapestry. Earlier I did the same with Struts.

Okay, so now I will go and try to add IDs...
[ January 11, 2006: Message edited by: Alexander Kolesnikov ]
Alexander Kolesnikov
author
Ranch Hand

Joined: Feb 26, 2005
Posts: 99
Thanks again, Gregg!

I have added IDs to all the components and it works properly now.
Alexander Kolesnikov
author
Ranch Hand

Joined: Feb 26, 2005
Posts: 99
Bummer!

Now I am trying to use a HtmlCommandLink, like this:



But there is always an exception, and the least descriptive of all:

javax.faces.FacesException: Assertion Failed

What the hell this could be!?
Alexander Kolesnikov
author
Ranch Hand

Joined: Feb 26, 2005
Posts: 99
I solved this problem. Perhaps I wasn't attentive enough while reading my book, or maybe it just doesn't mention this. So the old "trial and error" method helped.

The solution is that HtmlCommandLink must be inside of HtmlForm. While HtmlCommandButton doesn't need to. JSF is full of inconsistencies...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HtmlDataTable and "duplicate ID"
 
Similar Threads
Datascroller for a datatable | need help
getting problem while using �x:dataTable� and �x:updateActionListener�
Problem with h:selectManyCheckbox
Formatting problem.
Please HELP me. How To Hard Code Values in Each Row of a dataTable?