Re: Confirmation dialog during file upload

2010-06-18 Thread Kent Tong
 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



Re: Confirmation dialog during file upload

2010-06-18 Thread Kent Tong
Sorry, there is a bug in the code: You should never keep a FileUpload
object across requests. So, you need to copy the data into somewhere else.


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Confirmation dialog during file upload

2010-06-18 Thread Alec Swan
Hello,

If I understand your approach correctly, then the user would have to
click Upload button again after being redirected MyPage to
ConfirmSavePage, which is not desirable.

I would like to implement the following interaction:

1. User clicks Upload button and form submission request is sent to the server
2. The code on the server detect the file name collision and causes a
ModalWindow to display
3.1 If the user clicks Confirm button then upload form submission is resumed.
3.2 If the user clicks Cancel button then upload form submission is canceled.

What's the best way to implement this interaction? Can I use a request
intercepting page to display the ModalWindow?

Thanks

On Fri, Jun 18, 2010 at 3:42 AM, Kent Tong k...@cpttm.org.mo wrote:
 Sorry, there is a bug in the code: You should never keep a FileUpload
 object across requests. So, you need to copy the data into somewhere else.


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Confirmation dialog during file upload

2010-06-18 Thread Kent Tong
 1. User clicks Upload button and form submission request is sent to the
 server
 2. The code on the server detect the file name collision and causes a
 ModalWindow to display

These can be done with an AjaxButton to send the upload request. Then
show the ModalWindow in onSubmit().

 3.1 If the user clicks Confirm button then upload form submission is
 resumed.

The Confirm button would be another AjaxButton then. Just save the
file in onSubmit(). Of course, make sure you copied the file content
in the first place for use here.




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Confirmation dialog during file upload

2010-06-17 Thread Alec Swan
Hello,

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?

Thanks

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org