如何将图像添加到primefaces菜单栏?

时间:2015-02-09 09:53:34

标签: image jsf primefaces menubar

如何将图像添加到菜单栏?

我无法将h:graphicImage添加到MenuBar(请参阅下面的代码),并希望在菜单栏中添加徽标。

enter image description here

当前代码:图片位于顶部

<h:form id="navigation">

    <h:link outcome="/index.xhmtl">
        <h:graphicImage url="http://upload.wikimedia.org/wikipedia/commons/8/81/Wikimedia-logo.svg" height="75"/>
    </h:link>

    <p:menubar>
        <p:submenu label="Routine">
            <p:menuitem value="Item 1" outcome="/routine/item1.xhtml"/>
            <p:menuitem value="Item 2" outcome="/routine/item1.xhtml"/>
            <p:menuitem value="Item 3" outcome="/routine/item1.xhtml"/>
        </p:submenu>
        <p:submenu label="Lab">
            <p:menuitem value="Item 1" outcome="/lab/item1.xhtml"/>
            <p:menuitem value="Item 2" outcome="/lab/item2.xhtml"/>
        </p:submenu>
        ...
        <p:menuitem value="Log out" action="#{userBacking.logout()}" />
    </p:menubar>

</h:form>

1 个答案:

答案 0 :(得分:7)

在menuItem中添加graphicImage:

<p:menuitem>
    <h:link outcome="/index.xhmtl">
        <h:graphicImage name="/customer/0_0_1/img/logo.png" height="50" />
    </h:link>
</p:menuitem>