JSF-generated HTML element ID is changing, how to set it to a fixed element ID?

烂漫一生 提交于 2020-01-29 07:14:24

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/19101461/jsf-generated-html-element-id-is-changing-how-to-set-it-to-a-fixed-element-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!