ui的问题:包括使用primefaces

时间:2016-06-09 18:41:20

标签: jsf jsf-2 primefaces uiinclude ajax-update

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

在我的WebApplication中,我将内容包含在ui:include中。现在我的问题是,包含的文件中的所有Primefaces组件(Buttons,InputText Fields,...)都不起作用,尽管它们在视图中显示。

我的布局文件:

<?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>

0 个答案:

没有答案