PrimeFaces imageCropper does not display the selected area

I am just copying an example in the window of strokes, but the area for selecting an image is not displayed. In the window, it looks so simple.

My page:

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui"> <h:form> <p:imageCropper value="#{uploadMB.croppedImage}" id="imageCropper" image="/images/banner.jpg" /> </h:form> </ui:composition> 

My backbean:

 @ManagedBean public class UploadMB implements Serializable{ private static final Logger logger = Logger.getLogger(UploadMB.class.getName()); private CroppedImage croppedImage; private String newImageName; public String crop() { if(croppedImage == null) return null; setNewImageName(getRandomImageName()); ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext(); String newFileName = servletContext.getRealPath("") + File.separator + "images" + File.separator + "barca" + File.separator + getNewImageName() + ".jpg"; FileImageOutputStream imageOutput; try { imageOutput = new FileImageOutputStream(new File(newFileName)); imageOutput.write(croppedImage.getBytes(), 0, croppedImage.getBytes().length); imageOutput.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; } private String getRandomImageName() { int i = (int) (Math.random() * 100000); return String.valueOf(i); } public String getNewImageName() { return newImageName; } public CroppedImage getCroppedImage() { return croppedImage; } public void setCroppedImage(CroppedImage croppedImage) { this.croppedImage = croppedImage; } public void setNewImageName(String newImageName) { this.newImageName = newImageName; } 

Is it possible that some libraries are missing? or another configuration option? I just downloaded the 3.5 jar performances and put it in my classpath.

thanks

+4
source share
2 answers

Is your image on% WEBAPP_ROOT% / images / banner.jpg

Can you access your image through an HTTP address (browser)?

0
source

Do you have a stable initialCoords attribute to trim: "x, y, w, h"? You can also set aspectRatio and minSize .

0
source

Source: https://habr.com/ru/post/1487550/


All Articles