1 2 Previous Next 21 Replies Latest reply: Apr 17, 2012 4:15 AM by HuaMin Chen RSS

    Show one jpg file

    HuaMin Chen
      Hi,
      Could anyone pls show with one clear example to take/show one jpg file from the DB when displaying the jsf page, in Jdev11.1.1.5? Thanks a lot.

      Edited by: 732035 on Apr 11, 2012 2:10 PM
        • 1. Re: Show one jpg file
          Mohammad Jabr
          check
          http://www.baigzeeshan.com/2010/09/store-images-in-blob-in-oracle-adf.html
          http://www.youtube.com/watch?v=_KYquJwYFGE
          Hope this is what you want.
          • 3. Re: Show one jpg file
            Frank Nimphius-Oracle
            ... Fusion Order Demo also has images that it reads from a database and displays in the UI

            http://www.oracle.com/technetwork/developer-tools/jdev/index-095536.html

            The most complete summary of this topic is by Timo Hahn

            http://tompeez.wordpress.com/2011/11/26/jdev11-1-2-1-0-handling-imagesfiles-in-adf-part-1/
            http://tompeez.wordpress.com/2011/11/26/jdev11-1-2-1-0-handling-imagesfiles-in-adf-part-2/
            http://tompeez.wordpress.com/2011/12/16/jdev11-1-2-1-0-handling-imagesfiles-in-adf-part-3/

            Frank
            • 4. Re: Show one jpg file
              HuaMin Chen
              Thanks all. I mean one example to show one blob column upon the display of the whole record on the jsf page.
              Suresh,
              I do not think your example is showing what I expect to have.

              Edited by: 732035 on Apr 11, 2012 4:23 PM
              • 5. Re: Show one jpg file
                Timo Hahn
                That's exactly what I demonstrate in part 3 mentioned by Frank (http://tompeez.wordpress.com/2011/12/16/jdev11-1-2-1-0-handling-imagesfiles-in-adf-part-3/)

                Timo
                • 6. Re: Show one jpg file
                  HuaMin Chen
                  Thanks. Is there an example to retrieve the image using doGet(..) upon displaying the current record on the jsf page?
                  • 7. Re: Show one jpg file
                    Timo Hahn
                    Yes, as I said in my last post.
                    The lower frame of the [url http://tompeez.files.wordpress.com/2011/12/bloghandlingfiles-011-catalog-jsf-mozilla-firefox1.jpg]image shows exactly this.

                    If this is not your use case you need to give more information about your problem.


                    Timo
                    • 8. Re: Show one jpg file
                      HuaMin Chen
                      Thanks.
                      Good day Timo,
                      How is “doGet” called by the app to display that image there?

                      Edited by: Hua Min on Apr 12, 2012 3:20 PM
                      • 9. Re: Show one jpg file
                        Timo Hahn
                        If you read the article series you find the answer in there.

                        in short: doGet is a servlet method which is called by the servlet engine to handle requests of the GET type. So the af:image uses an url like
                        source="/render_image?id=#{bindings.ImageId.inputValue}"
                        where render_image is the url the servet listens to. Every url containing the application context root and the 'render_image' is passed to the doGet method of the specified servlet.

                        For more info please read the complete series!

                        Timo
                        • 10. Re: Show one jpg file
                          HuaMin Chen
                          Thanks Timo. How can “doGet” know which image file to take from the database?

                          Edited by: HuaMin on Apr 12, 2012 6:09 PM
                          • 11. Re: Show one jpg file
                            Timo Hahn
                            Hua,
                            quote from the blog article:
                            >
                            The servlet implements the doGet(…) method where all the real work is done. First of all you can get the parameters passed to together with the URI: ‘id=#{bindings.ImageId.inputValue}’ in the sample above. The parameter(s) should be sufficient to get the image data from within the servlet. In the sample I pass the primary key of the row holding the image data in a blob.
                            >
                            this is referring to
                            source="/render_image?id=#{bindings.ImageId.inputValue}"
                            In general everything after the '?' in the url is treated as parameter. More then one parameter are seperatied by '&' in the ulr.
                            source="/render_image?id=#{bindings.ImageId.inputValue}&type=xyz"
                            would treat id and type as parameter. The code to get the parameter from is listed too in the blog (line 23-31)
                                        // get parameter from request
                                        Map paramMap = request.getParameterMap();
                                        oracle.jbo.domain.Number id = null;
                                        if (paramMap.containsKey("id"))
                                        {
                                            String[] pVal = (String[]) paramMap.get("id");
                                            id = new oracle.jbo.domain.Number(pVal[0]);
                                            sb.append(" id=").append(pVal[0]);
                                        }         
                            Timo
                            • 12. Re: Show one jpg file
                              Timo Hahn
                              Hua,
                              quote from the blog article:
                              >
                              The servlet implements the doGet(…) method where all the real work is done. First of all you can get the parameters passed to together with the URI: ‘id=#{bindings.ImageId.inputValue}’ in the sample above. The parameter(s) should be sufficient to get the image data from within the servlet. In the sample I pass the primary key of the row holding the image data in a blob.
                              >
                              this is referring to
                              source="/render_image?id=#{bindings.ImageId.inputValue}"
                              In general everything after the '?' in the url is treated as parameter. More then one parameter are seperatied by '&' in the ulr.
                              source="/render_image?id=#{bindings.ImageId.inputValue}&type=xyz"
                              would treat id and type as parameter. The code to get the parameter from is listed too in the blog (line 23-31)
                                          // get parameter from request
                                          Map paramMap = request.getParameterMap();
                                          oracle.jbo.domain.Number id = null;
                                          if (paramMap.containsKey("id"))
                                          {
                                              String[] pVal = (String[]) paramMap.get("id");
                                              id = new oracle.jbo.domain.Number(pVal[0]);
                                              sb.append(" id=").append(pVal[0]);
                                          }         
                              Timo
                              • 13. Re: Show one jpg file
                                HuaMin Chen
                                BTW, Timo, could you pls advise which specific Jars/Libraries you do import to the app for doing this below?
                                http://tompeez.wordpress.com/2011/12/16/jdev11-1-2-1-0-handling-imagesfiles-in-adf-part-3/
                                • 14. Re: Show one jpg file
                                  Timo Hahn
                                  The blog comes with the sample work space and instruction on how to download it. You find the needed libraries in the projects properties under 'Libraries and Classpath).


                                  Timo
                                  1 2 Previous Next