1

I'm trying to send data to a backing bean but after the form submit and get the response, in the browser the input file data is persisting in the page even though you can not see, i noticed that after press F5 in the page and the data was re submited...

in te backingbean i'm seting the corresponding value to null in a finally block of the method. The bean is defined as ViewScoped in faces config.

package co.com.ibm.acobros.managedbean;

import java.io.IOException;
import java.sql.SQLException;
import java.util.Map.Entry;

import javax.ejb.EJB;

import org.apache.myfaces.custom.fileupload.UploadedFile;

import co.com.ibm.acobros.gestorbean.GestionParametrosEJB;
import co.com.ibm.acobros.model.vo.VOCargueSegmento;
import co.com.ibm.acobros.utilidades.UtilitariosLOB;

public class SegmentosMB
{

private String idProceso;
private Long resultadoCargue;
private UploadedFile file;
@EJB
GestionParametrosEJB gestionParametrosEJB;

public void submit() throws IOException
{

VOCargueSegmento cargue = new VOCargueSegmento();

try
{
   cargue.setArchivoCargue(UtilitariosLOB.uploadedFileToCLOB(file.getInputStream()));
    cargue.setNombreArchivo(file.getContentType());
    cargue.setIdAutenticacion(1L);
    Entry<Long, String> r = (Entry<Long, String>) gestionParametrosEJB.cargarSegmentos(cargue);
    resultadoCargue = r.getKey();
    idProceso = r.getValue();
}
catch (SQLException | IllegalStateException e)
{
    e.printStackTrace();
}
finally
{
    file = null;
}
}

public UploadedFile getFile()
{
return file;
}

public void setFile(UploadedFile file)
{
this.file = file;
}

public Long getResultadoCargue()
{
return resultadoCargue;
}

public void setResultadoCargue(Long resultadoCargue)
{
this.resultadoCargue = resultadoCargue;
}

public String getIdProceso()
{
return idProceso;
}

public void setIdProceso(String idProceso)
{
this.idProceso = idProceso;
}

}

and the view ...

<h:form enctype="multipart/form-data">
<t:inputFileUpload accept=".csv" value="#{segmentosMB.file}">
</t:inputFileUpload>
<h:commandButton value="#{general.importar}"
    class="btn btn-davivienda"
    actionListener="#{segmentosMB.submit()}">
</h:commandButton>

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Steven Diaz
  • 139
  • 12
  • Does it break your functionality to do `@RequestScoped`? – JGlass May 09 '18 at 15:45
  • i tried with request scoped but the problem persist – Steven Diaz May 09 '18 at 19:17
  • I added the myfaces tag to your question so hopefully someone with more myfaces experience can help, I've only used RichFaces and haven't run into the problem before. May I suggest you joing this mailing list https://myfaces.apache.org/mail-lists.html as well and see if anyone can help? If you get it figured out, be sure to answer your own question so as to help others that might have the same problem! Good luck, keep me posted! – JGlass May 10 '18 at 14:10

0 Answers0