0

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?

2
  • What exactly would be your goal in overriding those names? Presumably they work just fine for having JSF map the form data to its components. Aug 29, 2012 at 10:13
  • @Michael Borgwardt That is true. This is more of an academic question actually as I've not done JSF programming at all. I am merely interested in knowing whether there is any way to override the basic behaviour. Aug 29, 2012 at 10:25

1 Answer 1

4

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.

1
  • Thank you for the answer. The id appears to be a standard attribute (in h:inputText for example). However, name is not similarly available. I was just wondering why this decision was made. Aug 29, 2012 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.