Salve a tutti
Ho uno strano problema con le pagine create in jfs che eseguono un download di file da fyle system.
la prima volta che eseguo il Download l'operazione avviene correttamente ,ma se cerco di eseguire qualche altro link , bottone, oppure il medesimo download la pagina si deve ricaricare . anche se lo fa in automatico la cosa è un po poco performate .
esempio tag nella pagina
codice:
<h:commandLink
id=""
action="#{DettaglioLottoController.getDownload}" >
<f:param name="idFileRic" value="#{fileRicevuto.idLottoFileRicevuto}"/>
<h:outputText id="id" value="#{fileRicevuto.qtaPdrAnomali}"
title="#{bundle['lotto.anomalie_download_righe_anomale']}"/>
</h:commandLink>
nella classe java DettaglioLottoController vi è il metodo
codice:
public void getDownloadFileAnomalie() {
ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
Map map = context.getRequestParameterMap();
String param = (String) map.get("idFileRic");
LottoFileRicevuto lottoFileRicevuto=null;
for (LottoFileRicevuto lottoFileRic : getLottoDettaglio().getFileRicevuti()) {
if(lottoFileRic.getIdLottoFileRicevuto().toString().equalsIgnoreCase(param)){
lottoFileRicevuto= lottoFileRic;
}
}
Lotto lotto= (Lotto) getLottoDettaglio();
FileLottoAnomalie fileLottoAnomalie = new FileLottoAnomalie(lotto,lottoFileRicevuto);
fileLottoAnomalie = getDettaglioLottoDelegate().getRigheAnomaleList(fileLottoAnomalie);
String path = "archiveFolder";
try {
logger.debug("fileLottoAnomalie IdLotto: " + fileLottoAnomalie.getLotto().getIdLotto());
logger.debug("fileLottoAnomalie Intestatario: " + fileLottoAnomalie.getLotto().getIntestatario());
//se e' un file del LetturistaDd ed e' stato processato, cercalo nella archiveFolder.palmare
if (fileLottoAnomalie.getLotto().getIntestatario() instanceof Letturista) {
logger.debug("Set search path to 'archiveFolder.palmare'");
path = "archiveFolder.palmare";
}
//se è un file non processato (scarto dell'intero file), cercalo nell'error folder
if (fileLottoAnomalie.getLottoFileRicevuto().getQtaPdrAnomali() == null || fileLottoAnomalie.getLottoFileRicevuto().getQtaPdrAnomali() < 0) {
logger.debug("Set search path to 'errorFolder'");
path = "errorFolder";
}
String fileName = PropertiesManager.getInstance().getProperty(path) + "/" + fileLottoAnomalie.getLottoFileRicevuto().getNomeFile();
logger.debug("calling download servlet with parameter: " + fileName);
HttpServletRequest request = (HttpServletRequest) context.getRequest();
String nomeFileOut = fileLottoAnomalie.getLottoFileRicevuto().getNomeFile() + "_" + DataTypeConverter.getStringFromDate(new Date(), DataTypeConverter.DATE_DDMMYYYY) + "_" + DataTypeConverter.getStringFromDate(new Date(), DataTypeConverter.DATE_HHMMSS) + "_ANOMALIE.csv";
logger.debug("----> NOME FILE OUT: " + nomeFileOut);
request.setAttribute("file_path_content", fileName);
HttpServletResponse response = (HttpServletResponse) context.getResponse();
RequestDispatcher dispatcher = request.getRequestDispatcher("/downloadRigheAnomalie");
FacesContext.getCurrentInstance().responseComplete();
dispatcher.forward(request, response);
} catch (IOException e) {
logger.error("Error reading i/o data", e);
} catch (ServletException e) {
logger.error("Error dispatching request", e);
} catch (NullPointerException ne) {
logger.error("Null Pointer Exception thrown " + ne.getMessage());
}
}
Grazie a chi interviene