I have a problem with FileItem and UploadItem:
in order to enable an (upload) button, I need to know, when the user has selected a file.
I added a changed handler to my items, but it never fires.
Following is some test code, which illustrates this:
Is there any other flag that I need to set on the form or field for the handler to fire?
I'm using GWT 2.0.4 and SmartGWT 2.3
in order to enable an (upload) button, I need to know, when the user has selected a file.
I added a changed handler to my items, but it never fires.
Following is some test code, which illustrates this:
Code:
package org.yournamehere.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.ButtonItem; import com.smartgwt.client.widgets.form.fields.FileItem; import com.smartgwt.client.widgets.form.fields.SubmitItem; import com.smartgwt.client.widgets.form.fields.UploadItem; import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; import com.smartgwt.client.widgets.form.fields.events.ClickEvent; import com.smartgwt.client.widgets.form.fields.events.ClickHandler; public class MainEntryPoint implements EntryPoint { private DynamicForm form = new DynamicForm(); private FileItem fileName = new FileItem("fi", "Select"); private SubmitItem doit = new SubmitItem("upload", "Upload"); private ButtonItem save = new ButtonItem("save", "Save"); public void onModuleLoad() { doit.setDisabled(true); save.setDisabled(true); fileName.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { System.err.println("FI Changed"); save.setDisabled(false); } }); UploadItem uli = new UploadItem("UploadItem", "Select file"); uli.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { System.err.println("ULI Changed"); doit.setDisabled(false); } }); save.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { System.err.println(fileName.getDataPath()+" "+fileName.getValue()); form.saveData(); } }); form.setCanSubmit(true); form.setAction("/upload"); form.setItems(uli, doit, fileName, save); form.draw(); } }
I'm using GWT 2.0.4 and SmartGWT 2.3
Comment