0

不知怎的,我找不到我的问题的答案......

在我的 WebApplication 中,我使用 ui:include 包含内容。现在我的问题是,包含文件中的所有 Primefaces 组件(按钮、InputText 字段……)都不起作用,尽管它们显示在视图中。

我的布局文件:

<?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://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
    <h:head>                    

    </h:head>
    <h:body>
        <p:layout fullPage="true">

            <p:layoutUnit position="north" size="130" style="border: none">
                <h1 align="center">Adressbuch</h1>
            </p:layoutUnit>

            <p:layoutUnit position="west" size="270" style="border:none; padding-left: 15px">
                <h:form>
                <p:menu>
                    <p:submenu label="Menu">
                        <p:menuitem value="Home" actionListener="#{navigationBean.setCurrentPage('welcome')}" update=":content"/>
                        <p:menuitem value="Test" actionListener="#{navigationBean.setCurrentPage('test')}" update=":content"/>
                    </p:submenu>
                </p:menu>
                </h:form>
            </p:layoutUnit>

            <p:layoutUnit position="center" style="border: none">
                <p:panel id="content"  style="border: none">
                    <ui:include src="#{navigationBean.currentPage}" />
                </p:panel>
            </p:layoutUnit>

        </p:layout>
    </h:body>
</html>

我的导航 Bean:

@Named(value = "navigationBean")
@RequestScoped
public class NavigationBean {

    private final String PATH = "/WEB-INF/resources/sites/";
    private String currentPage;

    /**
     * Creates a new instance of NavigationBean
     */
    public NavigationBean() {
        this.currentPage = this.PATH + "welcome.xhtml";
    }

    public String getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(String currentPage) {
        this.currentPage = this.PATH + currentPage + ".xhtml";
    }

    }

在布局文件的内容部分加载的示例内容:

<?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://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>

            <p:panelGrid columns="4">
                <p: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" />
                <p:outputLabel id="display" value="#{basicView.text}" />
            </p:panelGrid>


    </h:body>
</html>
4

0 回答 0