0

I want to use Primefaces galleria. I have seen galleria but I am not able to display images. I have tried these following codes:

Galleria.xhtml

<h:body>
<p:galleria value="#{imagesView.images}" var="image" panelWidth="600" panelHeight="400" showCaption="true">
    <p:graphicImage name="/resources/images/#{image}"/>
</p:galleria>

Galleria.java

@ManagedBean
public class ImagesView {
    private List<String> images;

    @PostConstruct
    public void init() {
        images = new ArrayList<String>();
        for (int i = 1; i <= 12; i++) {
            images.add("nature" + i + ".jpg");
        }
    }
    public List<String> getImages() {
        return images;
    }
}
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

3 Answers3

0

Use name attribute

<p:graphicImage name="images/#{image}"/>

Geinmachi
  • 1,251
  • 1
  • 8
  • 20
0

Try returning the image names like this:

images.add("images/nature" + i + ".jpg");

Then just change the p:graphicImage definition:

<p:graphicImage name="#{resource[image]}"/>

It should then map the image name properly.

Sva.Mu
  • 1,141
  • 1
  • 14
  • 24
0

I was also facing the same problem which I solved by dong following changes getting help from internet.

I know this one is old one but i am posting this for others who are facing the same issue.

you need to create resources folder and under that create one images folder and put all the images inside that.

NickyPatel
  • 503
  • 4
  • 11