jsf - primefaces Image Cropper getting null pointer exception -


i working primefaces application. need crop profile picture . once user desired portion of image , when user submits getting null pointer exception . getbytes() null.

here code xhtml code:``

<p:dialog id="cropdlg" appendtobody="false" widgetvar="dlg"   showeffect="fade" hideeffect="explode" resizable="false"   modal="true" header="edit picture"   style="background-color:#ffffff">   <h:form id="cropform" enctype="multipart/form-data">     <p:panel style="background-color: #ffffff" id="croppanel">       <p:messages />       <div>         <p:imagecropper value="#{profilebean.image}" image="/profile?id=#{profilebean.profile.imagefilename}" />         <h:commandbutton value="crop" immediate="true" styleclass="profilebut" action="#{profilebean.handlecropfileupload}" />       </div>     </p:panel>   </h:form> </p:dialog>  

my bean:

croppedimage croppedimage;  public void handlecropfileupload() {   system.out.println("get bytes" + croppedimage.getbytes());   fileimageoutputstream imageoutput;   try {     imageoutput = new fileimageoutputstream(file);     imageoutput.write(croppedimage.getbytes(), 0,     croppedimage.getbytes().length);     imageoutput.close();   } catch (exception e) {     e.printstacktrace();   } }  public croppedimage getimage() {   return image; }  public void setimage(croppedimage image) {   this.image = image; } 

remove attribute immediate="true" h:commandbutton , work.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -