6

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"
hellzone
  • 5,393
  • 25
  • 82
  • 148

2 Answers2

16

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

<p:graphicImage library="images" name="loading.gif" />
miroslav_mijajlovic
  • 1,703
  • 17
  • 31
  • worked for me thanks for your help. You can edit your answer. – hellzone Oct 07 '13 at 09:36
  • Using the library like this is bad practice ,see https://stackoverflow.com/questions/11988415/what-is-the-jsf-resource-library-for-and-how-should-it-be-used/11988418 – Kukeltje Jan 03 '19 at 20:23
1

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" />
  • How is this fundamentally different from the 13 upvoted and accepted answer (the 'subfolders' is not a fundamental difference). and using the library like this is bad practice, see https://stackoverflow.com/questions/11988415/what-is-the-jsf-resource-library-for-and-how-should-it-be-used/11988418 – Kukeltje Jan 03 '19 at 20:23