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

发布于 2024-12-01 21:01:05 字数 3121 浏览 0 评论 0原文

抱歉有点蠢。但我开始明白(我缺乏知识),如果您想在该页面上使用 RichFaces 组件,则无法转发到另一个页面。

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

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

我不需要转发到带有 RichFaces 组件的页面,但如果有这个选项就好了。可能我误解了有关如何使用 RichFaces 的一些关键内容。

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

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

PS。如果有一个可遵循的模式,这将对如何使用 RichFaces 进行页面转发有很大帮助。

问候克里斯。

这是错误 Firebug 报告(调用转发后)

XML or text declaration not at start of entity
http://localhost:8080/humis/faces/app_user/projectHome.xhtml
Line 7

Firebug 报告页面的这些状态

  • 200 OK
  • 304 Not Modified

这是标题和包含的 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>

模板的文件

<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>

使用我正在使用的

  • : RichFaces 4.0-final
  • Glassfish 3.1.1
  • 我不使用 maven 和 artefact 库

Sorry being a bit daft. But I come to understand (my lack of knowledge) that it's not possible to forward to another page, if you want use RichFaces components on that page.

This is some of the problems that I am experiance when forward to a page with RichFaces components

  • If i forward to a page with a form, there is some of the hundreds of included JavaScrips that is interpreted as a bad formatted XML tag.
  • If I use nested tables, the tables loose the CSS file and look like normal JSF 2.0 dataTables.
  • When forwarded to page with only a tabPanel as in the demo TabPanel - Show Case the tab panels get messed up and become not usable (see image beelow).

I don't need to forward to pages with RichFaces components, but it would be nice to have that option. Probably I have misunderstood something crucial on how to use RichFaces.

Just for your information, I've created a totally new web project in NetBeans 7.0.1 and made two pages. Via a4j:commandLink I forward from the first page to the second one that have a Tab Panel. The rendering get messed up and the panel becomes unusable. Except including the libs and tags necessary for RichFaces, the new project is totally clean of setup parameter in the web.xml and rich-faces.xml.

What am I missing when I forward to a page with RichFaces components?

PS. If there is a patter to follow, that would help a lot on how to make page forwarding work with RichFaces.

Greetings Chris.

This is the error firebug reports (after the forward is invoked)

XML or text declaration not at start of entity
http://localhost:8080/humis/faces/app_user/projectHome.xhtml
Line 7

Firebug report these status for the page

  • 200 OK
  • 304 Not Modified

It is something in the header and in the 20-30 scripts included. Don't know how to include the long html list here. The request it self seams ok, but RichFaces generated something that I can control when doing a forward to the page.

The masterLayout file;

<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>

File using the template

<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>

I am using:

  • RichFaces 4.0-final
  • Glassfish 3.1.1
  • I don't use maven and artefact for the library

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请止步禁区 2024-12-08 21:01:05

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

此错误表明您在生成的 HTML 输出的错误位置有悬空 声明。这是无效的,文档顶部应该有一个,或者最好根本没有(否则 MSIE 可能会造成严重破坏)。检查您的 Facelet 是否包含模板和标记文件,并确保它们全部包含在

因此,虚构的 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>

因此不是这样:

<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>

或者甚至

<?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>

顺便说一句,Facelets 完全省略 XML 声明也是完全可以的。

另请参阅:

XML or text declaration not at start of entity

This error suggests that you have dangling <?xml ... ?> declarations at wrong places of the generated HTML output. This is invalid, there should be one at top of the document, or preferably, no one at all (otherwise MSIE will potentially go havoc). Check your Facelets include templates and tag files and make sure that they are all wrapped inside an <ui:composition>.

So, a fictive include.xhtml must look like this:

<?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>

and thus not this:

<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>

or even

<?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>

It's by the way perfectly fine for Facelets to omit the XML declaration altogether.

See also:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文