我正在尝试在jsf 2.2框架中组合primefaces(v6.0)tabView和可编辑的dataTable。通过阅读本论坛中的许多优秀主题,我能够动态添加/删除标签并实现可编辑的表格,允许动态添加/删除行。
但是我在阅读一处房产时遇到了麻烦。#34; name"属于Hobby对象。确切地说,IDE不显示属于Hobby对象的属性,而是显示Person对象的属性。
我希望有经验的JSF开发人员能够找到我的错误并告诉我我做错了什么以及如何纠正错误。
仅供参考 - 我在这里粘贴的例子是水下版本。
formGroup expects a FormGroup instance. Please pass one in.
// This when using [formGroup]="item.whateverGroup02"
Cannot find control with name: 'whatever05'
// When using [formGroup]="item.controls.whateverGroup02"
Cannot find control with path: 'whateverArray01 -> 0 ->'
// This when using [formGroupName]="whateverGroup02"
管理bean:
<p:tabView value="#{bean.people}" var="person">
<p:tab title="#{person.name}">
<h:panelGrid>
<p:dataTable value="#{person.hobbies}" var="hobby">
<p:column headerText="my hobby">
#{hobby.name}
</p:column>
</p:datatTable>
</h:panelGrid>
</p:tab>
人物模型:
@ManagedBean(name="bean")
@ViewScoped
public class Bean {
private List<Person> people;
@PostConstruct
public void init() {
people = new ArrayList<>();
}
// getter/setter for people
.....
}
爱好模型:
public class Person {
private List<Hobby> hobbies;
private String name;
public Person() {
hobbies = new ArrayList<>();
}
// getter/setter for hobbies and name
....
}