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?
-
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– Michael Borgwardt2012年08月29日 10:13:48 +00:00Commented 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.Chetter Hummin– Chetter Hummin2012年08月29日 10:25:07 +00:00Commented Aug 29, 2012 at 10:25
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.
-
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– Chetter Hummin2012年08月29日 11:32:13 +00:00Commented Aug 29, 2012 at 11:32