0

I am using Primefaces 5.2 and I need to display some images on my webpage. I am using the GraphicImage tag from primefaces and in the name attribute I am passing the full path of the image, but nothing is getting displayed on the webpage and when I checked the source code of the html page generated , there is RES NOT FOUND value on the source attribute of the img tag.

Here is my code

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Add your Experience</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</h:head>
<body>
<div class="container">
        <p:contentFlow value="#{testBean.images}" var="image">
            <p:graphicImage name="C:/Users/Singh/Desktop/Photos/#{image}"
                styleClass="content" />
            <div class="caption">#{image}</div>
        </p:contentFlow>
        <p:graphicImage name="image/bg.jpg" />
        <h:graphicImage name="C:/Users/Singh/Desktop/Photos/abh.jpg"></h:graphicImage>
    </h:form>
</div>
</body>
</html>

1 Answers1

1

you are choosing the wrong attribute, to specify a link you have to choose the url attribute

<p:graphicImage url="image/bg.jpg" />
<h:graphicImage url="C:/Users/Singh/Desktop/Photos/abh.jpg"></h:graphicImage>

for the attribute name, In JSF 2.x, you can render above image via “resource library” concept, by adding resources folder under webapp in your project, and in your case you have to add images folder under resources and add your image in this folder.

The code will be like that :

<h:graphicImage library="images" name="bg.jpg" />
Spartan
  • 1,167
  • 4
  • 20
  • 40