PrimeFaces没有完全渲染我的组件

时间:2017-05-12 19:06:17

标签: primefaces jsf-2 jsf-2.2

PrimeFaces无法渲染。我已经正确配置了所有内容(希望如此)。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:mp="http://primefaces.org/ui/material">
    <head>
<title>Welcome Page</title>
    </head>
    <body>
        <h:head>
            <h:form>
                <h:panelGrid columns="4" cellpadding="5">
                    <h:outputLabel for="name" value="Name:" style="font-weight:bold" />
                    <p:inputText id="name" value="#{basicView.text}" />
                    <p:commandButton value="Submit" update="display"
                        icon="ui-icon-check" />
                    <h:outputText id="display" value="#{basicView.text}" />
                </h:panelGrid>
            </h:form>
        </h:head>
    </body>
</ui:composition>
public class BasicView {

    private String text;

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }
}

我已经包含了所有注释和lib。

Here is the Index.xhtml output

1 个答案:

答案 0 :(得分:2)

你弄乱了头部和身体的标签。你还需要把你的身体放在身体里。

<!DOCTYPE html>
<h:html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:mp="http://primefaces.org/ui/material">
    <h:head>
        <title>Welcome Page</title>
    </h:head>
    <h:body>
        <h:form>
            <h:panelGrid columns="4" cellpadding="5">
                <h:outputLabel for="name" value="Name:" style="font-weight:bold" />
                <p:inputText id="name" value="#{basicView.text}" />
                <p:commandButton value="Submit" update="display"
                    icon="ui-icon-check" />
                <h:outputText id="display" value="#{basicView.text}" />
            </h:panelGrid>
        </h:form>
    </h:body>
</h:html>