You are on page 1of 12

Displaying an Image stored in the Database as B... | Oracle Community https://community.oracle.

com/message/2197822#2197822

Oracle.com Downloads Cloud Trials Other Languages Go Directly To Quick Links

THIS DISCUSSION IS ARCHIVED

10 Replies Latest reply on Nov 15, 2007 9:37 AM by 555256

576717 Nov 14, 2007 1:00 PM

Displaying an Image stored in the Database as BLOB on OA Fwk Page

Hi,

Is there a way that an Image stored in the database column be shown on the OA Fwk Page ??

We want to show the photo of the employee in a particular report.The images are stored in the per_images tables.

It tried creating a VO on per_images and map the attribute Image of the same to an item on the Page.
But dint work. :(

Anyone who can throw light on the same.

Regards
Jujaar

4138 Views Tags:

1 of 12 12/4/2019 5:02 PM
Displaying an Image stored in the Database as B... | Oracle Community https://community.oracle.com/message/2197822#2197822

Average User Rating

(0 ratings)

583651 Nov 14, 2007 1:21 PM ( in response to 576717)


1. Re: Displaying an Image stored in the Database as BLOB on OA Fwk Page

What is the item type u have created and what is the datatype associated with it?

Thanks
Babu

Actions Like (0)

2 of 12 12/4/2019 5:02 PM
Displaying an Image stored in the Database as B... | Oracle Community https://community.oracle.com/message/2197822#2197822

576717 Nov 14, 2007 1:34 PM ( in response to 583651)


2. Re: Displaying an Image stored in the Database as BLOB on OA Fwk Page

Hi,

I tried with Item Type as Image,RawText.


But nothing works.

Can u tell me what shuld be the Item Type and Data type shuld be associted with it??

Regards
Jujaar

Actions Like (0)

3 of 12 12/4/2019 5:02 PM
Displaying an Image stored in the Database as B... | Oracle Community https://community.oracle.com/message/2197822#2197822

555256 Nov 14, 2007 2:33 PM ( in response to 576717)


3. Re: Displaying an Image stored in the Database as BLOB on OA Fwk Page

Jugaar,
One way of doing it through urlinclude is see this link:
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=50&t=014273
I haven't tried the approach mentioned in this link, but looks perfect with urlinlcude and an additional jsp with jdbc code to get the
image.
I remember this discussion in many old threads, it wouold not be possible to show image from Db column of blob type. The only work
around is keep all the employee images in OA_MEDIA folder, with a unique indentifier say employee id as name.
In your VO get the employee_id of the corresponding employee and display image from the media folder.
--Mukul

Actions Like (0)

gareth.roberts Nov 14, 2007 10:37 PM ( in response to 555256)


4. Re: Displaying an Image stored in the Database as BLOB on OA Fwk Page

Hi Mukul,

That's not nice - surely Oracle has a solution to this?


Anything up and coming?
Any comments from anyone else?

Gareth

Actions Like (0)

4 of 12 12/4/2019 5:02 PM
Displaying an Image stored in the Database as B... | Oracle Community https://community.oracle.com/message/2197822#2197822

555256 Nov 15, 2007 3:08 AM ( in response to gareth.roberts)


5. Re: Displaying an Image stored in the Database as BLOB on OA Fwk Page

Gareth,
I agree Oracle should come up for a solution on this, but as of now, i don't see any solution for this.In fact UIX engine which is the
view layer of OAF, takes all pics of icons, buttons etc, from OA_MEDIA.
I have worked in ADF Faces,there u surely have solutions. So, as of now, the approach I mentioned above, i see no other approach
other than this working.
--Mukul

Actions Like (0)

555256 Nov 15, 2007 5:15 AM ( in response to 555256)


6. Re: Displaying an Image stored in the Database as BLOB on OA Fwk Page

Jujjar,
did u tried the approach?
--Mukul

Actions Like (0)

576717 Nov 15, 2007 9:04 AM ( in response to 576717)


7. Re: Displaying an Image stored in the Database as BLOB on OA Fwk Page

Cheers to all the people who are active on this forum helping others.

Hey Mukul,

5 of 12 12/4/2019 5:02 PM
Displaying an Image stored in the Database as B... | Oracle Community https://community.oracle.com/message/2197822#2197822

The basic concept we all know that Image should be there in the application tier for the OA Fwk page to display it.
But in our case the issue was User can change their photos anytime which will be saved in the database.So in order to get the latest
photo ,it was required that we take the photo always from the database.

We got reference from one of the Oracle Seeded page in Oracle HR (Self Service) which is used for uploading and viewing the
photos.

Page: /oracle/apps/per/selfservice/empdir/webui/EmpDetailPG

We created a VO with one dummy column in the VO and in the Controller we get the temporary location for the file which is returned
by OAPageContext on the application tier.

pageContext.getTemporaryImageLocation();

Then a method is called to create a file at the location got in the step mentioned above with the name of image.(Name of image
which is stored in the database,one of the VO attribute).

The dummy column of the VO is set the value which contains the path and Image name created on the application tier in the step
mentioned above.

In the controller we bind this column name with the Item(of type Image) on the page.

Below is the code for the same:

-**************************Controller - Process Request *************

public void processRequest(OAPageContext pageContext, OAWebBean webBean)


{
super.processRequest(pageContext, webBean);
if(pageContext.isLoggingEnabled(1))
pageContext.writeDiagnostics(this, "Entering processRequest..", 1);

Serializable[] param = {pageContext.getTemporaryImageLocation()};

6 of 12 12/4/2019 5:02 PM
Displaying an Image stored in the Database as B... | Oracle Community https://community.oracle.com/message/2197822#2197822

pageContext.getApplicationModule(webBean).invokeMethod("initImg",param);
OAImageBean oaimagebean = (OAImageBean)webBean.findIndexedChildRecursive("item1");
if(oaimagebean != null)
{
oaimagebean.setAttributeValue(UIConstants.SOURCE_ATTR, new OADataBoundValueViewObject(oaimagebean, "ImageSource"));
oaimagebean.setWidth(100);
oaimagebean.setHeight(110);
oaimagebean.setBorderWidth(2);
}
if(pageContext.isLoggingEnabled(1))
pageContext.writeDiagnostics(this, "Leaving processRequest..", 1);
}

********************************AM Methods***************************************
public void initImg(String s2)
{
OAViewObjectImpl oaviewobjectimpl = getImageEOVO1();
oaviewobjectimpl.executeQuery();
if(oaviewobjectimpl.first() != null)
{
OARow oarow = (OARow)oaviewobjectimpl.first();
BlobDomain blobdomain = (BlobDomain)oarow.getAttribute("Image");
if(blobdomain != null)
{
String s3 = createFile(s2, blobdomain, (String)oarow.getAttribute("ImageName"));
oarow.setAttribute("ImageSource", s3);
}
}
}

public void fromInputToOutput(InputStream inputstream, OutputStream outputstream)


throws IOException
{

7 of 12 12/4/2019 5:02 PM
Displaying an Image stored in the Database as B... | Oracle Community https://community.oracle.com/message/2197822#2197822

byte abyte0[] = new byte[255];


for(int i = 255; i == 255;)
{
i = inputstream.read(abyte0);
if(i < 0)
break;
outputstream.write(abyte0, 0, i);
}

outputstream.close();
inputstream.close();
}

public String createFile(String s, BlobDomain blobdomain, String s1)


{
File file = new File(s);
if(!file.exists())
file.mkdirs();
File file1 = new File(s, s1);
try
{
fromInputToOutput(blobdomain.getBinaryStream(), new FileOutputStream(file1));
}
catch(IOException ioexception)
{
ioexception.printStackTrace();
}
return "fwk/t/" + file1.getName();
}

*******************************************VO Query ****************************


SELECT PerEmpdirImagesEO.IMAGE_ID,
PerEmpdirImagesEO.ORIG_SYSTEM,
PerEmpdirImagesEO.ORIG_SYSTEM_ID,

8 of 12 12/4/2019 5:02 PM
Displaying an Image stored in the Database as B... | Oracle Community https://community.oracle.com/message/2197822#2197822

PerEmpdirImagesEO.IMAGE_NAME,
PerEmpdirImagesEO.CONTENT_TYPE,
PerEmpdirImagesEO.IMAGE,
PerEmpdirImagesEO.OBJECT_VERSION_NUMBER,
PerEmpdirImagesEO.LAST_UPDATE_DATE,
PerEmpdirImagesEO.LAST_UPDATED_BY,
PerEmpdirImagesEO.LAST_UPDATE_LOGIN,
PerEmpdirImagesEO.CREATED_BY,
PerEmpdirImagesEO.CREATION_DATE,
Null Image_Source
FROM Per_Empdir_Images PerEmpdirImagesEO
WHERE Orig_System = 'PER'
And Orig_System_Id = 162676
--------------------------------------------------------------------------------------

Cheers
Jujaar

Actions Like (0)

555256 Nov 15, 2007 9:19 AM ( in response to 555256)


8. Re: Displaying an Image stored in the Database as BLOB on OA Fwk Page

Jujjar,
But the apporach remains the same ur not writing image directly to the page, but getting it from DB blob column at a temperory place
, rite..... And then based on the location you are getting it in image item on page.
The same is done by UIX engine, for page item images like button etc, where there path is set to OA_MEDIA.
The jsp approach I told is where u don't have to store image anywhere, but directly will be put on the page.
--Mukul

9 of 12 12/4/2019 5:02 PM
Displaying an Image stored in the Database as B... | Oracle Community https://community.oracle.com/message/2197822#2197822

Actions Like (0)

576717 Nov 15, 2007 9:33 AM ( in response to 555256)


9. Re: Displaying an Image stored in the Database as BLOB on OA Fwk Page

Hi Mukul,

Yeah,thats the basic constraint,we have to have that Image in the application tier but I feel this approach is better than the JSP
approach cause we can handle it with the very basic and common compoenents of OA Fwk like VO,few methods in AM and
Controller Object and need not create a sepearate component like JSP or Servlet for it.

Thanks for your help.

Regards
Jujaar

Actions Like (0)

555256 Nov 15, 2007 9:37 AM ( in response to 576717)


10. Re: Displaying an Image stored in the Database as BLOB on OA Fwk Page

Jujjar,
But just think ur page CO will retrieve the images for employees every time that page has been viewed in the application layer. So,
you will either write a concurrent program or manually clear this location occassionaly, on the other hand, the approach I am telling u,
everything would be dynamic, so , there will be no file created on application layer.
I guess you can visualise what I am trying to say.Moreoever creating servelet/jsp is not a problem, if its suffice ur requirement.
--Mukul

10 of 12 12/4/2019 5:02 PM
Displaying an Image stored in the Database as B... | Oracle Community https://community.oracle.com/message/2197822#2197822

Actions Like (0)

11 of 12 12/4/2019 5:02 PM
Displaying an Image stored in the Database as B... | Oracle Community https://community.oracle.com/message/2197822#2197822

Oracle Community

About Oracle Developer Community FAQ Communities Other Languages Oracle.com

Site Map Legal Notices Terms of Use Privacy Cookie Preferences Ad Choices

12 of 12 12/4/2019 5:02 PM

You might also like