What you will find is that as a beginner it is going to be extremely difficult to do this. Do
not take these words lightly. Is this your primary objective or just one of the things you
have been tasked with?
Joined: Mar 01, 2011
Thanks for replaying.
I am developping a project, so I decided to use JSF because I see that this freemwork make tasks easy. So I stoped when I faced this problem.
Joined: May 12, 2009
This code demonstrates the loading & display of a BLOB from a database using h:graphicImage
without any temporary files. Whilst not entirely generic you should be able to get this working
with a days work if you're prepared to stick at it.
The scenario is that you have an "Employee" JPA persistent entity that implements the
"PhotoInterface" interface that defines one method, getPhoto(). Given a database with a table
with an integer primary key, where the entity implements PhotoInterface this will display a
byte as an image on your page.
"yourEJB" is simply an EJB that has a find function which is EntityManager.find().
Replace or remove SQLog.log() with your logging approach.
In the example below we have an "Employee" entity that supports the PhotoInterface and
therefore has a getPhoto() function. The Employee class (@Entity) has a byte
In this way you can retrieve images from any entity/table that supports PhotoInterface
given the primary key of the table row.