jQuery in Action, 3rd edition
The moose likes JSF and the fly likes Unable to display image using jsf 1.2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Unable to display image using jsf 1.2" Watch "Unable to display image using jsf 1.2" New topic

Unable to display image using jsf 1.2

Srikanth Neelakantachar

Joined: Feb 19, 2013
Posts: 2
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 :-

<td >

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

Thanks in advance :-)

Manjunath Kammar

Joined: Mar 05, 2013
Posts: 3

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

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

Joined: Mar 05, 2013
Posts: 3

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

check this.. you may get some idea...............
Manjunath Kammar

Joined: Mar 05, 2013
Posts: 3

look into this as well.....
I agree. Here's the link: http://aspose.com/file-tools
subject: Unable to display image using jsf 1.2
It's not a secret anymore!