you can't hold on to it like that
its a tmp resource that should be cleaned up after the request
so you have to make a copy somehow.
johan
On 5/8/07, galbu <[EMAIL PROTECTED]> wrote:
Hi Johan thanks for the example it's what I need, but I have another
question...
I'm trying to use FileUploadField Component and I have a problem: I want
to
select a file with my ChooseFile page and then send it to another page
called UpdateProdotti in which I have a confirm button to press for write
the file on db.
But when I read the file selected in the ChooseFile page I lost the
information on the location path so, when the UpdateProdotti (File
uploadFile) is invoked, I can't find the file (no path is present).
I send the source code of ChooseFile, UpdateProdotti pages to be more
clear...if someone could show me where I'm wrong...
Thanks in advance Galbu
public class ChooseFile extends ConsumiTemplateMenuPage {
public ChooseFile() {
super();
verifyAccess();
final FeedbackPanel feedback = new
FeedbackPanel("feedback");
final FileUploadForm form = new
FileUploadForm("chooseFileForm");
add(feedback);
add(form);
}
public String getPageTitle() {
return "Scelta File da Salvare";
}
private class FileUploadForm extends Form {
private File uploadFile;
private FileUploadField fileUploadField;
public FileUploadForm(String name) {
super(name);
// set this form to multipart mode (allways needed
for uploads!)
setMultiPart(true);
// Add one file input field
add(fileUploadField = new
FileUploadField("fileInput"));
// Set maximum size to 100K for demo purposes
//setMaxSize(Bytes.kilobytes(100));
}
public void onSubmit() {
final FileUpload upload =
fileUploadField.getFileUpload();
if (upload != null) {
uploadFile = new File(
upload.getClientFileName());
setResponsePage(new
UpdateProdotti(uploadFile));
}
}
}
}
public class UpdateProdotti extends ConsumiTemplateMenuPage {
public UpdateProdotti(File src) {
super();
verifyAccess();
final File uploadFile = src;
final Form form = new Form("updateProdottiForm");
final FeedbackPanel feedback = new
FeedbackPanel("feedback");
add(feedback);
add(form);
form.add(new Button("annulla") {
public void onSubmit() {
setResponsePage(new ChooseFile());
}
});
form.add(new Button("updateProdotti") {
public void onSubmit() {
AppService appService =
((ConsumiApplication)
Application.get()).getAppService();
ConsumiSession session =
(ConsumiSession)getSession();
ExcelLoader.setConsumiSession(session);
ExcelLoader.setAppService(appService);
String esito;
try {
String tipo =
"ANAGRAFICA_PRODOTTO";
int dimensioneTabIniziale =
appService.countRecords(tipo,
session.getUser());
ExcelLoader.loadAnagraficaProdotto
(uploadFile);
/*
* va impostata la logica di
gestione dell'errore nel caricmento dei
dati e,
* quindi, anche un controllo
sulla stringa con cui valorizzare
l'esito.
*/
esito = "caricamento effettuato";
int dimensioneTabFin =
appService.countRecords(tipo,
session.getUser());
int numDatiCaricati =
dimensioneTabFin-dimensioneTabIniziale;
setResponsePage(new
ReportUpdateProdotti(esito,numDatiCaricati,dimensioneTabFin));
}
catch (HibernateException e) {
e.printStackTrace();
setResponsePage(new
HomeLoggedPage());
}
catch (IOException e) {
e.printStackTrace();
setResponsePage(new
HomeLoggedPage());
}
}
});
}
public String getPageTitle() {
return "Aggiorna Lista Prodotti";
}
}
Johan Compagner wrote:
>
> http://wicketstuff.org/wicket12/
>
>
> On 5/8/07, Frank Bille <[EMAIL PROTECTED]> wrote:
>>
>> On 5/8/07, Nino Saturnino Martinez Vazquez Wael <
[EMAIL PROTECTED]>
>> wrote:
>> >
>> > I think 1.2 are down, so you cant really access it any more?
>>
>>
>> It's very recent then. When I posted the link it worked.
>>
>> Frank
>>
>>
>>
>>
>>
-------------------------------------------------------------------------
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>> _______________________________________________
>> Wicket-user mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/wicket-user
>>
>>
>
>
-------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>
--
View this message in context:
http://www.nabble.com/Send-files-with-Wicket-tf3704527.html#a10377056
Sent from the Wicket - User mailing list archive at Nabble.com.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user