7

I have a JSF input text component which has an id of search. In the generated HTML output it looks like this j_idt17:search, but the number 17 is changing from time to time. How to make it to stay one?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Pavel
  • 1,278
  • 2
  • 17
  • 34

1 Answers1

12

Give the JSF component which generated the HTML element with id="j_idt17" a fixed ID. In this particular case, it's likely the HTML input element's parent <form> element which is generated by the JSF <h:form> component.

So, this should do:

<h:form id="form">

This way the ID of the generated HTML <input> element will become form:search.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555