Hi guys!
I want to know if there's anyway to clear or reload the area of a imageAreaSelect when a image changes.
The image is loaded dynamically, users can upload a image and select a area in the same page (something like Facebook photo change, that's exactly what I'm trying to implement), but if a new image is loaded, even when I update the components, the imageAreaSelect still stands in the old picture area.
Thank you!
[SOLVED] Clear imageAreaSelect when p:graphicImage changes
-
- PrimeFaces Core Developer
- Posts: 3979
- Joined: 03 Dec 2010, 14:11
- Location: Bavaria, DE
- Contact:
Please post your code with code quotes.
Thomas Andraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
Ok!tandraschko wrote:Please post your code with code quotes.
Code: Select all
<h:form id="upload" enctype="multipart/data">
<p:fileUpload fileUploadListener="#{fotoBean.handleFileUploadPerfil}"
onstart="PF('statusDialog').show()" onerror="PF('statusDialog').hide()"
mode="advanced" auto="true" label="#{msgs.selecionar_foto}"
oncomplete="PF('statusDialog').hide(), areaSelect.reload()"
invalidFileMessage="#{erros.arquivo_invalido}"
allowTypes="/(\.|\/)(jpg|jpeg|png)$/" multiple="false"
update=":panelRecortar" sizeLimit="131072"
invalidSizeMessage="#{erros.tamanho_invalido}">
</p:fileUpload>
</h:form>
<p:spacer />
<p:outputPanel id="panelRecortar">
<center>
<p:graphicImage id="recortar" value="#{fotoBean.foto}" cache="false" styleClass="img-polaroid" />
<pe:imageAreaSelect for="recortar" handles="true" aspectRatio="200:200" widgetVar="areaSelect" />
</center>
</p:outputPanel>
Code: Select all
public void handleFileUploadPerfil(FileUploadEvent event) {
try {
imagem = "/resources/tempimages/" + socialBean.getPerfil().getId() + ".png";
File arquivo = new File(StringUtils.getDiretorioCompleto("") + imagem);
FileUtils.copyInputStreamToFile(event.getFile().getInputstream(), arquivo);
} catch (Exception e) {
imprimirErro(ErroUtil.getMessage(ErroUtil.RENDIZAR_FOTO));
}
}
public StreamedContent getFoto() {
if (imagem == null) {
imagem = FOTO_PADRAO_PERFIL;
}
return getStreamedContent(imagem);
}
FOTO_PADRAO_PERFIL is a constant to render a default image.
getStreamedContent just load the image from some directory and returns a StreamedContent.
Primefaces 6.0 | Primefaces Extensions 6.1.0 | Glassfish 4.1.0 | Mojarra 2.2.8
Hibernate 4.3.10 Final | NetBeans 8.1 | JDK 1.8.0_45
Hibernate 4.3.10 Final | NetBeans 8.1 | JDK 1.8.0_45
-
- PrimeFaces Core Developer
- Posts: 3979
- Joined: 03 Dec 2010, 14:11
- Location: Bavaria, DE
- Contact:
I fixed this for the upcoming releases, for now you can use:
Code: Select all
oncomplete="PF('statusDialog').hide(); PF('areaSelect').cancelSelection(); PF('areaSelect').reload();"
Thomas Andraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
I tried but it did not work. The same problem occours. =\tandraschko wrote:I fixed this for the upcoming releases, for now you can use:
Code: Select all
oncomplete="PF('statusDialog').hide(); PF('areaSelect').cancelSelection(); PF('areaSelect').reload();"
Primefaces 6.0 | Primefaces Extensions 6.1.0 | Glassfish 4.1.0 | Mojarra 2.2.8
Hibernate 4.3.10 Final | NetBeans 8.1 | JDK 1.8.0_45
Hibernate 4.3.10 Final | NetBeans 8.1 | JDK 1.8.0_45
-
- PrimeFaces Core Developer
- Posts: 3979
- Joined: 03 Dec 2010, 14:11
- Location: Bavaria, DE
- Contact:
Then please try a trunk build, i tested it with the showcase and it worked.
Thomas Andraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
I solved the problem doing this in p:fileUpload:tandraschko wrote:Then please try a trunk build, i tested it with the showcase and it worked.
Code: Select all
onstart="PF('statusDialog').show(), PF('areaSelect').cancelSelection(), PF('areaSelect').reload()"
Primefaces 6.0 | Primefaces Extensions 6.1.0 | Glassfish 4.1.0 | Mojarra 2.2.8
Hibernate 4.3.10 Final | NetBeans 8.1 | JDK 1.8.0_45
Hibernate 4.3.10 Final | NetBeans 8.1 | JDK 1.8.0_45
-
- Information
-
Who is online
Users browsing this forum: No registered users and 20 guests