• Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between UIComponent getId and getClientId(FacesContext)  RSS feed

 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just wondering what the difference is between the getId() and getClientId(FacesContext) method of the UIComponent?

I guess the getClientId() 'generates an id if one does not exist.' Is that the big diff? Can't we expect every component to already have an id? I'm thinking especially during the validation or conversion phase. If a UIComponent is being validated, it's already been rendered at least once, so it would have to have an id, right?

JSF 1.2 UIComponent JavaDoc

 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, when used in the validation method, if you want the <h:message for="xyz"/> tag to work, you need to use getClientId(xxx)

It seems getId() just generated the name that might be used in the tag, where the getClientId gets the fully qualified name.



text.getClientId --> rpsgameform:gesture
text.getId --> gesture
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kito Mann mentioned that fact in his JSF in Action book.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!