• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to display image using jsf 1.2

 
Srikanth Neelakantachar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i have a method which returns 'image' and i need to display the same image in UI and am using jsf1.2 , icefaces 1.8.2 , Jboss seam.
Am adding the snippet i used to display image in UI, but am unable to get image in UI.

public BufferedImage imageReturn(String taskId) throws IOException {
byte[] bytes;

EntityManager em = (EntityManager) Component.getInstance("entityManager");
System.out.println("Task ID : " + taskId);

bytes = (byte[]) em.createQuery("select t.image from Task t where t.taskId = " + taskId).getSingleResult();

System.out.println("bytes---> " + Arrays.toString(bytes));
InputStream inputStream = new ByteArrayInputStream(bytes);

BufferedImage image = ImageIO.read(inputStream);
return image;

In XHTML page :-

<tr>
<td >
Signature
</td>

<td>
<h:graphicImage id="image" alt="signature could not be found" value="#{taskHome.imageReturn(taskHome.instance.taskId)}" />
</td>

Thanks in advance :-)




 
Manjunath Kammar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TryThis:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Response Page (in Facelet)</title>
</h:head>
<h:body>
<h:form id="responseform">
<h2>Hello, #{userBean.name}
<h:commandButton id="back" action="inputFacelet" value="Back" /></h2>
</h:form>
<h:graphicImage id="image" url="#{resource['glassfish.gif']}" />
</h:body>
</html>


The <h:graphicImage> tag defines an image. The #{resource['glassfish.gif']} refer to the file "glassfish.gif". By default, the resources are kept in directory "resources" (with a 's' here).

Try to pass ID There....
 
Manjunath Kammar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.itcuties.com/j2ee/jsf-2-read-and-write-images-from-sql-database/

public static final String IMAGE_PATH = "/images/";

check this.. you may get some idea...............
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic