Search code examples
jsfwhitespacefaceletsdoctypemyfaces

When using MyFaces 2.1, with Eclipse Juno, how do I get rid of a space after the doctype


I have searched all around for an answer, and tried many things, but no luck. When I use MyFaces 2.1 with Eclipse Juno, and attempt to create an HTML5 page, I get

<!DOCTYTPE html >

Notice the space after the "html". When this page is viewed in FireFox, using HTML Tidy, it throws an error saying its an invalid doctype.

The source xhtml file contains with no space. Does anyone have a solution?

Thanks

Dan


Solution

  • I can reproduce it in at least MyFaces 2.1.9 and 2.1.10 (didn't tried older versions). This problem doesn't manifest in Mojarra. It's undoubtedly a bug in MyFaces. I recommend to report it to MyFaces guys.

    For the meantime until they get it fixed, I found a workaround. Replace <!DOCTYPE>

    <!DOCTYPE html>
    <html lang="en"
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://java.sun.com/jsf/facelets"
    >
        ...
    </html>
    

    by <h:doctype>

    <ui:composition 
        xmlns="http://www.w3.org/1999/xhtml"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://java.sun.com/jsf/facelets"
    >
        <h:doctype rootElement="html" />
        <html lang="en">
            ...
        </html>
    </ui:composition>
    

    Its renderer generates the proper space-less doctype.

    This problem is in no way related to Eclipse. It's just a tool like Notepad.