• Post Reply Bookmark Topic Watch Topic
  • New Topic

Non-unique IDs generated by MyFaces Tomahawk t:columns tag  RSS feed

 
Wally Hartshorn
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given this MyFaces Tomahawk 1.1.3 JSP code:


In the generated HTML, I get input fields with IDs like "valuesField[0]", "valuesField[1]", "valuesField[2]", etc. That works fine.

However, if instead of using <t:column> I am using <t:columns> (plural), I run into a problem.



Now in the first row I get input fields with IDs like "valuesField[0]", "valuesField[1]", "valuesField[2]", etc. In the second row I also get input fields with IDs like "valuesField[0]", "valuesField[1]", "valuesField[2]", etc. And in the third row I also get input fields with IDs like "valuesField[0]", "valuesField[1]", "valuesField[2]", etc. In sure, the field IDs are no longer unique, which makes it difficult to reference them using CSS and JavaScript.

Is there a way around this problem?
 
Eugene Abarquez
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use forceId attribute in Tomahawk.
 
Thorsten Duhn
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

per definition a id "must be unique in a document".
http://www.w3.org/TR/REC-html40/struct/global.html#h-7.5.2

So forceId used in lists, table rows or columns will make the resulting html invalid. That is your experience. (The added numeration is new to me, but I never even tried such.) Nevertheless you should avoid forceId.

For CSS you should use style classes instead. I have no good idea for your JavaScript purpose, but you will not be able to reference a specific element if its id is not unique, you will get non deterministic results (I guess in most cases reference the first element with this id, but this may differ between browsers).

As I see it the behaviour you described is some kind of bug, with forceId set to true I would expect an unaltered id (docs say "If true, this component will force the use of the specified id when rendering"), this numeration added makes any CSS or JS reference also hard. I believe you never should rely on the ids rendered into html when it is altered by the framework, because this may change in future releases. But when it ends in non-unique ids this is really a bug.

But I also cannot guess a solution forcing to keep the unaltered id and also use this within iterations, which must produce invalid html.

Regards,
Thorsten
[ August 26, 2006: Message edited by: Thorsten Duhn ]
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe this is a known bug: http://mail-archives.apache.org/mod_mbox/myfaces-dev/200606.mbox/%3C33226819.1150220789852.JavaMail.jira@brutus%3E
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!