PDA

View Full Version : FormPanel & gwt widgets like ListBox


mmiotk
04-24-2008, 11:26 AM
Why I can't add to FormPanel any gwt widgets like ListBox?

FormPanel panel = new FormPanel();
panel.frame = true;
panel.fieldWidth = 300;
panel.labelWidth = 200;
panel.buttonAlign = HorizontalAlignment.CENTER;
panel.setHeading(getPageTitle());
panel.setIconStyle("icon-form");
panel.setWidth(600);
panel.setStyleAttribute("padding", "20");

final ListBox lb = new ListBox();
lb.setWidth("200px");
lb.setVisibleItemCount(1);
lb.addItem("item 1 ");
lb.addItem("item 2 ");
lb.addItem("item 3 ");
panel.add(lb);

final TextBox tb = new TextBox();
tb.setText("xxxx");
panel.add(tb);

But form panel is empy.




(I work with Firefox browser)

darrellmeyer
04-24-2008, 11:44 AM
FormPanel children need to be instances of Field. Can you use ComboBox?

mmiotk
04-24-2008, 02:30 PM
FormPanel children need to be instances of Field. Can you use ComboBox?

Yes, I tried, but how can I set the default value from ComboBox.
I tried:

a) call ComboBox: : select(5)
b) call ComboBox: : setValue("MyItemLabel");
c) call ComboBox: : setValue(new CDCBaseModel("MyItemLabel")); where CDCBaseModel extends BaseModel and overrides hashCode() and equals()

but these variants doesn't give any effects.

Because I had this problem, I tried to use ListBox.

(I work with Firefox browser)

darrellmeyer
04-24-2008, 04:28 PM
There were some bugs in setValue for ComboBox. The fix is in SVN and will go out in beta2.

You should pass an existing record from the store or the text that will match value field of a record in the store.