I'm using gwt sdk 2.6.0. My problem is that when I only use two fields being "name" and "address" everything works ok. But when I add a third field "año" my code fails. Compiler says "constructor contact is undefined".
public class Tablila extends VerticalPanel {
private static class Contact {
private final String name;
private final String address;
private final String año;
public Contact(String nombre, String address, String año) {
this.name = nombre;
this.address = address;
this.año = año;
}
}
private static List<Contact> CONTACTS = Arrays.asList(new Contact("ruben",
"av.lomas", "15"), new Contact("jos", "av.juliet", "35"));
public Tablila() {
setUp();
}
public void setUp() {
CellTable<Contact> table = new CellTable<Contact>();
TextColumn<Contact> nameColumn = new TextColumn<Contact>() {
@Override
public String getValue(Contact contact) {
return contact.name;
}
};
table.addColumn(nameColumn, "Name");
TextColumn<Contact> addressColumn = new TextColumn<Contact>() {
@Override
public String getValue(Contact contact) {
return contact.address;
}
};
table.addColumn(addressColumn, "address");
TextColumn<Contact> añoColumn = new TextColumn<Contact>() {
@Override
public String getValue(Contact contact) {
return contact.año;
}
};
table.addColumn(añoColumn, "Año");
table.setRowCount(CONTACTS.size(), true);
// Push the data into the widget.
table.setRowData(0, CONTACTS);
this.add(table);
this.getElement().getStyle().setMargin(8, Unit.PX);
}
}
This means you cannot construct your Contact object by passing three values to it.
I see that you have such constructor in the code that you pasted, but in this case you should get an error when passing 2 values.
I compiled your code, and there were no errors. Did you save the changes to your code?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.