8 Replies Latest reply on Mar 1, 2011 3:51 PM by psramkumar.ps.ramkumar.gmail.com

    I want to display uploaded image in Modelpanel.

    ananymous7239

      Click HELP for text formatting instructions. Then edit this text and check the preview.


      can any one help me .how to display image in model panel .



      thanks for all your valuable suggestions

        • 1. Re: I want to display uploaded image in Modelpanel.
          kragoth

          This forum is for Seam, not how to do your homework.


          At the very least make the effort to solve the problem first. Show your work if you get stuck and someone might help. Don't just ask people to do your work for you.


          READ THE DOCO HERE click on view source....guess what that example has in it, an image in a modal panel!

          • 2. Re: I want to display uploaded image in Modelpanel.
            kragoth

            None of my suggestions were silly. I was being 100% serious.


            If you are interested in becoming a programmer then dealing with things you don't know a lot about is something you have to do every day.


            The answer is to not just jump on any old forum and ask someone to tell you. If you use this approach then you do not actually learn anything. All you are doing is copying and pasting someone else's work and hoping it works for you.


            When you are new to a topic you should go research it and read about it. Google will 99% of the time give you something on the very first page of your search results that if you read it will expand your knowledge on the topic.


            Once you have done some reading then you start experimenting with it. Write a small example bit of code to test if you can get it working or not. If you can't get it working maybe you need to read some more. If after doing a decent amount of research you are unable to make sense of it then you come to a forum and show people what you have tried and then people who have had a similar experience to you will be able to answer your question.


            The reason why people on this forum can answer questions is because they have taken the time to expand their knowledge on certain topics.

            • 3. Re: I want to display uploaded image in Modelpanel.
              ananymous7239

              Click HELP for text formatting instructions. Then edit this text and check the preview.


              I am sorry .but i have search a lot about this in google.i have no idea.i am new to seam.so i ask some one suggestions like you on forum.



              • 4. Re: I want to display uploaded image in Modelpanel.
                kragoth

                I assume when you say modal panel you are actually referring to the Richfaces modalPanel component. In which case it has very little to do with Seam at all.


                I obviously don't know how much time you spent researching the topic, but logic would say that you actually didn't google the topic a lot. See my reasoning below.


                So, I type modal panel richfaces into google and the very first link I get tells me how to use the component. (The link I provided in my earlier post)


                Clicking on the Developers Documentation link on that page shows me pretty much everything about the component and shows a picture of someone displaying an image in a modal panel.


                So, after reading both of these links you should be able to now experiment with a small page to see if you can do it. If you get it working great. Otherwise, you then should go to the RICHFACES forum and ask for help there, but make sure you show what you have tried, what errors you are getting and do not multi post on a bunch of unrelated topics.

                • 5. Re: I want to display uploaded image in Modelpanel.
                  kragoth

                  I'd rather not. My email is not for support.


                  Posting on the forum is just as effective if not better. There are much better and more experienced programmers then me that read and respond on this forum.

                  • 6. Re: I want to display uploaded image in Modelpanel.
                    ananymous7239


                    Tim i know how to display the image like in demo site.but i want to display image which i have been uploaded.that is what i am confusing .please give me a suggestion



                    • 7. Re: I want to display uploaded image in Modelpanel.
                      kragoth

                      I'm going to take for granted you can do the following.


                      You know how to get the image uploaded.


                      You know how to create a variable of type byte[] that contains the content of the image.


                      @Scope(ScopeType.CONVERSATION)
                      @Name("MyBean")
                      public class MyBean {
                      
                          private byte[] image = uploadedData; //You have to work out where that uploaded data comes from.
                      
                          public byte[] getImage() {
                              return image;
                          }
                      
                          public byte[] setImage(byte[] image) {
                              this.image = image;
                          }
                      }
                      



                      Then all you need to do is this in your xhtml is


                      <s:graphicImage id="image" value="#{MyBean.image}" />
                      

                      • 8. Re: I want to display uploaded image in Modelpanel.
                        psramkumar.ps.ramkumar.gmail.com
                        i guess we can do this using fileupload way

                        below is the method which read the file for upload

                        `       @RequestParameter String selectedFilePath;
                             /** Download a selected file */
                             public void downloadSelectedFile(){
                                  if(verbose){
                                       logger.info("Selected File Path "+ this.selectedFilePath);
                                  }
                                  File selectedFile = new File(this.selectedFilePath);
                                  String fileName = selectedFile.getName();
                                  String mimeType = FileDownloadUtil.getFileContentType(fileName);
                                  HttpServletResponse response = (HttpServletResponse) extCtx.getResponse();
                                  response.setContentType(mimeType);
                                        response.addHeader("Content-disposition", "attachment; filename=\""+fileName+"\"");
                                  try {
                                       ServletOutputStream os = response.getOutputStream();
                                       os.write(FileDownloadUtil.getBytesFromFile(selectedFile));
                                       os.flush();
                                       os.close();
                                       facesContext.responseComplete();
                                  } catch(Exception e){
                                       logger.error("Method downloadSelectedFile got Exception " + e.toString());
                                  }
                             }`
                        FileDownloadUtil.java
                                 `public static String getFileContentType(String fileN){
                                  String mimeType = URLConnection.guessContentTypeFromName(fileN);
                                  if (mimeType == null) {
                                       mimeType = "application/"+ fileN.substring(fileN.lastIndexOf('.') + 1, fileN.length());
                                  }
                                  return mimeType;
                             }

                             /**
                              * using Java IO latest API
                              * @param file
                              * @return
                              * @throws IOException
                              */
                             public static byte[] getBytesFromFile(File file) throws IOException {
                                  InputStream input = new FileInputStream(file);
                                  try {
                                       return IOUtils.toByteArray(input);
                                  } finally {
                                       input.close();
                                  }
                             }
                        `

                        and then point this file upload to the image source
                        `<h:graphicImage  url="<point to that upload page>"/>`

                        please update if any body implemented this way