Edward Burns's Weblog

Edward Burns's Weblog

All | General | Java | Music

20041214 Tuesday December 14, 2004

The basics of rendering XHTML with JavaServer Faces (Brief)

graham_s wrote in the JSF Forum: "Is there any way to make jsf render as valid xhtml?" I thought it best to answer graham_s's question in a blog entry, since this topic comes up frequently.

Short answer: everything rendered by the Faces standard renderkit conforms to the following XHTML practices:

  • XHTML elements must be properly nested

  • XHTML documents must be well-formed

  • Tag names must be in lowercase

  • All XHTML elements must be closed

  • Attribute names must be in lower case

  • Attribute values must be quoted

  • Attribute minimization is forbidden

  • The id attribute replaces the name attribute.

    Faces does both for input commands.

  • The lang attribute

    Actually, we don't handle this one properly, but I've filed an issue and I'm waiting for approval on the change-bundle.

    Now we generate both lang and xml:lang, as required by the XHTML 1.0 spec, section C.7.

Now, to go the last mile, you have to make some changes to your pages on your own, since they're outside the scope of Faces. These changes are detailed in the excellent, brief, XHTML Tutorial at w3schools.com.

  • All XHTML documents must have a DOCTYPE declaration. The html, head and body elements must be present, and the title must be present inside the head element.

  • You must also specify the XHTML namespace in the html element.

If these changes are not sufficient to make your Faces application XHTML compliant, please post to the forum and we'll file a bug! I'm not allowing a talkback because I want to keep the discussion in the forum.

(2004-12-14 08:58:35.0) Permalink Comments [2]

Calendar

December 2004 »
SunMonTueWedThuFriSat
   
1
2
3
4
5
6
7
8
9
10
11
12
13
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
       
Today

RSS Feeds

XML
All
/General
/Java
/Music

Search

Links


Navigation



Referers

Today's Page Hits: 24