I'm in trouble using primefaces image galleria.
Sometimes the filmstrip is displayed multiple times, sometimes not.

Galleria printscreen

The images are obtained dynamically by a Servlet class.
I have already debugged the code and the list of images is correct, without repeating the items.

How can I prevent images repetition?

galleria.xhtml

<p:galleria id="myGalleria" 
        value="#{myBean.imageList}"
        var="item" 
        effect="fade" 
        autoPlay="false" 
        panelWidth="540"        
        showCaption="true" 
        widgetVar="myGalleria">     

    <p:graphicImage width="520" 
                    id="img"
                    title="#{item.description}"
                    value="/imageServlet/show?id=#{item.id}" 
                    cache="false" />
</p:galleria>

ImageServlet

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    String id = request.getParameter("id"); 

    if(StringUtils.isNotBlank(id)) {

        try {

            byte[] dados = myService.getImageData(id);
            if(dados != null) {

                String fileName = id.concat(EXTENSAO_ARQUIVO);

                response.setHeader("Content-Type", getServletContext().getMimeType(fileName));
                response.setHeader("Content-Length", String.valueOf(dados.length));
                response.setHeader("Content-Disposition", "inline; filename=\"" + fileName + "\"");

                // configuracoes de cache
                response.setHeader("Cache-control", "no-cache, no-store");
                response.setHeader("Pragma", "no-cache");
                response.setHeader("Expires", "-1");

                InputStream in = new ByteArrayInputStream(dados);
                OutputStream out = response.getOutputStream();

                IOUtils.copy(in, out);

                if(in != null) {
                    in.close();
                }
                if(out != null) {
                    out.close();
                }
            }           
        } catch (Exception e) {
            // TODO: log
            e.printStackTrace();
        }
    }
}

MyImage class

public class MyImage {
   private String id;
   private String description;
}

MyBean class

public class MyBean {
   List<MyImage> imageList = myService.getImageList();
}

1 Answers

1
LIU ShouHai On

this might be a duplicate of Primefaces UI issue with Gallery Film strip, see my workaround there:

<p:commandLink onclick="PF('popup').show();" update="galleria"/>
<p:dialog id="popup">
    <p:galleria id="galleria"/>
</p:dialog>