Erro aplicação JSF 2 com PrimeFaces ocorrendo quando abre no navegador Chrome

5 respostas
Roger75

Quando abro um sistema feito com JSF2 com componentes do Primefaces, instalado no Glassfish 3, pelo navegador Google Chrome, ocorre a seguinte mensagem de erro:

This page contains the following errors:
error on line 46 at column 228: XML declaration allowed only at the start of the document
Below is a rendering of the page up to the first error.

No IE e no Firefox não aparece esse erro… que será?

5 Respostas

E

Veja se o início do seu arquivo está semelhante a isso:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
Roger75

O erro ocorre quando entro numa página principal que tem outras páginas dentro dela, inseridas por <ui:include> (que está dentro de um <p:tab>)

Em cada página está declarado o html assim:

&lt;html 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" xmlns:p="http://primefaces.prime.com.tr/ui"&gt;

Será que tem que declarar esses xmlns só na página principal?

E

Acredito que não influencia. Eu tenho isso funcionando no chrome.

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 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">

    <ui:include src="../../includes/head.xhtml"/>

E o início do meu head:

<?xml version='1.0' encoding='UTF-8' ?>

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

Olá!

Consegui solucionar colocando a tag <f:view contentType=“text/html”> imediatamente dentro do body.

Ficou assim:

<h:body> <f:view contentType="text/html"> ... </f:view> </h:body>

Att.

barbon

Segue link com post detalhando solução:

http://www.patternizando.com.br/2011/03/google-chrome-xml-declaration-allowed-only-at-the-start-of-the-document-usando-jsf/

Criado 7 de fevereiro de 2011
Ultima resposta 24 de mar. de 2011
Respostas 5
Participantes 4