mery
mery

Reputation: 23

p:galleria does not display small image and description

I used primafeces galleria in my website.It is connected to mysql and I can display images from database.But small images and description don't display.What is the my problem.How should I display them?

    <p:galleria value="#{gallery.Print()}" var="news"
        panelWidth="650" panelHeight="400" showCaption="true">
        <h:outputLink
            value="http://localhost:8080/newsSite/faces/template/index.xhtml">
            <p:graphicImage value="#{news.image}" alt="#{news.title}" title="#{news.title}"
                width="100%" height="100%" />
        </h:outputLink>
    </p:galleria>

Bean.java

@ManagedBean(name="gallery")
@SessionScoped
public class Bean {
       private Statement st;
        private ResultSet rs;

        public List<galleryNews> Print(){

            Connect nesne = new Connect();
            List<galleryNews> galleryList = new ArrayList<galleryNews>();

            try {
                st=nesne.getCon().createStatement();
                rs=st.executeQuery("select * from galleryNews");

                while(rs.next()){
                    galleryNews obj = new galleryNews();
                obj.setId(rs.getInt("id"));
                obj.setTitle(rs.getString("title"));
                obj.setText(rs.getString("text"));
                obj.setImage(rs.getString("image"));
                galleryList.add(obj);
                }
            } catch (Exception e) {
                System.err.println(e);
            }
            return galleryList;
        }

Upvotes: 0

Views: 1220

Answers (1)

Sva.Mu
Sva.Mu

Reputation: 1131

This is caused by your p:graphicImage being nested in h:outputLink - p:galleria needs p:graphicImage to be its direct child, otherwise it seems unable to pull the alt and title values.

I was able to fix this by moving the link into the p:graphicImage and providing some additional styles - note I used p:link with no label instead of h:outputLink:

<p:galleria value="#{gallery.Print()}" var="news" panelWidth="650" panelHeight="400"
    showCaption="true">

    <p:graphicImage value="#{news.image}" alt="#{news.title}" title="#{news.title}"
        width="100%" height="100%">

        <p:link value=""
            style="width:100%; height:100%; display:block; position:absolute;"
            href="http://localhost:8080/newsSite/faces/template/index.xhtml" />

    </p:graphicImage>
</p:galleria>

I tested this in Firefox, Chrome and IE 11, seems working to me, though I'm not really sure if this is the best solution to your problem.

Upvotes: 1

Related Questions