您好希望創建一個帶有序列號的列的數據表,並且我正在使用按鈕點擊添加行來實現datacolum動態,我需要生成一個序列號,我爲此做了什麼聊天情況下,在數據表中添加列的序列號
我的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;
}
}
你有什麼試圖生成序列號?你在期待什麼? –
我需要添加序列號到第一列,但我的代碼反映在所有列中,因爲它的整數,我想我應該可能添加一個arraylist –
您可以發佈Employee類嗎? – Adarsh