jsf - Using <h:dataTable><h:inputText> on a List<String> doesn't update model values -
i've below data table:
<h:datatable var="row" value="#{mybean.listofstrings}"> <h:column> <h:inputtext value="#{row}" /> </h:column> </h:datatable>
which tied list<string>
:
private list<string> listofstrings = new arraylist<string>(); public list<string> getlistofstrings() { return listofstrings; } public void setlistofstrings(list<string> listofstrings) { this.listofstrings = listofstrings; }
when enter value in field , save form not passing value field in list, setting null
, doing wrong here?
the string
class immutable. doesn't have setter instance value. getter in construct object#tostring()
method implicitly called el, coincidentally returns string value itself.
you need set changed value new list item instead. can via brace notation on list whereby pass list index: #{mybean.listofstrings[index]}
.
so, should do, making use of uidata#getrowindex()
list index:
<h:datatable binding="#{table}" value="#{mybean.listofstrings}" var="row"> <h:column> <h:inputtext value="#{mybean.listofstrings[table.rowindex]}" /> </h:column> </h:datatable>
(note: value expression of binding
as-is! don't bind bean property)
Comments
Post a Comment