PDA

View Full Version : [2.0] Form data disappearing after el.setXY?



hstang
20 Jul 2009, 10:16 AM
Hi,
I'm trying to refresh some form data using RequestBuilder, then moving the container holding the form panel to the center. However, the newly added form data disappears when I am using RequestBuilder in conjunction with el.setXY() after layout() is called.

This does not occur if I do not use RequestBuilder though. That is, the form data remains on the screen when I statically add the form data.

Anyone knows why? Happens in FF 3.5 with GXT 2.0.



public class Test implements EntryPoint
{
private FormPanel fp = new FormPanel();
private FormContainer fc = new FormContainer();

public void onModuleLoad()
{
RootPanel panel = RootPanel.get();
panel.add(fc);
Button b = new Button("Tryme", new SelectionListener<ButtonEvent>()
{
public void componentSelected(ButtonEvent event)
{
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, "http://www.google.com");
builder.setCallback(new RequestCallback()
{
public void onResponseReceived(Request request, Response response)
{
fp.removeAll();
TextField<String> field = new TextField<String>();
field.setFieldLabel("fieldLabel");
fp.add(field, new FormData("0.7"));
}
public void onError(Request request, Throwable throwable) {}
});
try { builder.send();}
catch (RequestException e) { GWT.log("OH NO", e); }

fp.layout();
Rectangle rectangle = fc.el().getBounds();
fc.el().setXY(rectangle.x + 50, rectangle.y + 50);
}
});
panel.add(b);
}

class FormContainer extends LayoutContainer
{
@Override
protected void onRender(Element parent, int index)
{
super.onRender(parent, index);

BorderLayout layout = new BorderLayout();
setLayout(layout);
setSize(700, 400);

fp.setHeading("Yes");
fp.setBodyBorder(false);
fp.setHeaderVisible(false);
TextField<String> field = new TextField<String>();
field.setFieldLabel("Parameter 3");
TextField<String> field2 = new TextField<String>();
field2.setFieldLabel("Parameter 2");
fp.add(field, new FormData("0.5"));
fp.add(field2, new FormData("0.5"));

ContentPanel p = new ContentPanel();
p.add(fp);
p.setScrollMode(Style.Scroll.AUTOY);
add(p);
}
}
}