4

What Doctype should I use in JSF pages? The other day I'm trying to migrate from Mojarra 2.1.13 to 2.1.18 and it seems that the way the doc types are interpreted changed. In the root template I have following DOC TYPE

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Do I also have to include this?

<?xml version="1.0"?>

In composites (that use this template) I used to have following doctype

 <!DOCTYPE composite PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

But it seems that Mojarra 2.1.18 doesn't really support that. Also I didn't find this in any JSF 2.0 reference, this we used to use in JSF 1.2. If I have this doctype in composite page, it will render composite doctype instead of html that is in the template. In the result, the css styles are messed up.

So what's the correct usage of doctypes in JSF 2.0. Or is this issues with Mojarra? I didn't find any reference regarding this.

lukas
  • 545
  • 2
  • 7
  • 18
  • 1
    The doctype parsing broke in Mojarra 2.1.14, but should be fixed in 2.1.17. It should use the doctype of the master template and ignore any doctypes outside ``. Are you really using 2.1.18? What version is been logged during startup? Did you try the current 2.1.20? – BalusC Apr 02 '13 at 17:18
  • It prints out this one: Initializing Mojarra 2.1.18-jbossorg-1 20130205-1414 for context ''. I use JBoss EAP 6.1 Alpha1. I don't know how to upgrade Mojarra version for JBoss server. They use their own built – lukas Apr 02 '13 at 17:19
  • Oh, the JBoss-provided one? How exactly did you upgrade? Did you also take API into account instead of only impl? – BalusC Apr 02 '13 at 17:21
  • I'm using the default Mojarra provided by JBoss EAP 6.1. Alpha1. There is Mojarra 2.1.18. – lukas Apr 02 '13 at 17:23
  • Uh, thus you actually migrated to a newer JBoss version? – BalusC Apr 02 '13 at 17:23
  • In any case, try supplying your own up to date Mojarra libs. You can tell JBoss about that using a context param: http://stackoverflow.com/questions/11908720/how-to-configure-a-war-in-order-to-depends-on-the-exported-libraries-in-the-war/11911413#11911413 – BalusC Apr 02 '13 at 17:29
  • Yes, that's right. I'm trying to but I'm dealing with stability of JSF. It's actually even worse. From time to time the JSF throws Duplicate ID error such as java.lang.IllegalStateException: Component ID j_idt1 has already been found in the view. It generates duplicate id for f:viewParam and s:viewAction components – lukas Apr 02 '13 at 17:29
  • well, so i updated to mojarra 2.1.19 and no help – lukas Apr 02 '13 at 22:52
  • I created JIRA issue here: http://java.net/jira/browse/JAVASERVERFACES-2820 – lukas Apr 02 '13 at 23:13

2 Answers2

3

I created a JIRA issue for this: http://java.net/jira/browse/JAVASERVERFACES-2820

and it has been closed as this is the expected behavior.

"The composite page is where you actually use the template. So it is the outer most file where you specified a doc type. As such it defines the doc type that will be rendered."

Just specify the doctype in a template and nowhere else

lukas
  • 545
  • 2
  • 7
  • 18
  • In my case - if the doctype is in the template only, nowhere else - I have "composite" type in the view, even if there is html specified in the template :-( – robson Apr 19 '13 at 17:35
  • what mojarra version do you use? – lukas Apr 19 '13 at 19:12
  • If i don't include any doctype anywhere, it is rendered by default. If I put the doctype only into the template, that one will be rendered. If I put the doctype into composite view, that one will be rendered (and it also overrides the doctype in a template). I'm using Mojarra 2.1.19 – lukas Apr 19 '13 at 19:15
  • I use mojarra 2.1.18 and I have such behaviour: if I put the doctype into composite view - I'll have it on rendered page. If I don't put the doctype into composite view - I'll have doctype composite on rendered page - even if template of this page has doctype html. Looks like the composite doctype is default - and mojarra takes only composite view into account. Maybe 2.1.19 has it fixed? – robson Apr 19 '13 at 22:25
0

I also migrated Jboss 7.1 to JBoss EAP 6.1

I found not very nice workaround - to insert on each page (not template):

<!DOCTYPE html>

e. g.:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html" template="template.xhtml"> 

Is there any other way - for doctype to be read from master template?

robson
  • 1,623
  • 8
  • 28
  • 43