JSF - TreeNode.setID gets IllegalArgument Exception

By: Kadhar Viewed: 153171 times    

When you set the id for a TreeNode are you getting an illegal Argument exception.

For example:

String id = "0C00EC8C-E1";
TreeNode node = new TreeNode;
node.setId(id); //

This code may throw an IllegalArgument exception. To solve this problem you need to u need to adhere to the contract of UIComponent.setId():

  • Must not be a zero-length String.
  • First character must be a letter or an underscore ('_').
  • Subsequent characters must be a letter, a digit, an underscore ('_'), or a dash ('-').
  • Component identifiers must also obey the following semantic restrictions (note that this restriction is NOT enforced by the setId() implementation):
  • The specified identifier must be unique among all the components (including facets) that are descendents of the nearest ancestor UIComponent that is a NamingContainer, or within the scope of the entire component tree if there is no such ancestor that is a NamingContainer.

This should solve your problem.

Most Viewed Articles (in JSF )

Latest Articles (in JSF)

Comment on this tutorial