При компилирование следующего класса
| Код | package com.google.gwt.sample.testwork.client;
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.ui.*; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.ServiceDefTarget; import com.google.gwt.user.client.rpc.AsyncCallback; import java.util.ArrayList;
/** * Entry point classes define <code>onModuleLoad()</code>. */ public class TestWork implements EntryPoint {
private VerticalPanel mainPanel = new VerticalPanel(); private FlexTable peopleFlexTable = new FlexTable(); private HorizontalPanel addPanel = new HorizontalPanel(); private TextBox nameSymbolTextBox = new TextBox(); private TextBox sexondnameSymbolTextBox = new TextBox(); private TextBox phonenumberSymbolTextBox = new TextBox(); private TextBox dateSymbolTextBox = new TextBox(); private Button addButton = new Button("Add"); private User[] people; private String names;
public void callForCustomService() { CustomServiceAsync customService = (CustomServiceAsync) GWT.create(CustomService.class); ServiceDefTarget target = (ServiceDefTarget) customService; String relativeUrl = GWT.getModuleBaseURL() + "tbl1"; target.setServiceEntryPoint(relativeUrl); // создаём callback AsyncCallback callback = new AsyncCallback() { public void onSuccess(User[] result) { // радуемся people = new User[result.length]; people = result; }
public void onFailure(Throwable caught) { // страдаем GWT.log("Error ", caught); caught.printStackTrace(); } };
// Делаем вызов нашего сервиса. Вызов будет асинхронный - программа продолжится сразу, // а когда придёт ответ вызовется callback try{ customService.myMethod(names,callback); } catch (Exception e){} } /** * This is the entry point method. */ public void onModuleLoad() { // Настраиваем заголовок таблицы цен peopleFlexTable.setText(0, 0, "Name"); peopleFlexTable.setText(0, 1, "SexondName"); peopleFlexTable.setText(0, 2, "Phone Number"); peopleFlexTable.setText(0, 3, "Date of birthday"); peopleFlexTable.setText(0, 4, "Delete");
callForCustomService();
for(int i=0;i<people.length;i++){ peopleFlexTable.setText(i+1,0,people[i].getName() ); peopleFlexTable.setText(i+1,1,people[i].getSexondname() ); peopleFlexTable.setText(i+1,2,people[i].getPhonenumber() ); peopleFlexTable.setText(i+1,3,people[i].getDate() ); }
//реакция на желчок мыши addButton.addClickListener(new ClickListener() { public void onClick(Widget sender){ checkRow(); addRow(); } }); // Панель добавления новой акции addPanel.add(nameSymbolTextBox); addPanel.add(sexondnameSymbolTextBox); addPanel.add(phonenumberSymbolTextBox); addPanel.add(dateSymbolTextBox); addPanel.add(addButton); // Главная панель mainPanel.add(peopleFlexTable); mainPanel.add(addPanel); // Добавляем главную панель к HTML элементу с ID "stockList" RootPanel.get("dataBase").add(mainPanel); // Переводим фокус на текстовое поле nameSymbolTextBox.setFocus(true); } private void checkRow(){ final String symbolname = nameSymbolTextBox.getText().toUpperCase().trim(); nameSymbolTextBox.setFocus(true); // symbol must be between 1 and 10 chars that are numbers, letters, or dots if (!symbolname.matches("^[0-9a-zA-Z\\.]{1,10}$")) { Window.alert("'" + symbolname + "' is not a valid symbol."); nameSymbolTextBox.selectAll(); return; } nameSymbolTextBox.setText("");
final String symbolsexondname = sexondnameSymbolTextBox.getText().toUpperCase().trim(); sexondnameSymbolTextBox.setFocus(true); // symbol must be between 1 and 10 chars that are numbers, letters, or dots if (!symbolsexondname.matches("^[0-9a-zA-Z\\.]{1,10}$")) { Window.alert("'" + symbolsexondname + "' is not a valid symbol."); sexondnameSymbolTextBox.selectAll(); return; } sexondnameSymbolTextBox.setText("");
final String symbolphonenumber = phonenumberSymbolTextBox.getText().toUpperCase().trim(); phonenumberSymbolTextBox.setFocus(true); // symbol must be between 1 and 10 chars that are numbers, letters, or dots if (!symbolphonenumber.matches("^[0-9a-zA-Z\\.]{1,10}$")) { Window.alert("'" + symbolphonenumber + "' is not a valid symbol."); phonenumberSymbolTextBox.selectAll(); return; } phonenumberSymbolTextBox.setText("");
final String symboldate = dateSymbolTextBox.getText().toUpperCase().trim(); dateSymbolTextBox.setFocus(true); // symbol must be between 1 and 10 chars that are numbers, letters, or dots if (!symboldate.matches("^[0-9a-zA-Z\\.]{1,10}$")) { Window.alert("'" + symboldate + "' is not a valid symbol."); dateSymbolTextBox.selectAll(); return; } dateSymbolTextBox.setText("");
// now we need to add the stock to the list... }
public void addRow(){
}
public void addRow(String name,String sexondname,String Phonenumber,String dateofbirthday){
} }
|
Выдает ошибку
| Код | Line 33: The type new AsyncCallback(){} must implement the inherited abstract method AsyncCallback.onSuccess(Object)
|
Хотя класс юзеров у меня серилезованый :
| Код | package com.google.gwt.sample.testwork.client; import com.google.gwt.user.client.rpc.IsSerializable;
/** * Created by IntelliJ IDEA. * User: toxic * Date: 07.02.2009 * Time: 13:45:17 * To change this template use File | Settings | File Templates. */ public class User implements IsSerializable {
private String name; private String sexondname; private String phonenumber; private String date;
/*public User (String name,String sexondname,String phonenumber,String date){ this.name = name; this.sexondname=sexondname; this.phonenumber=phonenumber; this.date=date; } */
public String getName(){ return this.name; }
public String getSexondname(){ return this.sexondname; }
public String getPhonenumber(){ return this.phonenumber; }
public String getDate(){ return this.date; }
public void setName(String name){ this.name=name; }
public void setSexondname(String sexondname){ this.sexondname=sexondname; }
public void setPhonenumber(String phonenumber){ this.phonenumber=phonenumber; }
public void setDate(String date){ this.date=date; } }
|
|