PDA

View Full Version : Why window popup is open when FormPanel is submitted?



yakamax
11 Nov 2009, 2:55 AM
I have a form panel :


FormPanel panelPanel = new FormPanel();
panelPanel.setFrame(false);
panelPanel.setHeaderVisible(false);
panelPanel.setHeading("Upload xml config");
panelPanel.setSize(300, -1);
panelPanel.setLabelAlign(LabelAlign.TOP);
panelPanel.setButtonAlign(HorizontalAlignment.CENTER);
panelPanel.setMethod(Method.POST);
panelPanel.setAction(GWT.getModuleBaseURL() + "MyFormHandler");


with one field attached :


final TextField<String> name = new TextField<String>();
file.setFieldLabel("Name");
panelPanel.add(file, formData);


I perform a submit :


panelPanel.submit();



When submit is perfomed :
In Hosted Mode, an Hosted Mode window is opened.
In Firefox, no window is open : OK
In Internet Explorer (7 et 8), an Internet Explorer window is opened.

So my problem is :
In Hosted Mode and Internet Explorer (Hosted Mode is based on IE), my Listener is not handled :



panelPanel.addListener(Events.Submit, new Listener<FormEvent>() {
...
}


So why window popup is open when FormPanel is submitted in Hosted Mode and Internet Explorer? (:|

Thank you all,
Max

micgala
11 Nov 2009, 3:07 AM
Hi.

This will be fixed in 2.1 (it is already fixed for subscribers).
You can take a look in my signature. There you will find a thread with a solution for you.

Regards,
Michel.

yakamax
11 Nov 2009, 3:48 AM
Perfect! Thank you.

http://www.extjs.com/forum/showthrea...110#post394110 (http://www.extjs.com/forum/showthread.php?p=394110#post394110)

My Full Fixed class (FixedFormPanel.java):



package com.toto.client.widget;

import com.extjs.gxt.ui.client.core.XDOM;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.impl.FormPanelImpl;

public class FixedFormPanel extends FormPanel {

@Override
protected void onAttach() {
super.onAttach();
Element iFrame = getIFrameElement();
Element fixedIFrame = createFixedFrame();

FormPanelImpl impl = getImpl();
impl.unhookEvents(iFrame, getLayoutTarget().dom);
XDOM.getBody().removeChild(iFrame);

XDOM.getBody().appendChild(fixedIFrame);
impl.hookEvents(fixedIFrame, getLayoutTarget().dom, this);

setIFrameElement(fixedIFrame);
}

private Element createFixedFrame() {
Element dummy = DOM.createDiv();
DOM.setInnerHTML(dummy, "<iframe src=\"javascript:''\" name='" + getFrameName()
+ "' style='position:absolute;width:0;height:0;border:0'>");

return DOM.getFirstChild(dummy);
}

private native String getFrameName() /*-{
return this.@com.extjs.gxt.ui.client.widget.form.FormPanel::frameName;
}-*/;

private native Element getIFrameElement() /*-{
return this.@com.extjs.gxt.ui.client.widget.form.FormPanel::iframe;
}-*/;

private native void setIFrameElement(Element fixedIFrame) /*-{
this.@com.extjs.gxt.ui.client.widget.form.FormPanel::iframe = fixedIFrame;
}-*/;

private native FormPanelImpl getImpl() /*-{
return @com.extjs.gxt.ui.client.widget.form.FormPanel::impl;
}-*/;

}


So use it like that :



FormPanel panelPanel = new FixedFormPanel();


Thanks :D