• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

HtmlDataTable and "duplicate ID"

 
author
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Alexander Kolesnikov
author
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks again, Gregg!

I have added IDs to all the components and it works properly now.
 
Alexander Kolesnikov
author
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Your mother is a hamster and your father smells of tiny ads!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic