# 2
Thank you for you response. In fact I want a dynamically generated data table (such as the example "Dynamically populate datatable" at the bottom of the page you gave). Here is an excerpt of my code :
#### CODE
//Create the Table Dynamically
Table table = new Table();
table.setId("table1");
table.setTitle(tableConfig.getLibelle());
table.setPaginateButton(true);
table.setPaginationControls(true);
// Create the Table Row group dynamically
TableRowGroup rowGroup = new TableRowGroup();
rowGroup.setId("rowGroup1");
rowGroup.setSourceVar("currentRow");
rowGroup.setValueBinding("sourceData", getApplication().
createValueBinding("#{TableConfigPage.dynamiqueTableDataProvider}"));
rowGroup.setRows(10);
// Add the table row group to the table as a child
table.getChildren().add(rowGroup);
//Iterate over the columns
Iterator<ColumnConfig> colonnes = tableConfig.getColonnes().iterator();
while(colonnes.hasNext()){
ColumnConfig c = colonnes.next();
// Create the table Column
TableColumn tableColumn1 = new TableColumn();
tableColumn1.setId("tableColumn"+c.getName());
tableColumn1.setHeaderText(c.getLibelle());
tableColumn1.setVisible(c.isVisible());
// Add the table Column to the table row group
rowGroup.getChildren().add(tableColumn1);
// Create the Static text and set its value as TRIPID
if(c.getType().equalsIgnoreCase("boolean")){
String ref = "";
if(c.getTableRefObject() == null){
ref = c.getName();
}else{
ref = c.getTableRefObject().getDisplayColumn();
}
tableColumn1.setSort(ref);
Checkbox checkBox1 = new Checkbox();
checkBox1.setValueBinding("selected", getApplication().
createValueBinding("#{currentRow.value['"+ref+"']!='0'}"));
checkBox1.setValueBinding("disabled", getApplication().
createValueBinding("#{currentRow.value['"+key+"'] ne SessionBean1.modifiableRow}"));
// Add the CheckBox to the table column1
tableColumn1.getChildren().add(checkBox1);
}else if(c.getType().equalsIgnoreCase("DropDown") && c.getTableRefObject() != null){
String ref = c.getName();
DropDown dropDown1 = new DropDown();
ConnectionManager cm = WebConnectionManager.get();
PreparedStatement ps = cm.getConnection().prepareStatement(c.getReferenceSelectRequete());
ResultSet rs = ps.executeQuery();
ArrayList<Option> options = new ArrayList();
while(rs.next()){
options.add(new Option(rs.getBigDecimal(1), rs.getString(2)));
}
if(options.size() > 0){
Option[] optionsArray = new Option[options.size()];
optionsArray = options.toArray(optionsArray);
dropDown1.setItems(optionsArray);
}
dropDown1.setValueBinding("selected", getApplication().
createValueBinding("#{currentRow.value['"+ref+"']}"));
dropDown1.setValueBinding("disabled", getApplication().
createValueBinding("#{currentRow.value['"+key+"'] ne SessionBean1.modifiableRow}"));
// Add the DropDown to the table column1
tableColumn1.getChildren().add(dropDown1);
//dropDown1.setDisabled(true);
}else{
String ref = "";
if(c.getTableRefObject() == null){
ref = c.getName();
}else{
ref = c.getTableRefObject().getDisplayColumn();
}
TextField textField1 = new TextField();
//ValueExpression ve = getApplication().getExpressionFactory().createValueExpression(getFacesContext().getELContext(),"#{currentRow.value['"+ref+"']}", String.class);
//textField1.setValueExpression("text", ve);
textField1.setValueBinding("text", getApplication().
createValueBinding("#{currentRow.value['"+ref+"']}"));
textField1.setValueBinding("disabled", getApplication().
createValueBinding("#{currentRow.value['"+key+"'] ne SessionBean1.modifiableRow}"));
//textField1.setDisabled(true);
// Add the TextField to the table column1
tableColumn1.getChildren().add(textField1);
}
}
// Create the table Column
TableColumn modifierTableColumn = new TableColumn();
modifierTableColumn.setId("modifierColumn");
modifierTableColumn.setHeaderText("");
modifierTableColumn.setAlign("center");
// Add the table Column to the table row group
rowGroup.getChildren().add(modifierTableColumn);
// Create the Button and set its value as TRIPID
Button modifierButton = new Button();
modifierButton.setValueBinding("text", getApplication().
createValueBinding("#{currentRow.value['"+key+"'] ne SessionBean1.modifiableRow ? 'Modifier' : 'Sauver'}"));
modifierButton.setAction(getApplication().createMethodBinding("#{TableConfigPage.modifierButton_action}", null));
modifierButton.setId("modifierButton");
modifierTableColumn.getChildren().add(modifierButton);
// Create the table Column
TableColumn supprimerTableColumn = new TableColumn();
supprimerTableColumn.setId("supprimerColumn");
supprimerTableColumn.setHeaderText("");
supprimerTableColumn.setAlign("center");
// Add the table Column to the table row group
rowGroup.getChildren().add(supprimerTableColumn);
// Create the Button and set its value as TRIPID
Button supprimerButton = new Button();
supprimerButton.setValueBinding("text", getApplication().
createValueBinding("#{currentRow.value['"+key+"'] ne SessionBean1.modifiableRow ? 'Supprimer' : 'Annuler'}"));
supprimerButton.setAction(getApplication().createMethodBinding("#{TableConfigPage.supprimerButton_action}", null));
supprimerButton.setId("supprimerButton");
supprimerTableColumn.getChildren().add(supprimerButton);
if(rowAdded){
rowAdded = false;
}
tableGridPanel.getChildren().add(table);
#### CODE
The data provider is configured dynamically as well, based on an XML file which contains the definition of the different tables to be used. My problem is that the user should be able to edit the data, select a row in the dropdowns and so on, but during the postback the new data is not propagated to the data provider.
I hope this will clarify a bit my problem, I have not found anything on the web which could help me with this, so any help would be appreciated.
Thank you.