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>