PDA

View Full Version : [CLOSED] [1.2.3] FileUploadField auto open dialog



baskor
9 Mar 2009, 9:22 AM
System: OS X 10.5, GWT 1.5.3, GXT 1.2.3, Firefox 3.

I want to create a form panel where users can add as many files (FileUploadField) as they wish, and they do this by clicking on an "add file" button (TextToolItem).

When they click on the "add file" button, I add a FileUploadField to the form, and automatically open the browse window by calling:

uploadField.getFileInput().click();

This works fine in Safari 3 and Internet Explorer 7 but not in Firefox 3. The field is added in Firefox 3, but I can't automatically open the browse window, and I really need this to make the application user friendly.

Here is code that demonstrates the bug:


import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.form.FileUploadField;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.toolbar.TextToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

public class Test implements EntryPoint {

public void onModuleLoad() {

Viewport vp = new Viewport();

final FormPanel formPanel = new FormPanel();
formPanel.setSize(350, 200);

ToolBar toolBar = new ToolBar();
TextToolItem btn = new TextToolItem("Add file");
btn.addSelectionListener(new SelectionListener<ComponentEvent>() {
@Override
public void componentSelected(ComponentEvent ce) {
FileUploadField uploadField = new FileUploadField();
uploadField.setFieldLabel("File");
formPanel.add(uploadField);
formPanel.layout();
uploadField.getFileInput().click();
}
});
toolBar.add(btn);
formPanel.setTopComponent(toolBar);

vp.add(formPanel);
RootPanel.get().add(vp);
}
}

sven
9 Mar 2009, 9:31 AM
Have you read the javadocs for the click method? There is not much we can do about this.