Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set image directory for Primefaces GraphicImage

I have a graphicImage component but I couldn't see my loading.gif file. I think there is a problem with file path. My image is under "Web Pages/Resources/images/loading.gif".

I am using Netbeans and Here is my page "Web Pages/Pages/customPages/index.xhtml";

<p:blockUI block="myDataTable" trigger="myDataTable">  
            Loading<br />  
            <p:graphicImage library="images" value="loading.gif"/>  
        </p:blockUI

EDIT: These are also didn't work :)

library="images" value="loading.gif"
library="resources/images" value="loading.gif"
value="loading.gif"
library="resources" value="loading.gif"

EDIT2: Here is how I solved this issue but I don't think it is a good solution. Is there any other way?

value="#{FacesContext.getCurrentInstance().getExternalContext()}/resources/images/loading.gif"
like image 256
hellzone Avatar asked Oct 07 '13 08:10

hellzone


2 Answers

When you use library attributte you shouldn't use value attributte. Use name attributte instead. Try:

<p:graphicImage library="images" name="loading.gif" />
like image 144
miroslav_mijajlovic Avatar answered Nov 15 '22 12:11

miroslav_mijajlovic


use the attributte library to indicate the folder that is inside the resources folder

<p:graphicImage library="images" name="loading.gif" />

if you use subfolders

<p:graphicImage library="images" name="folder1/folder2/loading.gif" />
like image 39
John Sanchez Avatar answered Nov 15 '22 13:11

John Sanchez