开发者

Chrome giving error "Extra content at the end of the document" when adding another <h:column>

I have the following JSF table:

 <?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:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core">

<h:head>
    <title>List</title>
</h:head>

<h:body>
<h1>List</h1>

    <h:form>

        <h:dataTable value="#{myBean.workflows}" var="item">
            <h:column>
                <f:facet name="header">ID</f:facet>
                #{item.id}
            </h:column>
            <h:column>
                <f:facet name="header">Name</f:facet>
                #{item.name}
            </h:column>
            <h:column>
                开发者_StackOverflow社区<h:link outcome="edit" value="Edit">
                    <f:param name="myId" value="#{item.id}"/>
                </h:link>
            </h:column>
            <h:column>
                <h:link outcome="run" value="Run">
                    <f:param name="myId" value="#{item.id}"/>
                </h:link>
            </h:column>
            <h:column>
                 <h:commandButton value="Delete" action="#{myBean.doDelete}" />
            </h:column>
        </h:dataTable>
    </h:form>
</h:body>

</html>

The following part:

    <h:column>
         <h:commandButton value="Delete" action="#{myBean.doDelete}" />
    </h:column>

is causing "error on line 361 at column 9: Extra content at the end of the document" error to show up in Chrome above the table. At the same time, an exception is shown in the server log saying: "Unable to generate Facelets error page as the response has already been committed".

Why is the extra <h:column> causing this error?

UPDATE: It appears that the error will be thrown whenever there are more than two components (for example three h:link components).


I understand that this happens only when there's a rendering exception, but it's been too late for Facelets to change the response into a fullworthy HTTP 500 error page. It's too late because a part of the response has already been committed, which is a point of no return. This explains the "Unable to generate Facelets error page as the response has already been committed" error.

Chrome will apparently display "Extra content at the end of the document" when the resulting HTML/XML is malformed. Indeed, Facelets has abruptly stopped rendering the HTML due to the exception.

To fix the problem you should look back in the server logs for the real exception which caused Facelets to stop rendering the HTML.


add this to your xhtml:

f:view

and close it at the end of you form or just add it and close it before/after body tags.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜