473,472 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

I have a method which returns 'image' and I need to display the same image in UI

1 New Member
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.

Expand|Select|Wrap|Line Numbers
  1. public BufferedImage imageReturn(String taskId) throws IOException {
  2. byte[] bytes;
  3.  
  4. EntityManager em = (EntityManager) Component.getInstance("entityManager");
  5. System.out.println("Task ID : " + taskId);
  6.  
  7. bytes = (byte[]) em.createQuery("select t.image from Task t where t.taskId = " + taskId).getSingleResult();
  8.  
  9. System.out.println("bytes---> " + Arrays.toString(bytes));
  10. InputStream inputStream = new ByteArrayInputStream(bytes);
  11.  
  12. BufferedImage image = ImageIO.read(inputStream);
  13. return image;
In XHTML page :-

Expand|Select|Wrap|Line Numbers
  1. <tr> <td >
  2. Signature    
  3. </td> <td> <h:graphicImage id="image" alt="signature could not be found" value="#{taskHome.imageReturn(taskHome.instance.taskId)}" /> </td>
Thanks in advance :-)
Feb 27 '13 #1
1 1639
r035198x
13,262 MVP
1.) Create a Servlet and map it's URL to /images/*.
2.) Use the servlet parameters or request.getPathInfo() to get an image id and use that id in the servlet to stream out the image data
3.) Make your graphicImage tag point to your image id e.g
Expand|Select|Wrap|Line Numbers
  1. <h:graphicImage value="images/#{bean.imageId}"> 
where bean.getImageId returns the id of the image.
Mar 6 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Yves PEYSSON | last post by:
Hi, I want to display the same image (from the same file) at different positions in a window. Up to now I used DIV command in the body part of the text, and document.getElementById in order to...
9
by: Wally | last post by:
I am trying to display images from an Access 2000 database and I get an error "Invalid Parameter Used" when I execute the code line "picBLOB.Image = Image.FromStream(stmBLOBData)" in my Visual...
1
by: bborden | last post by:
Novice Access programmer here. I would like to display an image using the Toolbox Image object by calling the images file name using: =fPictureFiles(!!,1) in the Picture control. Below...
3
by: comp.lang.php | last post by:
class ThumbView extends PaginationView { function ThumbView() {} /** * Determine if the original image is actually an image and thus a thumbnail can be generated at all * * @access public...
6
by: yk | last post by:
Hi, Is it a technique available in html/javascript in order to display same image many many times on a same page? Because of a large page loading I am looking for a way not to have same...
10
by: rajbala | last post by:
Hai all, I need to get two or three images as a buttons.At the moment when i click the image it must display on window if i click another image button that image also display on the same...
1
by: rajbala.3399 | last post by:
Hai all, I need to get multiple image buttonsand wheni click on the image button it should display corresponding image on window and if i click another image button it is also display on same...
3
by: =?Utf-8?B?SlIx?= | last post by:
I would like to add text to an image. I have tried to use DrawString and it works on some images but on others it is very very small. I am pretty sure it has something to do with the size of the...
3
by: computer_guy | last post by:
Hi Everyone, I run into a problem. I am trying to write an aspx that can dynamically generate an image based on some input parameters. Things are very simple if the size of the parameters is...
0
by: David Kawlni | last post by:
Database backend:PostgreSQL Database Name: MoviesDirectory Table Name: picture Column: img DataType:bytea First, I store my uploaded images which may be either .jpg,.gif,.png with the following...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.