Hi.
I have a table that gets data from DataBase
Here is the PersonList class where I get datas:
package com.example.table;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
import com.vaadin.ui.Window;
public class PersonList extends Table {
Window mainWindow = new Window("Mysql1 Application");
String url = "jdbc:mysql://localhost:3306/officemanager";
Statement statement = null;
ResultSet rs = null;
public PersonList() {
try {
Class.forName("com.mysql.jdbc.Driver");
java.sql.Connection con = DriverManager.getConnection(url,"manvel", "manvel19831987233");
statement = con.createStatement();
rs = statement.executeQuery("SELECT * FROM people");
addContainerProperty("First Name", String.class, null);
addContainerProperty("Last Name", String.class, null);
while (rs.next()){
String name = rs.getString("name");
String surname = rs.getString("surname");
addItem(new Object[] {name, surname}, null);
setSizeFull();
System.out.println(name);
}
rs.close();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
} catch (SQLException e) {
// TODO Auto-generated catch block
}
}
}
And here is my main class where I call that table:
package com.example.table;
import com.vaadin.Application;
import com.vaadin.ui.*;
public class TableApplication extends Application {
public PersonList table = new PersonList();
@Override
public void init() {
Window mainWindow = new Window("Table Application");
table.setSelectable(true);
table.setImmediate(true);
mainWindow.addComponent(table);
setMainWindow(mainWindow);
}
}
Now I need to make table editable by double clicking on current item. And save changes to server… please help me with this question…