0

I would like to have a JSF data table and insert rows (with input fields) into the table as I click a button. In JS one would think of doing something like:

$(document).ready(function(){    
$('#myButton').click(function(){
    document.getElementById('myTable').style.display="block"; //show table
    var table = document.getElementById("myTable"); //get table
    var row = table.insertRow(1); //insert row into table
    var cell1 = row.insertCell(0); //insert into the created row
    var cell2 = row.insertCell(1); //insert into the created row   
    cell1.innerHTML = "<input type='text' value='someValue' readonly='readonly'>";
    cell2.innerHTML = '<textarea rows="1" cols="90" ></textarea>';       
});
});

I am developing a java web application in which one of the screens will have a user click a button to have more input fields. Any suggestion how to do this in maybe primefaces? I am not very conversant with JSF yet. Any help will be appreciated.

  • 2
    Possible duplicate of [Dynamically adding a row to primefaces dataTable](http://stackoverflow.com/questions/9561982/dynamically-adding-a-row-to-primefaces-datatable) – Radouane ROUFID May 19 '17 at 07:46
  • on button clikc a dialog opens to collect the data for the new record. when the user closes this table by the save button (data validation passed) it persists the new record and rerender the datatable. – The Bitman May 19 '17 at 12:14

0 Answers0