This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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.....
 
wood burning stoves
 
subject: Unable to display image using jsf 1.2
 
Similar Threads
Problem displaying report using JSP
How to move a video file(*.flv) from a directory to another directory
Using JSTL Data Displayed In Browser Is Getting Fixed To 24576 Bytes(24 KB)
resizing table width
Resizing table width upon page load