I’m new user of vaadin, I’m working on a web application so i need your help please !!
I have MySQL database
I succeeded to connect to my database , i have text fields to enter data that will be added to the database , this step is achieved !!
My Question is how can i get data from my database (table named Ticket) to show it in a Table in my application , and i want to show the items of every column in a row in text fields
I tried with beanitemcontainer and it doesn’t work for me !!!
you can make your Table editable with Table.setEditable(true); A FieldFactory makes your TextFields. You can also overwrite the FieldFactory, to make special Columns like a Select. Another way is to generate own columns.
I am doing something similar and tried this out. I made an own class with extends Table and add the SQLContainer as a Datasource:
class myTable extends Table {
}
myTable t = new myTable();
t.addContainerDatasource(SQLContainer);
Then I added generated Coloums to it.
class myTable extends Table {
public myTable() {
addGeneratedColumn("yourColumn", new ColumnGenerator() {
@Override
public Component generateCell(Table source, Object itemId, Object columnId) {
if (getItem(itemId).getItemProperty("youtColumn").getValue() != null) { //If the Value from the Table is not == null
//Make a TextField
TextField t = new TextField("");
//Bind the Textfield to the Data from yout Table
t.setPropertyDataSource(SQLContainer.getItem(itemId).getItemProperty("yourColumn"));
t.setImmediate(true);
return t;
}
}
Hope you understand what I mean. But the Problem I have with this (I will ask in a new Thread), if I change the Data in the Textfield, my SQLContainer also changes ist, but I cannot write it into the Database.
Thank you for your answer, but it doesn’t work with my case
I found a solution in the vaadin’s tuto which enables me to show the data (of the selected row in a table) in a footer with possibility of editing that data.
I tested that and it works with dummy data ,
now i want to import data from my table in the Mysql DB and to put it in the table of my application
I’m really pressed with time, ready for your help !!