Q:

jsf submit dynamically generated table with multiple 

I have a dynamically generated table with dynamically generated <h:inputText/> fields.
My question is how can I post all of my <h:inputText/> to a backing bean.
This is how my table looks like:
<table class="table table-bordered table-hover">
<ui:repeat value="#{mainWorkerMB.showAvailableEventDetailTypes()}" var="eventDetail">
<tr>
<td>
<h:outputText value="#{eventDetail.edtyName}"></h:outputText>
</td>
<td>
h:inputText styleClass="form-control" value="#{mainWorkerMB.edtyId}" />
</td>
</tr>
</ui:repeat>
</table>    

I know by default, I have to create fields in my backing bean, with getters and setters, but now I don't know how many field will I have.
Sorry, for that but i don't even start to solve it.
Do you have any idea? Help me please.

A:

Yes you can, you need to iterate over a collection to generate the table and input fields per object, this is an example:
In this case, the objects in collection are instances of Person:
public class Person {

    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Name: " + name + ", age: " + age;
    }
}

In your managed bean (in this case i'm using CDI) you need to populate the collection:
@Named
@ViewScoped
public class SampleBean implements Serializable {

    private static final long serialVersionUID = 1L;

    private List<Person> dataSample;

    @PostConstruct
    private void init() {
        dataSample = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            Person person = new Person();
            dataSample.add(person);
        }
    }

    public void process() {
        dataSample.forEach(System.out::println);
    }

    public List<Person> getDataSample() {
        return dataSample;
    }
}

And use it in the JSF view file:
<h:form>

        <table class="table table-bordered table-hover">
            <ui:repeat value="#{sampleBean.dataSample}" var="person">
                <tr>
                    <td>Name:</td>
                    <td><h:inputText styleClass="form-control" value="#{person.name}" /></td>
                    <td>Age:</td>
                    <td><h:inputText styleClass="form-control" value="#{person.age}" /></td>
                </tr>
            </ui:repeat>
        </table>

        <h:commandButton actionListener="#{sampleBean.process()}" value="Send!" />

</h:form>

This will render a table with 2 columns and 5 rows, and 2 inputs per row (1 for 'name' and other for 'age')
I have submitted the values:
'Peter' and '23'
'Samuel' and '30'
'Mary' and '19'
'Betty' and '22'
'Sofi' and '28'
And the results in console were:
Name: Peter, age: 23
Name: Samuel, age: 30
Name: Mary, age: 19
Name: Betty, age: 22
Name: Sofi, age: 28

