aspose file tools*
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
Author

Unable to display image using jsf 1.2

Srikanth Neelakantachar
Greenhorn

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 :-

<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

Joined: Mar 05, 2013
Posts: 3
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

Joined: Mar 05, 2013
Posts: 3
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...............
Manjunath Kammar
Greenhorn

Joined: Mar 05, 2013
Posts: 3
http://technology.amis.nl/2009/09/02/creating-a-custom-jsf-12-component-with-facets-resource-handling-events-and-listeners-valueexpression-and-methodexpression-attributes/

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