PDA

View Full Version : FormPanel fields won't resize



cyChop
6 Jan 2012, 2:30 AM
Hi there!

I have a problem with the use of FormPanels. Actually not all FormPanels, but I can't say the difference between them.

I have two FormPanels in the same LayoutContainer. When I resize the container, the fields of the first one are resized, the second one is not. If I duplicate the first one, both are layouted on resize, so I guess I am missing something in panels initialization, but I can't tell what.

Also, all FormPanels are resized, only inner fields are not (used the border to make sure).

I have other examples of FormPanels in a LayoutContainer whose fields won't resize, but their initilizations look the same.

So does somebody have a clue about what could hinder a FormPanel's fields dynamic resizing? Would it be linked to pre/post-render addition?

Thanks in advance,

-----
Not sure code will help, but just in case, here is some sample from first case.

Container is initialized as follows:


// extends LayoutContainer
// basically a form with a combobox to choose displayed form
// create a combobox displaying the available screens
this.setLayout(new RowLayout(Orientation.VERTICAL));
ComboBox<ScreenEntry> formList = new ComboBox<ScreenEntry>();
ListStore<ScreenEntry> formStore = new ListStore<ScreenEntry>();
formStore.add(this.getScreens());
formList.setStore(formStore);
formList.setFieldLabel(getComboLabel());
formList.setDisplayField(ScreenEntry.FIELD_LABEL);
formList.setAllowBlank(false);
formList.setForceSelection(true);
formList.setTriggerAction(TriggerAction.ALL);


FormPanel form = new FormPanel();
form.setHeaderVisible(false);
form.setBodyBorder(false);
form.setLabelSeparator(labels.forms_labels_separator());
form.setLabelAlign(LabelAlign.TOP);
form.add(formList, new FormData("100%"));
// margin is negative at bottom to compensate FormPanel's padding
this.add(form, new RowData(1, -1, new Margins(0, 0, -15, 0)));


final RowData data = new RowData(1, -1, new Margins(0));
formList.addSelectionChangedListener(new SelectionChangedListener<ScreenEntry>() {

// switch form
@Override
public void selectionChanged(SelectionChangedEvent<ScreenEntry> se) {
if (currentScreen != null) {
remove(currentScreen);
}


currentScreen = se.getSelectedItem().getScreen();
add(currentScreen, data);
layout();
currentScreen.resetPanel();
}
});


The second form, that will not resize, is reset as follows:


// extends LayoutContainer
public void resetPanel() {
this.log.debug("resetPanel");


this.removeAll();


this.formPanel = new FormPanel();
this.formPanel.setHeaderVisible(false);
this.formPanel.setBodyBorder(false);
this.formPanel.setButtonAlign(HorizontalAlignment.CENTER);
this.formPanel.setLabelSeparator(this.labels.forms_labels_separator());
this.formPanel.setLabelAlign(LabelAlign.TOP);


for (Field<?> f : getSearchFields()) {
f.addListener(Events.SpecialKey, this.returnSubmitter);
this.formPanel.add(f, this.formData100);
}


// Form buttons
Button searchButton =
new Button(this.labels.forms_search(), this.icons.viewmagMedium(),
new SearchSelectionListener());
searchButton.setScale(ButtonScale.MEDIUM);
FormButtonBinding binding = new FormButtonBinding(formPanel);
binding.addButton(searchButton);
this.formPanel.addButton(searchButton);


Button reinitButton =
new Button(this.labels.forms_reinit_short(), this.icons.cancelMedium(),
new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
ECMSimpleSearchSide.this.formPanel.clear();
}
});
reinitButton.setScale(ButtonScale.MEDIUM);
this.formPanel.addButton(reinitButton);


this.add(formPanel);


if (this.isRendered()) {
this.layout();
}
}


GXT 2.1.1, Web mode, Chromium/FireFox 4+

sven
6 Jan 2012, 3:06 AM
Your formpanel is not sized. You just add it without giving it a layoutdata. This will only work if your parent either has a CardLayout or a FitLayout

cyChop
6 Jan 2012, 5:07 AM
Well, I'm using a RowLayout here, so I guess the LayoutData is mandatory. Borders show that FormPanel is sized, only fields are not (HTML inspection concurs).

As for a FitLayout, I have another example using no LayoutData. FormPanel is sized but not fields.

sven
6 Jan 2012, 5:13 AM
Please provide a fully working testcase implementing EntryPoint that shows your problem. There is something wrong in your layoutchain if it does not get sized.

If you use a RowLayout, you will need to provide a RowData with values != -1 for the width at least.

cyChop
6 Jan 2012, 7:55 AM
Here is a sample. I applied setFrame(true) on FormPanels so that their size will be clear to see.

Thanks for your help, sven.

sven
6 Jan 2012, 8:17 AM
Your SearchForm has no layout set, nor do you set a layoutdata to the FormPanel that you are adding to it.

cyChop
9 Jan 2012, 1:36 AM
You're right, though it does not surprise me. ;) I set a FitLayout to SearchForm and now things works just fine.

Thanks sven! As usual, you were a great help!