A
String是不可变的。它没有值的二传手。您需要将其包装在bean(或称为POJO)中。
public class Musician { private String preferredGenre; // Add/generate constructor, getter, setter, etc.}
然后按如下所示更改您的托管bean。
@ManagedBean@ViewScopedpublic class NewMusician { private ArrayList<Musician> musicians = new ArrayList<Musician>(); public NewMusician() { musicians.add(new Musician("olo")); } public ArrayList<Musician> getMusicians() { return musicians; } public void saveNewMusician() { // ... } // ...}
和您的数据表:
<h:dataTable value="#{newMusician.musicians}" var="musician"> <h:column> <h:inputText value="#{musician.preferredGenre}" /> </h:column></h:dataTable>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)