简体   繁体   中英

Icons does not appear in p:GraphicImage

I want to add some icons to menubar. I put them into resources/images folder, but they don't appear.

Example: In submenu I added a icon="fail.ico" , but it doesn't appear.

<p:menubar autoDisplay="true" >
        <p:menuitem >     
            <p:commandLink action="index.jsf?faces-redirect=true" >
                <p:graphicImage height="24" width="24" value="resources/images/home.ico" style="border:none" />                
            </p:commandLink>
        </p:menuitem>

        <p:submenu label="sayfa2" icon="fail.ico" > 
            <p:menuitem value="altMenu2" url="altMenu.jsf"/>              
            <p:menuitem value="altMenu3" url="altMenuu.jsf"/>
        </p:submenu>
</menubar>

try like that, works on my jBoss

<h:graphicImage value="#{pathManager.path}/resources/images/home.ico" />

and write a class and method that handles paths to your resources or look how your deployment tree looks like and hard-code it.

That depends on where is your current page(Folders structure), and how your application handles the path. To solve the issue, click with the right button in your missing image(In your web browser) and watch the URL Address, now get back to the application and fix the value of your graphicImage with the correct path. You might have to use "../resources/images/home.ico" depending on your folders structure

  • Note: Test your page on Firefox before, It's not a requirement for a web browser to support ico files, especially the IE, you may have to convert it to another type

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM