Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Setting the cliendID of an h:inputText

 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I would like for my rendered <input> tag to have the "name" attribute explicitly set to some value for example: "email" without any colon of course.
I understand the clientID is rendered as the "name" attribute. My question is then: how do I set the clientID of my inputText (preferably from the facelets code)?
Thanks in advance for your help,
Julien.
 
Victor Hugo M Machado
Greenhorn
Posts: 22
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe I misunderstood what you said but let it ..

the colon are caused because you have separeted the formID from the componentID.

for me.. it ´s possible only if you decompile jsf and change naming components..
 
Cesar Loachamin
Ranch Hand
Posts: 90
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Julien

The name of the component is composed for the form_name:component_name, if for some reason this does not work for you, you can remove the form name and the colon setting the prependId attribute of the form to false like this:

Regards

Cesar
 
Victor Hugo M Machado
Greenhorn
Posts: 22
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
really good.. one more lesson
 
Tim Holloway
Saloon Keeper
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The internal name (seen by JavaScript) of a JSF component ID is always going to contain those colons and higher-level qualifiers.

That's because certain JSF components act as naming containers which simply means that IDs within the naming container - for example, the form - must be unique, but the ID itself does not need to be unique globally in the view. JSF knows how to find the appropriate component using a simple ID, but JavaScript (client-side code) doesn't, which is why JavaScript must reference the fully-qualified ID, which includes the IDs of its surrounding naming container(s).
 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for your replies.
Julien.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic