Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm reading up on JSF. One thing that I noticed that tags such as h:inputText and h:inputTextarea auto-generate a random name. Is there any way to over-ride this?

share|improve this question
    
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. –  Michael Borgwardt Aug 29 '12 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. –  Chetter Hummin Aug 29 '12 at 10:25
add comment

1 Answer 1

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.

share|improve this answer
    
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. –  Chetter Hummin Aug 29 '12 at 11:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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