f you care to see the HTML source from your browser, you will find out that the id of your input field is <form-id>+":"+<input-field-id>, in your case, j_idt7:UserId:. Try to give your<h:form> some meaningful id in order to make some sense out of it. You can read about JSF IDs here. In case you don't like it, you can turn it off by modifying your form tag to something like this,
<h:form prependId = false> // its true by default.
But that might turn out to be problematic, as pointed out by BalusC here.
Furthermore, it seems like you have never configured any validation messages yourself. Which in turn ends up with this message. Hence, a message.properties file is needed to have a control over message and show something more appropriate. Even then the field name should not be the part of the message, to make those validation message generic to avoid repetition. See BalusC's answer regarding the use of label attribute inside the <h:inputText>.
理解JSF中表单ID前缀问题及解决方法
本文深入探讨了JSF中表单ID前缀的原理及其可能带来的问题,提供了如何给表单赋予有意义ID的建议,并讨论了禁用此功能的后果。同时强调了自定义验证消息的重要性,以及正确设置字段名以避免重复验证信息的方法。
224

被折叠的 条评论
为什么被折叠?



