jsf 2 - Before Upload event in PrimeFaces 3.5 -


is possible server side processing, before file upload in primefaces 3.5? let form contains p:inputtext elements, needs filled before file upload, how can check that? event?

view looks like-

<h:form enctype="multipart/form-data">     <p:inputtext value="#{fileuploadcontroller.name}" id="name" label="name" />     <p:inputtext value="#{fileuploadcontroller.about}" id="about" label="about" />     <p:fileupload fileuploadlistener="#{fileuploadcontroller.handlefileupload}"             mode="advanced"              update="messages"             sizelimit="100000"              allowtypes="/(\.|\/)(gif|jpe?g|png)$/"/>      <p:growl id="messages" showdetail="true"/>  </h:form> 

managedbean below-

import javax.faces.application.facesmessage; import javax.faces.context.facescontext;  import org.primefaces.event.fileuploadevent; import org.primefaces.model.uploadedfile;  public class fileuploadcontroller {      private string name;     private string about;     //getters & setters      public void beforeupload(){     if(getname().isempty()||getabout().isempty())         facesmessage msg = new facesmessage("error", "name or cannot empty");         facescontext.getcurrentinstance().addmessage(null, msg);     }      public void handlefileupload(fileuploadevent event) {         facesmessage msg = new facesmessage("succesful", event.getfile().getfilename() + " uploaded.");         facescontext.getcurrentinstance().addmessage(null, msg);     } } 

<p:fileupload/> has onstart property can conveniently wire <p:remotecommand/> component fire backing bean operation before upload operation starts

      <p:fileupload fileuploadlistener="#{fileuploadcontroller.handlefileupload}"         mode="advanced"          onstart="startsomething();"         update="messages"         sizelimit="100000"          allowtypes="/(\.|\/)(gif|jpe?g|png)$/"/>        <p:remotecommand name="startsomething" action="#{bean.startsomething}"/>   

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -