• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use forceId attribute in Tomahawk.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Saloon Keeper
Posts: 28401
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Blueberry pie is best when it is firm and you can hold in your hand. Smell it. And smell this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic