Thread: How to display the content of a BLOB column in a ADF/BC pages ?


Permlink Replies: 7 - Pages: 1 - Last Post: Sep 3, 2009 12:43 AM Last Post By: mojtabajava
ali_nizam

Posts: 984
Registered: 08/15/00
How to display the content of a BLOB column in a ADF/BC pages ?
Posted: Jun 6, 2007 5:44 AM
Click to report abuse...   Click to reply to this thread Reply
How to display the content of a BLOB column in a ADF/BC pages ?

There is some image in database table blog column. And we want to display image on the screeen.

There is some example about upload and dowload blog columns.
(steve not yet document example page etc...)

But We want to display blog picture in a image component...

is there any basic way to do it ?

Thanks a lot...
John Stegeman

Posts: 4,477
Registered: 01/16/06
Re: How to display the content of a BLOB column in a ADF/BC pages ?
Posted: Jun 6, 2007 5:45 AM   in response to: ali_nizam in response to: ali_nizam
Click to report abuse...   Click to reply to this thread Reply
ali_nizam

Posts: 984
Registered: 08/15/00
Re: How to display the content of a BLOB column in a ADF/BC pages ?
Posted: Jun 6, 2007 6:04 AM   in response to: John Stegeman in response to: John Stegeman
Click to report abuse...   Click to reply to this thread Reply
Thanks

But we are using 10.1.3.2 and we are foreign to J dev 11.

Can you extract the part of code from this sample to display image for us ?
John Stegeman

Posts: 4,477
Registered: 01/16/06
Re: How to display the content of a BLOB column in a ADF/BC pages ?
Posted: Jun 6, 2007 6:29 AM   in response to: ali_nizam in response to: ali_nizam
Click to report abuse...   Click to reply to this thread Reply
Ali,

You could just download the sample app... but... here is the servlet code from the demo (look at it just for technique - you'll obviously have to change it for your needs)...

John

package oracle.fodemo.storefront.servlet;
 
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
 
import javax.servlet.*;
import javax.servlet.http.*;
 
import oracle.jbo.ApplicationModule;
import oracle.jbo.Key;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;
import oracle.jbo.client.Configuration;
import oracle.jbo.domain.BlobDomain;
import oracle.jbo.domain.DBSequence;
import oracle.jbo.domain.Number;
import oracle.jbo.server.ViewObjectImpl;
 
public class ImageServlet
  extends HttpServlet
{
  private static final String CONTENT_TYPE = 
    "image/jpg; charset=windows-1252";
 
  public void init(ServletConfig config)
    throws ServletException
  {
    super.init(config);
  }
 
  public void doGet(HttpServletRequest request, 
                    HttpServletResponse response)
    throws ServletException, IOException
  {
    response.setContentType(CONTENT_TYPE);
    response.setContentType(CONTENT_TYPE);
    String detailProductId = request.getParameter("detail");
    String thumbnailProductId = request.getParameter("thumbnail");
    boolean thumbnail = true;
    String productId = null;
    OutputStream os = response.getOutputStream();
    String amDef = "oracle.fodemo.storefront.store.service.StoreServiceAM";
    String config = "StoreServiceAMLocal";
    ApplicationModule am = 
      Configuration.createRootApplicationModule(amDef, config);
    ViewObjectImpl vo = 
      (ViewObjectImpl) am.findViewObject("ProductImages"); // get view object (the same as used in the table)
    if (detailProductId != null)
    {
      productId = detailProductId;
      thumbnail = false;
    }
    else
    {
      productId = thumbnailProductId;
    }
    vo.defineNamedWhereClauseParam("paramThumbnail", null, null);
    vo.defineNamedWhereClauseParam("paramProductId", null, null);
    vo.setWhereClause("DEFAULT_VIEW_FLAG = :paramThumbnail AND PRODUCT_ID = :paramProductId");
    vo.setNamedWhereClauseParam("paramThumbnail", (thumbnail? "Y": "N"));
    vo.setNamedWhereClauseParam("paramProductId", productId);
    vo.executeQuery();
    Row product = vo.first();
    BlobDomain image = (BlobDomain) product.getAttribute("Image");
 
 
    InputStream is = image.getInputStream();
 
    // copy blob to output
    byte[] buffer = new byte[10 * 1024];
    int nread;
    while ((nread = is.read(buffer)) != -1)
      os.write(buffer, 0, nread);
    os.close();
    vo.setWhereClause(null);
    vo.removeNamedWhereClauseParam("paramProductId");
    vo.removeNamedWhereClauseParam("paramThumbnail");
    Configuration.releaseRootApplicationModule(am, false);
 
  }
}
 
KUBA

Posts: 877
Registered: 11/18/05
Re: How to display the content of a BLOB column in a ADF/BC pages ?
Posted: Jun 6, 2007 6:38 AM   in response to: ali_nizam in response to: ali_nizam
Click to report abuse...   Click to reply to this thread Reply
ali_nizam

Posts: 984
Registered: 08/15/00
Re: How to display the content of a BLOB column in a ADF/BC pages ?
Posted: Jun 6, 2007 8:44 AM   in response to: KUBA in response to: KUBA
Click to report abuse...   Click to reply to this thread Reply
thanks for your help...

we tried http://kuba.zilp.pl/?id=1 example. But it download
file directly to do file system.

We need to display the image in a image item.

We will try to change your code to meet our needs.

Thanks...
richard.allen.s...

Posts: 923
Registered: 03/19/03
Re: How to display the content of a BLOB column in a ADF/BC pages ?
Posted: Jun 6, 2007 9:50 AM   in response to: ali_nizam in response to: ali_nizam
Click to report abuse...   Click to reply to this thread Reply
Ali nizam,

Use the ImageServlet from the FOD demo (the code John provided). Then reference the servlet in your jspx page with an image tag.
<af:image source="/urlToServlet?thumbnail=#{bindings.someValue}"/>


Hope that helps.
--RiC
mojtabajava

Posts: 6
Registered: 08/28/09
Re: How to display the content of a BLOB column in a ADF/BC pages ?
Posted: Aug 29, 2009 2:51 AM   in response to: ali_nizam in response to: ali_nizam
Click to report abuse...   Click to reply to this thread Reply
hi
please
can you help for full sample for read and save blob in oracle10 xe by jdeveloper 10 ?
Legend
Guru Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums