Test.java
package cyh.test.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.core.Ext;
import com.gwtext.client.core.ExtElement;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.MessageBox;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.form.FormPanel;
import com.gwtext.client.widgets.form.TextField;
import com.gwtext.client.widgets.form.VType;
import com.gwtext.client.widgets.layout.HorizontalLayout;
public class Test implements EntryPoint {
public void onModuleLoad() {
createComponents();
}
private void createComponents() {
ExtElement main = Ext.get("main");
final FormPanel frm = new FormPanel();
frm.setDraggable(true);
frm.setWidth(300);
frm.setTitle("用户注册");
frm.setPaddings(25);
TextField txtUsername = new TextField("用户名", "username");
TextField txtPassword = new TextField("密码", "password");
TextField txtEmail = new TextField("邮箱", "email");
TextField txtPhone = new TextField("电话", "phone");
txtUsername.setRegex("^[a-zA-Z]*$");
txtUsername.setRegexText("用户名必须为字母!");
txtUsername.setAllowBlank(false);
txtPassword.setPassword(true);
txtPassword.setRegex("^[a-zA-Z]*$");
txtPassword.setRegexText("密码必须为字母!");
txtPassword.setAllowBlank(false);
txtEmail.setVtype(VType.EMAIL);
txtEmail.setVtypeText("请输入合法的邮箱地址!");
txtEmail.setAllowBlank(false);
txtPhone.setRegex("^\\d*$");
txtPhone.setRegexText("电话必须为数字!");
txtPhone.setAllowBlank(false);
frm.add(txtUsername);
frm.add(txtPassword);
frm.add(txtEmail);
frm.add(txtPhone);
Panel buttonPanel = new Panel();
buttonPanel.setLayout(new HorizontalLayout(10));
Button btnSave = new Button("保存");
btnSave.addListener(new ButtonListenerAdapter() {
@Override
public void onClick(Button button, EventObject e) {
if (frm.getForm().isValid()) {
MessageBox.alert("成功", "信息提交成功!");
} else {
MessageBox.alert("错误", "请验证输入的信息是否正确!");
}
}
});
Button btnClear = new Button("取消");
btnClear.addListener(new ButtonListenerAdapter() {
public void onClick(Button button, EventObject e) {
MessageBox.alert("取消", "注册信息保存失败!");
}
});
buttonPanel.add(btnSave);
buttonPanel.add(btnClear);
frm.add(buttonPanel);
if (main != null) {
frm.setApplyTo(main.getDOM());
frm.render("");
} else {
RootPanel.get().add(frm);
}
}
}
Test.gwt.xml
<module>
<inherits name='com.google.gwt.user.User'/>
<inherits name="com.gwtext.GwtExt"/>
<entry-point class='cyh.test.client.Test'/>
<stylesheet src='js/resources/css/ext-all.css'/>
<script src="js/adapter/ext/ext-base.js"></script>
<script src="js/ext-all.js"></script>
</module>
Test.html
<html> <head> <title>Wrapper HTML for Test</title> </head> <body> <script type="text/javascript" language="javascript" src="cyh.test.Test.nocache.js"></script> <div id="main"></div> </body> </html>
lib有
gwtext.jar
gwt-servlet.jar
gwt-user.jar
问题补充:
问题在附件图片中
问题补充:
这个问题搞了两天了
做了N个都不行,一直是这样的错
郁闷啊!
我的源码,大侠们看看,到低错在哪儿?谢谢!