javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2453

Doctype not rendered in the generated HTML if doctype was defined in an included file

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.8, 2.1.9, 2.1.10
    • Fix Version/s: 2.1.14, 2.2.0-m06
    • Component/s: view handling
    • Labels:
      None

      Description

      When testing our application running on Mojarra 2.1.10 I found out that the generated HTML does not contain the doctype, even though it is present in the template. Missing doctype of course means quirk mode in browsers causing layout issues. The problematic page does not use the template directly, but instead it includes another page that then uses the template.

      I tried the application with multiple Mojarra versions:
      2.0.6 - no problem, doctype rendered
      2.1.7 - no problem, doctype rendered
      2.1.8 - doctype missing, root html tag missing
      2.1.10 - doctype missing, html tag present

      The problematic page (home.xhtml) contains just one ui:include tag that includes another page (todos.xhtml) which uses a template (through ui:composition) to include the main layout stuff (including the doctype). If I visit home.jsf as the first JSF page after the server starts, none of the pages using the same template will contain the doctype. But if I visit todos.jsf first, the doctype will be present also when I open home.jsf subsequently.

      I had a look in com.sun.faces.facelets.compiler.SAXCompiler (startDTD() within CompilationHandler) and it seems that this behaviour is present since JAVASERVERFACES-2328 was fixed. Obviously the decision whether the doctype will be rendered or not is decided when the template facelet is compiled, depending on whether this facelet is used within an ui:include tag or not. In our case however the template is used both from within a ui:include tag (the home.jsf case) and directly (todos.jsf) and the doctype presence depends on which page is accessed first.

        Issue Links

          Activity

          Hide
          Ed Burns added a comment -

          All required jobs passed.

          Show
          Ed Burns added a comment - All required jobs passed.
          Hide
          Toskan added a comment -

          Please reopen this issue for mojarra 2.1.16 - I was using it (2.1.16) and wondered why everything is quirks mode. I downgraded to 2.1.14 - now I get the doctype again. Version 2.1.15 is working as well, 16 is broken.
          Maybe it could be considered removing 16 from the stable download links, quirks-mode basically breaks a lot of things and thus shouldn't be considered stable. I spent already time developing stuff for v16.

          I had btw a different setup, I think the bug is the same though, if you need feedback, ill be glad to help.

          Show
          Toskan added a comment - Please reopen this issue for mojarra 2.1.16 - I was using it (2.1.16) and wondered why everything is quirks mode. I downgraded to 2.1.14 - now I get the doctype again. Version 2.1.15 is working as well, 16 is broken. Maybe it could be considered removing 16 from the stable download links, quirks-mode basically breaks a lot of things and thus shouldn't be considered stable. I spent already time developing stuff for v16. I had btw a different setup, I think the bug is the same though, if you need feedback, ill be glad to help.
          Hide
          Toskan added a comment -

          It seems odd, I have sometimes the doctype and sometimes not with 2.1.15, I'll keep you guys up to date (but I have to leave now). I wish I could edit my comment

          Show
          Toskan added a comment - It seems odd, I have sometimes the doctype and sometimes not with 2.1.15, I'll keep you guys up to date (but I have to leave now). I wish I could edit my comment
          Hide
          kennardconsulting added a comment -

          Toskan,

          I think you'll need to provide an example of your particular approach.

          I was involved with this issue, but can confirm the fix introduced in 2.1.14 is still working in 2.1.16. So all fine here

          Regards,

          Richard.

          Show
          kennardconsulting added a comment - Toskan, I think you'll need to provide an example of your particular approach. I was involved with this issue, but can confirm the fix introduced in 2.1.14 is still working in 2.1.16. So all fine here Regards, Richard.
          Hide
          ysbelman added a comment -

          I was getting the same problem (90%) of the times. There are ways to make it go away, however. I'll explain.

          My particular case was when command link was triggering a page to open in a new browser tab:
          <h:commandLink id="myLink" action="#

          {controller.action}

          " value="my link" target="_blank" />

          The resultant page would almost always show up with a missing <DOCTYPE>. I say almost because if I hit the page directly via browser URL (typing it in), and then again by navigating to the same view from the link above, THEN it works. It works a few times afterwards too, with DOCTYPE before reverting back to no DOCTYPE.

          So I tried <h:doctype> tag as someone had mentioned here and it worked very well. Thanks kennardconsulting !!

          My document structure is:
          <html>
          <h:doctype public="-//W3C//DTD XHTML 1.0 Transitional//EN" rootElement="html" system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
          <head></head><body></body>
          </html>

          Show
          ysbelman added a comment - I was getting the same problem (90%) of the times. There are ways to make it go away, however. I'll explain. My particular case was when command link was triggering a page to open in a new browser tab: <h:commandLink id="myLink" action="# {controller.action} " value="my link" target="_blank" /> The resultant page would almost always show up with a missing <DOCTYPE>. I say almost because if I hit the page directly via browser URL (typing it in), and then again by navigating to the same view from the link above, THEN it works. It works a few times afterwards too, with DOCTYPE before reverting back to no DOCTYPE. So I tried <h:doctype> tag as someone had mentioned here and it worked very well. Thanks kennardconsulting !! My document structure is: <html> <h:doctype public="-//W3C//DTD XHTML 1.0 Transitional//EN" rootElement="html" system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/> <head></head><body></body> </html>

            People

            • Assignee:
              Ed Burns
              Reporter:
              mhi
            • Votes:
              14 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 25 minutes
                3h 25m