HoleInVoid
HoleInVoid

Reputation: 49

Is Id required attribute for JSF 2 tags?

Is id required for all JSF 2 tags, for example:

<h:outputLabel value=" Variable label:" />
<h:outputText value="#{bean.varialbe}" />

Which renders to: Variable label: Variable

As such it does renders as expected, but can I run into trouble leaving the ID attribute out? Should I do

<h:outputLabel id ="myId" value=" Variable label:" />
<h:outputText id ="myVariableId" value="#{bean.varialbe}" />

Upvotes: 0

Views: 231

Answers (1)

McDowell
McDowell

Reputation: 108909

The id attribute is optional, at least in the core controls. You might wish to use it if you were using (for example) the outputLabel's for attribute or referring to the resultant DOM elements using client identifiers in JavaScript.

Upvotes: 4

Related Questions