• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Unable to display image using jsf 1.2

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 :-)




 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...............
 
Manjunath Kammar
Greenhorn
Posts: 3
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic