Why does JSF automatically generate names for html components and can this be overridden

jsf

I'm reading up on JSF. One thing that I noticed is that tags such as h:inputText and h:inputTextarea auto-generate a random name.

Is there any way to over-ride this?

Best Answer

The name and id for the rendered HTML are generated by the UIComponent.getClientId() method, so all you have to do is override that method. However, doing so is not recommended since it risks breaking the contract of the ID (which must be unique even when the same component is rendered multiple times), which would lead to very complex bugs.

Related Topic