I can not use the p: fileUpload .. when I put it in a page xhtml it stops working all the elements contained in the block form

1

I have a problem when entering the data to a form, when I enter dates and text there is no problem, uploads without problems to the database, but when you put the label:

 <p:fileUpload mode="simple"  value="#{formularioController.cargar}" />

It does not go up, it's more the upload button stays in active position and does not do anything, it does not give an error message and when I put a stop in the controller, it does not enter the controller, it stops before not even entering the controller, which has this in its part of the file:

private UploadedFile cargar;
public UploadedFile getCargar() {
    return cargar;
}
public void setCargar(UploadedFile file) throws IOException {
    this.cargar = file;
}

I thought it's my web.xml but this is the import as the manual says:

<filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

If I remove this tag ("p: fileUpload ...") the form works great. I read the official documentation of primefaces and I am sure that I am using it as recommended. is inside a:

<h:form enctype="multipart/form-data">

and it is really all within the form that stops working when I put this label, maybe I need to import something, I'm not sure anymore and I do not know where else to look. I hope you can give me a hand. my bookstores are:

    
asked by gorkyvtn 27.11.2018 в 22:02
source

1 answer

0

I found the problem, apparently it's just a matter of disabling the ajax (ajax="false") in the submit button or the accept button in the case of Spanish, so it did not reach the controller's call.

I've decided to put it here, just in case someone else happens to be the same and to remind me how stupid I can be.

<p:commandButton actionListener="#{formularioController.crearFormulario()}" value="Enviar Formulario" ajax="false" />

and since it did not occur to me, I did not put the code of the submit button in the question. because with that it is clear to me that we have to put 4 clear things.

  • the p: fileUpload must be inside a form with the command enctype="multipart / form-data".
  • in the controller you must pass the file by a data type compatible with file and then if you do what you want as a byte [] like:
  • 3. Disable the ajax in the call buttons to the controller ajax = false

  • Put the filters in the web.xml
  •     
    answered by 28.11.2018 в 14:45