开发者

Java Server Faces JSF - who is responsible for auto generated id's?

开发者 https://www.devze.com 2023-02-02 19:10 出处:网络
when the Faces Servlet compiles a jsp to the servlet in the work directory, it generates id\'s, like j_id_jsp_1024919151_1...

when the Faces Servlet compiles a jsp to the servlet in the work directory, it generates id's, like j_id_jsp_1024919151_1...

When is the id changing? I tried it on the same machine, cleaning work dire开发者_运维百科ctory, still the same. I started another Apache Tomcat on the same machine and I got new id's...

Thanx Stefan


The id of a component is generated by the implementation if it is not set.

The id attribute value emitted to the page is the client identifier. This is constructed using the rules defined in the link and will include parent NamingContainer ids and possibly the view namespace.

You can read more about working with JSF client identifiers here.


JSF automatically generate ids for the component during the lifecycle when you don't specify any. If you don't want this feature then set the id for all the components individually and set the id for <h:form> also to avoid this.

Also setting the id by yourself will help you more in Javascript based validation where the values of the fields are derived using ids


ID generation would be implementation dependent. By this, I mean any JSF implementation you use will have a mechanism for generating IDs based on variables that are "good enough" for unique identification. Possibly: class name, html element name, etc....

You might want to check reference implementation's source code.

0

精彩评论

暂无评论...
验证码 换一张
取 消