p:galleria 不显示小图和描述
p:galleria does not display small image and description
我在我的 website.It 中使用了 primafeces galleria 连接到 mysql 我可以显示来自 database.But 的小图片和描述 display.What 是我的problem.How 我应该显示它们吗?
<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;
}
这是因为你的p:graphicImage
嵌套在h:outputLink
中 - p:galleria
需要p:graphicImage
作为它的直接child,否则似乎无法拉取 alt
和 title
值。
我能够通过将 link 移动到 p:graphicImage
并提供一些额外的样式来解决这个问题 - 注意我使用 p:link
没有标签而不是 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>
我在 Firefox、Chrome 和 IE 11 中对此进行了测试,似乎对我有用,但我不确定这是否是解决您问题的最佳方法。
我在我的 website.It 中使用了 primafeces galleria 连接到 mysql 我可以显示来自 database.But 的小图片和描述 display.What 是我的problem.How 我应该显示它们吗?
<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;
}
这是因为你的p:graphicImage
嵌套在h:outputLink
中 - p:galleria
需要p:graphicImage
作为它的直接child,否则似乎无法拉取 alt
和 title
值。
我能够通过将 link 移动到 p:graphicImage
并提供一些额外的样式来解决这个问题 - 注意我使用 p:link
没有标签而不是 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>
我在 Firefox、Chrome 和 IE 11 中对此进行了测试,似乎对我有用,但我不确定这是否是解决您问题的最佳方法。