XML或文本声明不在实体的开头

Chr*_*ris 4 xml jsf facelets jsf-2

抱歉有点愚蠢.但我明白(我缺乏知识)如果你想在那个页面上使用RichFaces组件,就不可能转发到另一个页面.

这是我转发到具有RichFaces组件的页面时遇到的一些问题

  • 如果我转发到带有表单的页面,则会有数百个包含的JavaScrip被解释为格式错误的XML标记.
  • 如果我使用嵌套表,表将松散CSS文件,看起来像普通的JSF 2.0 dataTables.
  • 当转发到只有tabPanel的页面时,如演示TabPanel - Show Case一样,选项卡面板变得混乱并变得不可用(参见图像beelow).

我不需要转发到具有RichFaces组件的页面,但是拥有该选项会很好.可能我误解了如何使用RichFaces的关键.

仅为了您的信息,我在NetBeans 7.0.1中创建了一个全新的Web项目并制作了两个页面.通过a4j:commandLink我从第一页转发到第二页有一个选项卡面板.渲染变得混乱,面板变得无法使用.除了包含RichFaces所需的库和标签之外,新项目完全没有web.xml和rich-faces.xml中的setup参数.

当我转发到具有RichFaces组件的页面时,我错过了什么?

PS.如果有一个模式可以遵循,这将有助于如何使页面转发与RichFaces一起工作.

问候克里斯.

这是firebug报告的错误(在调用转发之后)

XML or text declaration not at start of entity
http://localhost:8080/humis/faces/app_user/projectHome.xhtml
Line 7
Run Code Online (Sandbox Code Playgroud)

Firebug报告页面的这些状态

  • 200好的
  • 304未修改

它是标题中的内容,包括20-30个脚本.不知道如何在这里包含长html列表.它自己接受的请求没问题,但RichFaces生成了一些我可以控制进行页面转发的东西.

masterLayout文件;

<h:head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <h:outputStylesheet name="css/default.css"/>
    <h:outputStylesheet name="css/cssLayout.css"/>

    <title>
        <h:outputText value="Partner Tapestry - " /> <ui:insert name="title">Browser Title</ui:insert>
    </title>
</h:head>

<h:body>
    <div id="top" >
        <ui:insert name="top">Top Default</ui:insert>
    </div>

    <div id="messages">
        <rich:messages id="messagePanel" ajaxRendered="true"/>
    </div>

    <div id="content">
        <ui:insert name="content">Content Default</ui:insert>
    </div>
</h:body>
Run Code Online (Sandbox Code Playgroud)

使用模板的文件

<ui:composition template="/resources/masterLayout.xhtml" 
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:a4j="http://richfaces.org/a4j">

    <ui:define name="title">
        <h:outputText value="#{bundle.EditActivityTitle}"></h:outputText>
    </ui:define>

    <ui:define name="top">
        <ui:include src="#{userController.roleMenuPath}"/>
    </ui:define>

    <ui:define name="content">

        <rich:panel header="Edit Activity" styleClass="center_content">
            <h:form id="activity_edit_form">
            ...
            </h:form>
        </rich:panel>
    </ui:define>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)

我在用:

  • RichFaces 4.0决赛
  • Glassfish 3.1.1
  • 我不使用maven和artefact作为库

在此输入图像描述

Bal*_*usC 6

XML或文本声明不在实体的开头

此错误表明您<?xml ... ?>在生成的HTML输出的错误位置处有悬空声明.这是无效的,文档顶部应该有一个,或者最好没有人(否则MSIE可能会破坏).检查您的Facelets是否包含模板和标记文件,并确保它们都包含在内<ui:composition>.

所以,虚拟include.xhtml必须如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <h2>Include page</h2>
    <p>Include page blah blah lorem ipsum</p>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)

因此不是这样的:

<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">
    <?xml version="1.0" encoding="UTF-8"?>
    <h2>Include page</h2>
    <p>Include page blah blah lorem ipsum</p>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)

甚至

<?xml version="1.0" encoding="UTF-8"?>
<x:anotherComponent
    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">
    <h2>Include page</h2>
    <p>Include page blah blah lorem ipsum</p>
</x:anotherComponent>
Run Code Online (Sandbox Code Playgroud)

顺便说一句,Facelets完全可以省略XML声明.

也可以看看: