ramzi....@gmail.com
unread,Dec 28, 2007, 6:01:17 PM12/28/07Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Web Toolkit
Hi,
I apologize if there was a post on this question, I looked around but
could not find a satisfactory solution. My goal is very simple I want
to be able to do this in GWT:
<html>
<form>
<input type="file" value="Browse" onchange="alert('ALOHA!!');" />
</form>
<html>
I want to be able to react to a change in the text box holding the
file name. I am looking for a solution other than simply using HTML or
using a form handler to submit.
One problem is that FileUpload is not a SourcesChangesEvents so there
is no way for me to register a change listener with a FileUpload, so I
tried doing the following (using onBrowserEvents)
/**
* Example of on change event with file Upload.
* @author me
*/
public class FileUploadApplication implements EntryPoint
{
public void onModuleLoad()
{
final FormPanel form = new FormPanel();
final FileUpload upload = new MyFileUpload();
form.add(upload);
DOM.setEventListener(upload.getElement(), upload);
RootPanel.get().add(form);
}
private class MyFileUpload extends FileUpload
{
protected void onLoad()
{
super.onLoad();
Window.alert("on load");
}
public void onBrowserEvent(Event event)
{
Window.alert("on browse");
}
}
}
When I open my HTML page in any mode I do get the alert that on load
occurred (no brainer) but not sure why the onBrowserEvent did not get
call I am sure I am missing the concept and onBrowseEvent might not be
what is going on, I try changing the text box of my FileUpload but
with no luck,
I am a beginner at GWT so any help on this will be appreciated,
Have a nice new year.