JSF生成的HTML元素ID正在更改,如何将其设置为固定元素ID? [英] JSF-generated HTML element ID is changing, how to set it to a fixed element ID?

查看:200
本文介绍了JSF生成的HTML元素ID正在更改,如何将其设置为固定元素ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ID为search的JSF输入文本组件.在生成的HTML输出中,它看起来像j_idt17:search,但是数字17时常在变化.如何使其保持一体?

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?

推荐答案

给出JSF组件,该组件生成具有id="j_idt17"固定ID的HTML元素.在这种情况下,很可能是HTML输入元素的父元素<form>由JSF <h:form>组件生成.

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.

所以,这应该做:

<h:form id="form">

这样,生成的HTML <input>元素的ID将变为form:search.

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

这篇关于JSF生成的HTML元素ID正在更改,如何将其设置为固定元素ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆