In an exercise to maximize performance of an Xpages application we decided to remove as much as redundant ID’s of controls as possible, as described in this best practice.
In summary the ID of an control gets rendered in a much longer ID when the HTML page is rendered. A simple label with ID ‘label1’ could become ‘view:_id1:_id2:_id11:label1’ and if you put that label in a repeat control the generated ID could become even much longer.
A downsize of removing the ID I found out that some properties like tagName for example does not get applied anymore. Of course you can replace the tag around the control, but I found that out afterwards.
Nevertheless a good best practice removing ID’s but do it with caution. Read the comments in the post to update yourself on the subject.
… always works for me – no id attribute required.
I have found that the tagName stops working for xp:text controls without an id attribute (which I suspect is the scenario you ran into), but since xp:text controls can’t have child node(s), I tend to not use them in favor of something like this:
This will result in the following, ultra-clean markup:
— as the xp:text won’t render an output tag (let alone a styleClass) if you due to the disableTheme attribute.
Great tip Patrick. Thanks.