Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 2 我应该如何使用Primefaces Dock组件?_Jsf 2_Primefaces - Fatal编程技术网

Jsf 2 我应该如何使用Primefaces Dock组件?

Jsf 2 我应该如何使用Primefaces Dock组件?,jsf-2,primefaces,Jsf 2,Primefaces,我正在尝试使用dock菜单,但它不起作用。它显示图像,但当我将鼠标移到上面时,它不会缩放图像。我想在我的页面的中心布局单元中使用它,插入另一个页面,该页面实际上包含dock。代码如下所示: template.xhtml <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java

我正在尝试使用dock菜单,但它不起作用。它显示图像,但当我将鼠标移到上面时,它不会缩放图像。我想在我的页面的中心布局单元中使用它,插入另一个页面,该页面实际上包含dock。代码如下所示:

template.xhtml

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
    <style type="text/css">
        body.ui-layout-container { background-color: cadetblue;}
    </style>
</h:head>
<h:body>
    <p:layout fullPage="true" resizeTitle="resize">
        <p:layoutUnit position="north" id="north" resizable="false" size ="75">
            <ui:include src="header.xhtml" />
        </p:layoutUnit>

        <p:layoutUnit position="west" id="west" resizable="false" style="height:580px;overflow:hidden;" size="180">
            <ui:include src="menu.xhtml" />
        </p:layoutUnit>

        <**p:layoutUnit styleClass="layoutUnitCenter" position="center">
                 !!Here I insert the page which contains the dock
                <ui:insert name="content" />
        </p:layoutUnit>**

        <p:layoutUnit position="south" resizable="true" id="south" size="40">
            <ui:include src="footer.xhtml" />
        </p:layoutUnit>

    </p:layout>
</h:body>
</html>
dock.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core"
    template="template.xhtml">   

 <ui:define name="content">
    <h:head>
    </h:head>
    <h:body>
         <h:form>
           <p:dock position="top">  
                   <p:menuitem value="teachers" icon="/images/dock/teacher.png" url="#"/>  
                   <p:menuitem value="students" icon="/images/dock/student.png" url="#"/>  
                   <p:menuitem value="parents" icon="/images/dock/parent.png" url="#"/>  
           </p:dock> 
       </h:form>
    </h:body>
</ui:define>
</ui:composition>
我尝试单独使用dock.xhtml,没有ui:composition,它工作得很好。但是当我尝试这样使用它时,它只显示图像,但当我将鼠标移到图像上时,它什么也不做。另一个问题是它没有把码头放在这个区域的中心。它的位置稍微向左。
我对jsf和Primefaces还很陌生,所以任何答案都可能有帮助

此代码生成与您请求帮助相同的问题:

这个小小的改变,为我解决了: