PDA

View Full Version : FormPanel dont hide the "validation message"



fother
19 Jun 2009, 4:59 AM
how to reproduce:

click on the button "validate 1"
click on the "radio 2"


you can see that the validation message dont dissapears when you call the method hide of the field.

code example


public class Explorer implements EntryPoint {

public void onModuleLoad() {

final TabItem tabItem = new TabItem("tab item");

final TextField<String> field1 = new TextField<String>();
field1.setAllowBlank(false);

final SimpleComboBox<String> combo1 = new SimpleComboBox<String>();
combo1.setAllowBlank(false);

final NumberField field2 = new NumberField();
field2.setAllowBlank(false);

final SimpleComboBox<String> combo2 = new SimpleComboBox<String>();
combo2.setAllowBlank(false);

Button validate1 = new Button("validate 1", new SelectionListener<ButtonEvent>() {

@Override
public void componentSelected(ButtonEvent ce) {

field1.validate();
combo1.validate();
field2.validate();
}
});

ToolBar bar = new ToolBar();
bar.add(validate1);

FormPanel panelForm = new FormPanel();
panelForm.add(field1);
panelForm.add(combo1);
panelForm.add(field2);
panelForm.add(combo2, new FormData(400, 20));
panelForm.setTopComponent(bar);

final Radio radio1 = new Radio();
radio1.setBoxLabel("radio 1");
radio1.setValue(true);
radio1.addListener(Events.OnClick, new Listener<FieldEvent>() {

public void handleEvent(FieldEvent be) {

field1.show();
combo1.show();
field2.show();

combo2.hide();

tabItem.layout();
}
});

Radio radio2 = new Radio();
radio2.setBoxLabel("radio 2");
radio2.addListener(Events.OnClick, new Listener<FieldEvent>() {

public void handleEvent(FieldEvent be) {

field1.hide();
combo1.hide();
field2.hide();

combo2.show();

tabItem.layout();
}
});

RadioGroup group = new RadioGroup();
group.add(radio1);
group.add(radio2);

ContentPanel panelRadio = new ContentPanel();
panelRadio.setHeaderVisible(false);
panelRadio.add(group);

tabItem.add(panelRadio);
tabItem.add(panelForm);

TabPanel tabPanel = new TabPanel() {
@Override
protected void onRender(Element target, int index) {

super.onRender(target, index);

radio1.fireEvent(Events.OnClick);
}
};
tabPanel.setSize(600, 300);
tabPanel.add(tabItem);

RootPanel.get().add(tabPanel);

}


tested on hosted mode: win vista

fother
19 Jun 2009, 5:26 AM
add this code too



Button validate2 = new Button("validate 2", new SelectionListener<ButtonEvent>() {

@Override
public void componentSelected(ButtonEvent ce) {

combo2.validate();
}
});

bar.add(validate2);


1- click in the button "validate 2" the validation message will be appears below the trigger button..