aspose file tools*
The moose likes JSF and the fly likes Display picture dynamically using outputstrem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Display picture dynamically using outputstrem" Watch "Display picture dynamically using outputstrem" New topic
Author

Display picture dynamically using outputstrem

Avik Mazunder
Ranch Hand

Joined: Jun 27, 2012
Posts: 39

I am trying to implement a search page where users names will show along with their photos which are stored in db as blob



My xhtml page


but i am getting the following exception


but my arraylist is getting populated as I am getting the names. Then how can it get index out of bound exception..please help..I have been stuck in this code for 4 days...!
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2435
    
  28

The problem may be in a list that you don't expect.

Look at the exception. It gives you a line number inside your code. Look at that line. Are you using a list there? What are yo78u doing in line number 269 of MessageSendBean
Avik Mazunder
Ranch Hand

Joined: Jun 27, 2012
Posts: 39

the exception is in this line

Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2435
    
  28

Are there any lists in that line?
Avik Mazunder
Ranch Hand

Joined: Jun 27, 2012
Posts: 39

getUser() method is the getter of the arraylist..!
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2435
    
  28

So, if the exception says that the line contains an array list with size=0, and getUsers is the only list in that line, then it must follow that get Users returns a list with 0 elements. You should look at what getUsers returns and how it's populated. You haven';t posted the code that populates the users list. If you post that code, it will help.
Avik Mazunder
Ranch Hand

Joined: Jun 27, 2012
Posts: 39

it is in the 12th line of javabean code
Avik Mazunder
Ranch Hand

Joined: Jun 27, 2012
Posts: 39

please me...! is there any other method to display blob image in jsf page other than this....!! please please please help me...!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

The simplest and most portable way to display an image on a JSF View is to use the h:graphicImage tag, where you supply a URL which in turn invokes a servlet that will return the image you want.

However, for RichFaces users the a4j:mediaOutput tag can be very useful. It is, however, a challenge to get working right.

Some things that will probably make the job easier:

1. Consider using a h:dataTable instead of an a4j:repeat. Or at least consider using a ui:repeat, if you cannot be persuaded to use a dataTable. There is no virtue in using obsolete extensions to JSF once the functions they provide have become incorporated into the standard.

2. Don't attempt to do all the work in paint1 in a single line of code. The compiler isn't going to make less efficient code if you break it up into multiple statements, and it is easier to debug if the functions are all separate statements where a debugger can examine what each one does one at a time.


Customer surveys are for companies who didn't pay proper attention to begin with.
Avik Mazunder
Ranch Hand

Joined: Jun 27, 2012
Posts: 39

Thanks... I implemented that by using h:graphicImage and servlet...!! Thanks once again..!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Display picture dynamically using outputstrem