6 Replies Latest reply on Jun 6, 2007 4:50 PM by 436787

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

    ali_nizam
      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...
        • 2. Re: How to display the content of a BLOB column in a ADF/BC pages ?
          ali_nizam
          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 ?
          • 3. Re: How to display the content of a BLOB column in a ADF/BC pages ?
            John Stegeman
            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);
            
              }
            }
            • 4. Re: How to display the content of a BLOB column in a ADF/BC pages ?
              470068
              Hi,

              See: http://kuba.zilp.pl/?id=1

              Kuba
              • 5. Re: How to display the content of a BLOB column in a ADF/BC pages ?
                ali_nizam
                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...
                • 6. Re: How to display the content of a BLOB column in a ADF/BC pages ?
                  436787
                  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