Every time a new String is generated but the List is having null value for it.
<h:dataTable value="#{add.periods}" var="prd">
<h:column><h:inputText value="#{prd}" /></h:column>
</h:dataTable>
<h:commandButton value="add" action="#{add.addList}" />
<h:commandButton value="submit" action="#{add.submit}" />
</h:dataTable>
Entity AddPeriods: object add
private List<String> periods = new ArrayList<String>();
@ElementCollection
public List<String> getPeriods()
{
return periods;
}
public void setPeriods(List<String> periods)
{
this.periods=periods;
}
public void addList()
{
periods.add(new String());
}
public void submit()
{
System.out.println("periods..................................: " +periods);
}
Message on Console:After 2 times addition
periods..................................: [, ]