嗨,想创建一个包含序列号的列的数据表,并且我正在通过在按钮单击时添加行来使数据列动态化,我需要生成一个序列号,我为这种情况做些什么聊天,
我的jsf页面
<rich:dataTable value="#{section2Bean.employeeList}"
var="emp" style="width:100%;">
<h:column>
<f:facet name="header">
#{msg.lbl_serialNo}
</f:facet>
<h:outputText value="#{TnwrdBean.hrmsBean.hrmsSection9.serialNo}" />
</h:column>
<h:column>
<f:facet name="header">
#{msg.lbl_addRow}
</f:facet>
<div class="buttons">
<p align="center">
<h:commandButton id="addEduQualRow" type="submit" actionListener="#{section2Bean.addNewEmployee}"
value="+" />
</p>
</div>
</h:column>
</rich:dataTable>
Section2Bean.java
public class Section2Bean extends BaseAction implements Serializable {
private static final long serialVersionUID = 32423545435345L;
List<Employee> employeeList;
List<Employee> employeetrainingList;
private boolean checkSelected;
public List<Employee> getEmployeeList() {
return employeeList;
}
public void setEmployeeList(List<Employee> employeeList) {
this.employeeList = employeeList;
}
public void addNewEmployee(ActionEvent event) {
employeeList.add(new Employee(employeeList.size(), null));
System.out.println(employeeList);
for(int i = 1;i<=employeeList.size();i++){
}
}
public void deleteNewEmployee(ActionEvent event){
employeeList.remove(employeeList.hashCode());
}
@PostConstruct
public void init() {
employeeList = new ArrayList<Employee>();
employeetrainingList =new ArrayList<Employee>();
employeeList.add(new Employee(1, ""));
}
public Section2Bean() {
}
public boolean isCheckSelected() {
return checkSelected;
}
public void setCheckSelected(boolean checkSelected) {
this.checkSelected = checkSelected;
}
}