> I have a form which allows a user to upload a file. The form is > patterned after upload Wicket example. > > If the file being uploaded will overwrite an existing file I need to > prompt the user if they want to replace the existing file or not. > What's the best way to implement this functionality?
There is nothing special about it. Just display a confirmation page. Only if the user chooses to go ahead, will it save the file. Below is an example doing that written in Scala (as my exercise in learning Scala): class MyPage extends WebPage { val f = new Form[Unit]("f") { override def onSubmit = { val exists = true if (exists) { setResponsePage(new ConfirmSavePage(upload.getFileUpload)) } else { Console.println("saving the file "+upload.getFileUpload.getClientFileName) } } } add(f) val upload = new FileUploadField("upload") f.add(upload) } class ConfirmSavePage(upload: FileUpload) extends WebPage { val f = new Form[Unit]("f") { override def onSubmit = { Console.println("saving the file "+upload.getClientFileName) } } add(f) val cancel = new Button("cancel") { override def onSubmit = { Console.println("Aborting") setResponsePage(classOf[MyPage]) } } f.add(cancel) } --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org