PDA

View Full Version : valid notification render bug in Tab-FormPanel



gslender
15 Jul 2008, 10:15 PM
Detailed description of the problem
This is a little complex to do - so follow exactly....
When using a Tab-FormPanel, if you have validated fields (like allow blank=false) and you are on any tab, other than the 1st - and you call panel.isValid() the notification icons are on the wrong spot when you go back to the 1st tab.
GXT version
v1.0
Host mode / web mode / both
hosted
Browser and version
IE6
Operating System
Windows XP
Sample code

package com.mycompany.gxt.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

import com.extjs.gxt.ui.client.Events;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.event.WindowEvent;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;

import ext.ux.wizard.client.WizardWindow;

public class TabFormPanelInvalidTest implements EntryPoint {

public void onModuleLoad() {

final FormPanel panel = new FormPanel();
panel.setFrame(false);
panel.setHeaderVisible(false);
panel.setBodyBorder(false);
panel.setButtonAlign(HorizontalAlignment.CENTER);
panel.setLayout(new FitLayout());

TabPanel tabs = new TabPanel();

TabItem personal = new TabItem();
personal.setText("Personal Details");
personal.setLayout(new FormLayout());

TextField<String> name = new TextField<String>();
name.setFieldLabel("First Name");
name.setAllowBlank(false);
personal.add(name);

TextField<String> last = new TextField<String>();
last.setFieldLabel("Last Name");
last.setAllowBlank(false);
personal.add(last);

TextField<String> company = new TextField<String>();
company.setFieldLabel("Company");
personal.add(company);

TextField<String> email = new TextField<String>();
email.setFieldLabel("Email");
personal.add(email);

tabs.add(personal);

TabItem numbers = new TabItem();
numbers.setText("Phone Numbers");
numbers.setLayout(new FormLayout());

TextField<String> home = new TextField<String>();
home.setFieldLabel("Home");
home.setValue("800-555-1212");
numbers.add(home);

TextField<String> business = new TextField<String>();
business.setFieldLabel("Business");
business.setAllowBlank(false);
numbers.add(business);

TextField<String> mobile = new TextField<String>();
mobile.setFieldLabel("Mobile");
mobile.setAllowBlank(false);
numbers.add(mobile);

TextField<String> fax = new TextField<String>();
fax.setFieldLabel("Fax");
numbers.add(fax);

tabs.add(numbers);

panel.add(tabs);
panel.addButton(new Button("Cancel"));
Button submit = new Button("Submit");

SelectionListener<ComponentEvent> listener = new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent be) {
panel.isValid();
}
};
submit.addSelectionListener(listener);
panel.addButton(submit);

panel.setSize(340, 180);

final Viewport vp = new Viewport();
vp.add(panel);

RootPanel.get().add(vp);
}
}