Ich habe zwei Klassen in meinem Vaadin 7 Projekt. Ich habe Schwierigkeiten, die Tabelle in meiner Hauptbenutzeroberflächenklasse anzuzeigen. MyTable.java und DocUI.java. Wie kann ich meinen Tisch in DocUI.java anzeigen/anzeigen lassen, wenn ich localhost: 8080 lade?Wie zeige ich eine Tabelle in Vaadin an?
public class MyTable extends DocUI{
public MyTable() {
Table table = new Table("The Brightest Stars");
table.addContainerProperty("Name", String.class, null);
table.addContainerProperty("Mag", Float.class, null);
Object newItemId = table.addItem();
Item row1 = table.getItem(newItemId);
row1.getItemProperty("Name").setValue("Sirius");
row1.getItemProperty("Mag").setValue(-1.46f);
table.addItem(new Object[] {"Canopus", -0.72f}, 2);
table.addItem(new Object[] {"Arcturus", -0.04f}, 3);
table.addItem(new Object[] {"Alpha Centauri", -0.04f}, 4);
table.setPageLength(table.size());
}
}
public class DocUI extends UI {
// new addition 4/28
public String[] userString = { "[email protected]",
"[email protected]", "[email protected]",
"[email protected]", "[email protected]" };
// create combo box
public ComboBox comboBox1 = new ComboBox("Random Combo Box") {
};
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = DocUI.class)
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
Button button = new Button("Click Me");
Button button2 = new Button("I am button 2");
button.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
layout.addComponent(new Label("Thank you for clicking"));
}
});
@SuppressWarnings("deprecation")
FieldGroup form = new FieldGroup();
layout.setSizeFull();
layout.addComponent(button);
layout.addComponent(button2);
addComponent(MyTable.table);
//new addition 4/28
layout.addComponent(comboBox1);
comboBox1.setInputPrompt("Select a value");
comboBox1.addItems("--add new user--", "[email protected]", "[email protected]","[email protected]","[email protected]","[email protected]");
}
}
Ich bin neu mit Java. Ich habe Ihren Code der MyTable.java-Klasse hinzugefügt und die Funktion wird nicht erkannt. "Funktion kann nicht zu einem Typ aufgelöst werden" – PeachesToad
Zuerst müssen Sie Java lernen. MyTable-Methode ist der Konstruktor und getTable ist ein Getter für die Eigenschaftentabelle. Ich möchte keinen fertigen und getesteten Code geben. Sie müssen Ihr eigenes Wissen mitbringen. Probieren Sie es aus und ich versuche Ihnen zu helfen;) – Dominik