4

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

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Chris
  • 712
  • 3
  • 16
  • 39
  • What does a HTTP traffic debugger like Firebug say about the HTTP status code and the HTTP response body of the loaded stylesheets and scripts? – BalusC Aug 30 '11 at 14:06
  • @BalusC. Updated the post with the error firebug is reporting. I don't know how to update the post with the long including list of script that RichFaces uses. The script are all in the *src="/humis/faces/javax.faces.resource/* path and I guess they all resides there? – Chris Aug 30 '11 at 16:18

1 Answers1

6

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:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I'll go though and see if there's tag outside the *composite* tags. Shouldn't the XML error also appear when I do and redirect ? – Chris Aug 30 '11 at 16:26
  • The browser behaviour of interpreting this malformed markup is undetermined and specific to browser itself. Check the generated HTML output and look for dangling `` declarations. Its location should hint enough where they originated in the JSF source. – BalusC Aug 30 '11 at 16:29
  • I included the masterLayout file. But the html part of the page didn't get pasted in. – Chris Aug 30 '11 at 16:32
  • The problem is in the file which is using the master template. You need `` **without** any `` declaration inside. – BalusC Aug 30 '11 at 16:37
  • Then there's another template in the path as specified by `` which uses XML declaration at the wrong place or is missing a ``. – BalusC Aug 30 '11 at 16:56
  • Remove also the * – Chris Aug 30 '11 at 17:05
  • The doctype declaration should go in master template alone and definitely not in an include/tag/composite file. It messes everything up. There's supposed to be only one in top of the page. As to the double submit problem, this can happen when you submit a form which re-renders another form. You should put its contents in a wrapper and re-render it instead. – BalusC Aug 30 '11 at 17:06
  • Yes, you get weird problem that it's hard to find the reason for. Specially when you get the templates and things from Netbeans to start with. – Chris Aug 30 '11 at 17:09
  • I don't use it (I've always thrown it away after some time of trying, every few years again), so I can't explain what Netbeans was thinking/figuring out for you. – BalusC Aug 30 '11 at 17:09