imageRotateAndResize with Galleria in Primefaces

196 Views Asked by At

I'm use galleria with StreamedContent to show images from c://. The galleria show the images correctly, but when I use the buttons to scale the image with pe:imageRotateAndResize, it only affects the first image, and when I change the image and use the buttons, it still affects only the first image in the gallery. What do I need or what do I have to correct so that pe:imageRotateAndResize affects the current image of galleria and not just the first one? Primefaces and PrimefacesExtensions version 6.0-6.0.0

Code of xhtml:

    <p:galleria id="galleriaC" var="galle" value="#{controller.imagenes}"  autoPlay="false" showCaption="false"
                                    style="width: 100%; max-width: 100px; min-width: 100%; min-height: 10px; height: auto; overflow:scroll; ">
                            <p:graphicImage id="myImage" value="#{controller.imageItem}" style="width: auto; height: 100%;">
                                    <f:param name="gh" value="#{galle}"/>
                            </p:graphicImage>
                        </p:galleria>
    
                      
                        
                        <pe:imageAreaSelect id="areaSelect"
                                            for="myImage"
                                            widgetVar="areaSelectWidget"
                                            autoHide="true"
                                            handles="false"
                                            movable="false"
                                            persistent="false"
                                            resizable="false"
                                            >
                            <p:ajax event="selectEnd" listener="#{controller.selectEndListener}" update="msg"/>
                        </pe:imageAreaSelect>
    
    
                        <pe:imageRotateAndResize id="rotateAndResize" for="myImage" widgetVar="rotateAndResizeWidget" >
                            <p:ajax event="rotate" listener="#{controller.rotateListener}"
                                    update="msg" oncomplete="PF('areaSelectWidget').reload();"/>
                            <p:ajax event="resize" oncomplete="PF('areaSelectWidget').reload();" />
                        </pe:imageRotateAndResize>
    
                        <p:commandButton value="Regresar" actionListener="#{controller.regresar()}" update=":form"/>                
                        <p:commandButton icon="ui-icon-zoomin" value="Scale +"
                                         onclick="PF('rotateAndResizeWidget').scale(1.05);return false;"/>
                        <p:commandButton icon="ui-icon-zoomout" value="Scale -"
                                         onclick="PF('rotateAndResizeWidget').scale(0.95);return false;"/>

Code Java:


    public List<String> getImagenes() {
            return imagenes;
    }
    
    public StreamedContent getImageItem(){
            FacesContext context = FacesContext.getCurrentInstance();
            try{
                if(context.getRenderResponse()){
                    return new DefaultStreamedContent();
                }else{
                    //String name = context.getExternalContext().getRequestParameterMap().get("gh");
                    Map<String,String> params = context.getExternalContext().getRequestParameterMap();
                    String nmFile = params.get("gh");
                    File imgFile = new File(nmFile);
                    System.out.println("File a stremear: "+nmFile);
                    StreamedContent ds = new DefaultStreamedContent(new FileInputStream(imgFile),context.getExternalContext().getMimeType(imgFile.getName()));
                    return ds;
                }
            }catch(Exception e){
                e.printStackTrace();
            }
            return null;
        }
    
    public void selectEndListener(final ImageAreaSelectEvent e) {
            final FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Area selected",
                    "X1: " + e.getX1() + ", X2: " + e.getX2() + ", Y1: " + e.getY1() + ", Y2: " + e.getY2()
                            + ", Image width: " + e.getImgWidth() + ", Image height: " + e.getImgHeight());
    
            FacesContext.getCurrentInstance().addMessage(null, msg);
        }
    
    
    public void rotateListener(final RotateEvent e) {
            final FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Image rotated",
                    "Degree:" + e.getAngle());
            FacesContext.getCurrentInstance().addMessage(null, msg);
        }

0

There are 0 best solutions below