I am new to Jsf and my requirement is to fetch list of images names(like n1.jpg,n2.jpg..etc for id=1 and n3.jpg,n4.jpg,n5.jpg...etc for id=2) for particular id from database, append it to "resources/Images/" and display slide show with pause and resume button in browser. I am using primefaces 4.0, jsf 2.2, mojarra 2.2.0. I am implementing the slide show task using p:imageswitch but the images are not displayed. Can anyone help me to trace my mistake, I am not getting any error also. The following is the xhtml code:
<h:selectOneMenu value="#{imageBean.selectedmp}" id="ulist">
<f:selectItems value="#{imageBean.dropdownValues}"/>
</h:selectOneMenu>
<h:commandButton value="Display Images" action="#{imageBean.executeQueryImages}" />
<div id="slider">
<p:imageSwitch widgetVar="switcher2" effect="none" slideshowSpeed="100" slideshowAuto="false" >
<ui:repeat value="#{imageBean.images}" var="image">
<p:graphicImage value="/resources/images/#{image}" />
</ui:repeat>
</p:imageSwitch>
</div>
This is my java code for executing query and get the list of images names. I able to produce the list:
public void executeQueryImages() {
String query1 = "some query";
ResultSet rs = null;
try {
connection = ConnectionFactory.getConnection();
statement = connection.createStatement();
rs = statement.executeQuery(query1);
images = new ArrayList<String>();
while (rs.next()) {
Events ev = new Events();
ev.setImagename(rs.getString("simagename"));
String Imagename = ev.getImagename();
System.out.println("path:::"+Imagename);
images.add(Imagename);
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
DBUtil.close(rs);
DBUtil.close(statement);
DBUtil.close(connection);
}
}
public List<String> getImages() {
return images;
}