微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

抱歉有点愚蠢.但我明白(我缺乏知识)如果你想在那个页面上使用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

Firebug报告页面的这些状态

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

使用模板的文件

<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决赛
> Glassfish 3.1.1
>我不使用maven和artefact作为库

解决方法

XML or text declaration not at start of entity

错误表明您有悬空<?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>

因此不是这样的:

<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声明.

也可以看看:

> How to include another XHTML in XHTML using JSF 2.0 Facelets?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。