Display External Image to Server p:graphicImage

Asked

Viewed 551 times

1

I’m using it this way: XHTML:

<p:graphicImage value="#{emitenteBean.myImage}"

Bean:

private StreamedContent myImage;  

try {  
FileInputStream fileInputStream = new FileInputStream("/Users/user/files/minhaImg.jpg");  
myImage = new DefaultStreamedContent(fileInputStream, "image/jpeg");  

} catch (FileNotFoundException e) {  
  System.out.println("ERRO AO CONVERTER IMG.");  
}

Does not display image and shows no error.

2 answers

0

File on the Tomcat: openfiscal#uploadsopenfiscal.xml

Conteudo Aquivo Tomcat:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" docBase="/Users/jeremias/Downloads/uploadsopenfiscal" path="/arquivosupload">
  <Resource auth="Container" factory="org.jboss.weld.resources.ManagerObjectFactory" name="BeanManager" type="javax.enterprise.inject.spi.BeanManager"/>
</Context>

getCaminho: "../arquivosupload/cliente/minhaImage.jpg"

XHTML: <p:graphicImage value="#{emitenteBean.emitente.logo.caminhoImagem}"

In Chrome: src="../arquivosupload/cliente/minhaImage.jpg?pfdrid_c=false&uid=89c637b7-24a1-439f-a89d-a3e17afe7399"

0

It was only solved by mapping through Eclipse directly on Tomcat. My doubt came as I take it to the production since I Mapeed the directory inside the eclipse. In addition to the file generated within Catalina/localhost as reported another post.

  • The XML file created is who defines the path, adding it on the server no longer needs anything, it will work, but anything tells me that we adjust.

  • The Post below shows what I did, but still did not show the image, only after mapping in Tomcat by eclipse began to display.

  • Ummm, I don’t understand why you used .. / to browse a backward directory, did you see in my gist how I use it? i just pass the mapped directory, when we use IDE’s sometimes we have to be careful with these configuration files because usually it caches those files, in eclipse it creates a folder serves within Workspace, in netbeans if Tomcat is that Embedded that comes with it you need to access windows /appData/roamming/Netbeans/config/.... I can’t remember all the way because I don’t use windows but it’s in there that the config,

  • but if you add the server (always talking about Tomcat) the configs are on itself, then maybe something is not yet well configured. If the virtual directory is created right you can access it by the url, e.g.: http://localhost:8080/images/your image.jpg

  • It is also possible to see the virtual directory created by Tomcat’s managerApp, just below where they are located.

  • Tomcat is the Zip you download and then add to Eclipse. Using /.. / was because Chrome in the generated code was concatenating localhost:8080/Project Name/Pastaimg/image.jpg. It also wasn’t direct access as you mentioned. I made the configuration on another machine and in the same way it only worked after informing by the eclipse itself. Just putting the file as you mentioned it didn’t work. I am starting and stopping the Server by eclipse.

  • Another question I was left was that I inform the directory to save the images, in the case of a hosting server as I would do this? Likewise?

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.