PDA

View Full Version : Compile Error with GXT2.0 with GWT 1.6.X



everhow@163.com
23 Dec 2009, 6:48 PM
Dear All,

I've suffered a very strange problem when I compile the gxt app.

the following is my code.

please give me some help~~:)



package com.haiker.webapp.client;

import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.util.Margins;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
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.button.Button;
import com.extjs.gxt.ui.client.widget.custom.Portal;
import com.extjs.gxt.ui.client.widget.custom.Portlet;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.form.CheckBoxGroup;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.RadioGroup;
import com.extjs.gxt.ui.client.widget.form.SimpleComboBox;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.Validator;
import com.extjs.gxt.ui.client.widget.layout.AccordionLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class Begingxt implements EntryPoint {

@Override
public void onModuleLoad() {
Viewport viewport = new Viewport();
BorderLayout bl = new BorderLayout();
viewport.setLayout(bl);

LayoutContainer north = new LayoutContainer();
north.addText("North:Application Title");

ContentPanel west = new ContentPanel();
west.setLayout(new AccordionLayout());
west.setHeading("West:Navigation");

ContentPanel cp = new ContentPanel();
cp.setHeading("Sent Items");
west.add(cp);

cp = new ContentPanel();
cp.setHeading("Sent Items1");
west.add(cp);

TabPanel center = new TabPanel();

TabItem item = new TabItem("Home");
item.setWidth("100%");
item.add(createPortal());
center.add(item);

item = new TabItem("Favorite");
item.add(createFormPanel());
item.setClosable(true);
item.setIconStyle("tree-folder");
center.add(item);

BorderLayoutData northData = new BorderLayoutData(LayoutRegion.NORTH, 20);
northData.setMargins(new Margins(5, 5, 0, 5));

BorderLayoutData westData = new BorderLayoutData(LayoutRegion.WEST, 240);
westData.setCollapsible(true);
westData.setFloatable(true);
westData.setSplit(true);
westData.setMargins(new Margins(5, 0, 5, 5));

BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
centerData.setMargins(new Margins(5));

viewport.add(north, northData);
viewport.add(west, westData);
viewport.add(center, centerData);

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

public FormPanel createFormPanel() {
final FormPanel fp = new FormPanel();

fp.setHeading("Personal Information");
fp.setFrame(true);

TextField fn = new TextField();
fn.setFieldLabel("First name");
fn.setEmptyText("Must not be blank");
fn.setAllowBlank(true);
fp.add(fn);

TextField ln = new TextField();
ln.setFieldLabel("Last name");
fp.add(ln);

TextField em = new TextField();
em.setFieldLabel("Email");
em.setAllowBlank(false);
final String emailReg = "[A-Z0-9._%+-]+\\.[A-Z]{2,4}";
final String errMsg = "Not a valid email address!";
em.setValidator(new Validator() {
@Override
public String validate(Field<?> field, String value) {
if(!value.toUpperCase().matches(emailReg)) {
return errMsg;
}
return null;
}
});

fp.add(em, new FormData("80%"));
TextArea ad = new TextArea();
ad.setFieldLabel("Address");
fp.add(ad, new FormData(270, 100));

Radio radio = new Radio();
radio.setName("radio");
radio.setBoxLabel("Male");
radio.setValue(true);

Radio radio2 = new Radio();
radio2.setName("radio");
radio2.setBoxLabel("Female");

RadioGroup radioGroup = new RadioGroup("test");
radioGroup.setFieldLabel("Sex");
radioGroup.add(radio);
radioGroup.add(radio2);
fp.add(radioGroup);

SimpleComboBox<String> combo;
combo = new SimpleComboBox<String>();
combo.add("Small");
combo.add("Medium");
combo.add("Large");
combo.add("Xtra Large");
combo.setFieldLabel("Shirt Size");
combo.setEditable(false);
combo.setSimpleValue("Large");
fp.add(combo);

CheckBox check1 = new CheckBox();
check1.setBoxLabel("Brochures");

CheckBox check2 = new CheckBox();
check2.setBoxLabel("Events");
check2.setValue(true);

CheckBox check3 = new CheckBox();
check3.setBoxLabel("Announcements");

CheckBoxGroup checkGroup = new CheckBoxGroup();
checkGroup.setFieldLabel("Subscribe");
checkGroup.add(check1);
checkGroup.add(check2);
checkGroup.add(check3);
fp.add(checkGroup);

Button save = new Button("Save");
save.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
MessageBox.alert("title", "hello", null);
fp.isValid();
}
});

fp.getButtonBar().add(save);
fp.getButtonBar().add(new Button("Cancel"));

fp.setWidth(400);
fp.setFieldWidth(270);
fp.setPosition(10, 10);
fp.layout();

return fp;
}

protected Portal createPortal() {
Portal portal = new Portal(2);

portal.setSize("100%", "100%");
portal.setColumnWidth(0, .5);
portal.setColumnWidth(1, .5);

Portlet pl;

for(int i = 0; i < 5; i++) {
pl = new Portlet();
pl.setHeading("Portlet" + i);

pl.addText("text" + i);
portal.add(pl, i%2);
}

return portal;
}
}