UIForm with prependId=“false” breaks

后端 未结 1 715
抹茶落季
抹茶落季 2020-11-22 02:00

I have a question about the idea behind the fact, that only UIForm got the attribute prependId. Why is the attribute not specified in the Nam

相关标签:
1条回答
  • 2020-11-22 02:39

    Indeed, UIComponent#findComponent() as done by <f:ajax render> fails when using <h:form prependId="false">. This problem is known and is a "Won't fix": JSF spec issue 573.

    In my humble opinion, they should never have added the prependId attribute to the UIForm during the JSF 1.2 ages. It was merely done to keep j_security_check users happy who would like to use a JSF form with JSF input components for that (j_security_check requires exact input field names j_username and j_password which couldn't be modified by configuration). But they didn't exactly realize that during JSF 1.2 another improvement was introduced which enables you to just keep using <form> for that instead of sticking to <h:form>. And then CSS/jQuery purists start abusing prependId="false" to avoid escaping the separator character : in their poorly chosen CSS selectors.

    Just don't use prependId="false", ever.

    For j_security_check, just use <form> or the new Servlet 3.0 HttpServletRequest#login(). See also Performing user authentication in Java EE / JSF using j_security_check.

    For CSS selectors, in case you absolutely need an ID selector (and thus not a more reusable class selector), simply wrap the component of interest in a plain HTML <div> or <span>.

    See also:

    • How to select JSF components using jQuery?
    • How to use JSF generated HTML element ID with colon ":" in CSS selectors?
    • By default, JSF generates unusable ids, which are incompatible with css part of web standards
    0 讨论(0)
提交回复
热议问题