Hello,
While using ImageCropper, i always get Conversion error occured. What can be the problem? Thanks in advance . I am using Glassfish V3, Netbeans 6.8, Mozialla 3.5.6
The showcase runs fine for me.
Edit :- This is bug with Primefaces. if i give simple image which is in my document root, it works fine. But if i give alternatedocroot_1 in my sun-web.xml (accessing images outside my document root) i get this error.
ImageCropper problem. {0} Conversion error occured
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
ImageCropper can crop local images in webroot and external images located with http://. I don't think it is a bug but more like a limitation as it doesn't support glassfish specific stuff like this.
Hello,
in my opinion there are two reasons who indicates that supporting external docroots is desirable in enterprise context.
1. Mounting big data sources out of web application archive.
2. Using external image context effects that the images can't be inside a web-resource with activated security.
Solution that works for me:
File: ImageCropperRenderer.java
Package: org.primefaces.component.imagecropper
@optimus.prime: Would you patch the Code in trunk?
greetings
tatsu
in my opinion there are two reasons who indicates that supporting external docroots is desirable in enterprise context.
1. Mounting big data sources out of web application archive.
2. Using external image context effects that the images can't be inside a web-resource with activated security.
Solution that works for me:
File: ImageCropperRenderer.java
Package: org.primefaces.component.imagecropper
Code: Select all
private BufferedImage getSourceImage(FacesContext context, String imagePath) throws IOException {
BufferedImage outputImage = null;
String absolutePath = null;
boolean isExternal = imagePath.startsWith("http");
if (isExternal) {
URL url = new URL(imagePath);
outputImage = ImageIO.read(url);
} else {
ServletContext servletContext = (ServletContext) context.getExternalContext().getContext();
// support for alternatedocroot (e.g. glassfish)
if (servletContext.getAttribute("org.apache.catalina.alternateResources") != null) {
AlternateDocBase matchedAlternateDocBase = AlternateDocBase.findMatch(
imagePath,
(ArrayList<AlternateDocBase>) servletContext.getAttribute("org.apache.catalina.alternateResources"));
if (matchedAlternateDocBase != null) {
absolutePath = matchedAlternateDocBase.getBasePath() + imagePath;
}
}
// default
if (absolutePath == null) {
absolutePath = servletContext.getRealPath("") + imagePath;
}
outputImage = ImageIO.read(new File(absolutePath));
}
return outputImage;
}
greetings
tatsu
-
- Posts: 37
- Joined: 05 Jun 2013, 19:29
Optimus or any who could helpe me,
What about if I want to allow the user post an image and keep it in his local machine? I'm talking about a possibility where I don't want to allow the user upload images from his local machine to the server, but keep the images in a specific path in his local machine.
What about if I want to allow the user post an image and keep it in his local machine? I'm talking about a possibility where I don't want to allow the user upload images from his local machine to the server, but keep the images in a specific path in his local machine.
JSF 2.1, Primefaces 3.5.9, Primefaces-extensions-0.7.1, GlassFish Server 3.1.2, Java EE 6 Web, JDK 1.7, Eclipselink-2.3.2 and Netbeans 7.3
-
- Posts: 37
- Joined: 05 Jun 2013, 19:29
kukeltje,
I said "specific path". the user can register a previous path and after that he/she can fetch images from there.
Also, I didn't find a place in this forum which classifies a thread as a zombie or not.
I said "specific path". the user can register a previous path and after that he/she can fetch images from there.
Also, I didn't find a place in this forum which classifies a thread as a zombie or not.
JSF 2.1, Primefaces 3.5.9, Primefaces-extensions-0.7.1, GlassFish Server 3.1.2, Java EE 6 Web, JDK 1.7, Eclipselink-2.3.2 and Netbeans 7.3
You cannot access it on a browser local machine in ANY path... But maybe I misunderstood you... I'm not a native english speakerprofessional wrote:I said "specific path". the user can register a previous path and after that he/she can fetch images from there.
In the forum posting rules it says:professional wrote:Also, I didn't find a place in this forum which classifies a thread as a zombie or not.
And yes, this is maybe not as explicit, but if you follow the forum a little (and you should), you'd remember the zombi thing was mentioned multiple, no many times... It is over three years old. Components are changed so much, versions of browsers, jee servers etc have changed, that in almost every case, the relation is non-existent, But in this specific case... well.... hmmmm....7) Avoid continuing with "I have the same problem" to old threads started by another, create a new thread for your case instead.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 65 guests