lukas
lukas

Reputation: 545

Doctype in JSF Mojarra

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.

Upvotes: 4

Views: 1539

Answers (2)

lukas
lukas

Reputation: 545

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

Upvotes: 3

robson
robson

Reputation: 1683

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?

Upvotes: 0

Related Questions