您可以刪除綁定並更改操作(不需要更改bean範圍)。
1)簡單情況下:與產品清單和行選擇細節對於選擇的項目被顯示
按照實施例後的數據表使用的Javascript(在豆存儲項ID和呼叫動作用於呈現相關數據此ID):
<a4j:jsFunction name="selectRow" action="#{locationAction.showSelectedLocation}">
<a4j:param name="locationId" assignTo="#{locationAction.selectedLocationId}" />
</a4j:jsFunction>
<rich:dataTable id="locationTable"
value="#{locationAction.locationList}" var="location"
rows="#{referenceData.recordsPerPage}"
onrowclick="selectRow('#{location.locationId}')">
...
</rich:dataTable>
2)套,具備多個複選框和動作按鈕:
<rich:dataTable id="productTable" var="res"
value="#{productPicker.pickerList}">
...
<rich:column>
<h:selectBooleanCheckbox id="selectChck" value="#{res.selected}" />
</rich:column>
...
</rich:dataTable>
<a4j:commandButton value="#{msg.detachSelected}"
action="#{productPicker.deleteSelectedFromPickerList}"
render="picker" />
,其中項目列表是private List<PickerItem> pickerList;
和項目是從
public class PickerItem {
private Long id; // with getter and setter
// private Record item; // with getter and setter
private boolean selected; // with getter and setter
}
在我的代碼有equals
和hashCode
方法爲PickerItem類的拍,但它應該不它也能工作。