Improving JSF by Dumping JSP
Subject:   ... and CSS
Date:   2004-06-10 05:27:30
From:   erikhatcher
Response to: Fantastic!

...not just JavaScript, but CSS also, when it comes to the importance of controlling the 'id' attribute.
Full Threads Oldest First

Showing messages 1 through 4 of 4.

  • ... and CSS
    2004-06-10 10:06:35  Hans Bergsten | O'Reilly Author [View]

    I'm sure this is a hot potato, but the HTML elements the JSF components render already sets the "id" attribute, so this issue isn't specific to the custom ViewHandler described in the article.

    For CSS, I believe the "class" attribute is more commonly used than the "id" attribute, so I don't see that as a big deal (but I may be wrong).

    For JavaScript, I admit it's a problem that needs to be dealt with in upcoming versions of the JSF spec. With JSF 1.0, there are methods that should be called to get the "id" attribute value from code that generates JavaScript dynamically (such as a Renderer), but this could be automated a lot more. For JavaScript entered as static text in the template, you currently need to understand the rules for how the specified "id" attribute can be adjusted by JSF and apply the same rules manually to the JavaScript code (which isn't totally fail-safe, but works pretty well for HTML at least).
    • ... and CSS
      2004-06-10 13:32:50  denka [View]

      use of "class" attribute is discouraged by W3C, so it's a big deal. Workaround can be thought of: id="checkbox myComponentId" might work as well
      • ... and CSS
        2004-06-14 15:06:52  jt2190 [View]

        I did a double take when I read the post above, so just to clarify, this is what the W3C said about using class and ids:

        By using the ID attribute as selector, one can set style properties on a per-element basis. While style sheets have been designed to augment document structure, this feature will allow authors to create documents that present well on the canvas without taking advantage of the structural elements of HTML. This use of style sheets is discouraged.

        Original here: .