Pagination problem with check box
flamingo May 5, 2010 2:56 PMHi........
I am developing the application where my vision is to get selected rows by clicking on checkbox in extendedDataTable for that I wrote the following code in xhtml
<rich:extendedDataTable id="shipmentDetailListTable" headerClass="head"
var="_shipmentDetail" rows="20" selectionMode="multi" selectedClass="selection"
height="532px" width="1150px" value="#{cargoDetail}">
<f:facet name="header">#{messages['com.infyz.toms.label.Search_results']}</f:facet>
<rich:column id="check" width="28px">
<f:facet name="header"> </f:facet>
<h:selectBooleanCheckbox id="Checkbox" value="#{itGateOperationsAction.detailSelectionCapital[_shipmentDetail]}"/>
</rich:column>
<rich:column id="voyage" width="120px" sortable="true"
sortBy="#{_shipmentDetail.itShipmentOrder.itVoyageMaster.voyageNumber}"
filterBy="#{_shipmentDetail.itShipmentOrder.itVoyageMaster.voyageNumber}" filterEvent="onkeyup"
headerClass="head"
label="#{messages['com.infyz.toms.properties.Voyage_number']}">
<f:facet name="header">
<h:outputText styleClass="headerText" value="#{messages['com.infyz.toms.properties.Voyage_number']}" />
</f:facet>
<h:outputText value="#{_shipmentDetail.itShipmentOrder.itVoyageMaster.voyageNumber}" />
</rich:column>
<rich:column id="shipmentnumber" width="120px" sortable="true"
sortBy="#{_shipmentDetail.itShipmentOrder.shipmentNumber}"
filterBy="#{_shipmentDetail.itShipmentOrder.shipmentNumber}" filterEvent="onkeyup"
headerClass="head"
label="#{messages['com.infyz.toms.properties.Shipment_number']}">
<f:facet name="header">
<h:outputText styleClass="headerText" value="#{messages['com.infyz.toms.properties.Shipment_number']}" />
</f:facet>
<h:outputText value="#{_shipmentDetail.itShipmentOrder.shipmentNumber}" />
</rich:column>
<rich:column id="cargoid" width="118px" sortable="true" headerClass="head"
sortBy="#{_shipmentDetail.cargoId}"
filterBy="#{_shipmentDetail.cargoId}" filterEvent="onkeyup"
label="#{messages['com.infyz.toms.properties.Cargo_id']}" >
<f:facet name="header">
<h:outputText styleClass="headerText" value="#{messages['com.infyz.toms.properties.Cargo_id']}" />
</f:facet>
<h:outputText value="#{_shipmentDetail.cargoId}" />
</rich:column>
<rich:column id="barcode" width="120px" sortable="true" headerClass="head"
sortBy="#{_shipmentDetail.barcode}"
filterBy="#{_shipmentDetail.barcode}" filterEvent="onkeyup"
label="#{messages['com.infyz.toms.properties.Bar_code']}">
<f:facet name="header">
<h:outputText styleClass="headerText" value="#{messages['com.infyz.toms.properties.Bar_code']}" />
</f:facet>
<h:outputText value="#{_shipmentDetail.barcode}" />
</rich:column>
<rich:column id="commodityClassId" width="120px" sortable="true" headerClass="head"
sortBy="#{_shipmentDetail.icCommodityClass.description}"
filterBy="#{_shipmentDetail.icCommodityClass.description}" filterEvent="onkeyup" label="#{messages['com.infyz.toms.properties.Comm_class']}">
<f:facet name="header">
<h:outputText styleClass="headerText" value="#{messages['com.infyz.toms.properties.Comm_class']}" />
</f:facet>
<h:outputText value="#{_shipmentDetail.icCommodityClass.commodityClassCode }" />
</rich:column>
<rich:column id="commodityTypeId" width="134px" sortable="true" headerClass="head"
sortBy="#{_shipmentDetail.icCommodityType.description}"
filterBy="#{_shipmentDetail.icCommodityType.description}" filterEvent="onkeyup" label="#{messages['com.infyz.toms.properties.Comm_type']}">
<f:facet name="header">
<h:outputText styleClass="headerText" value="#{messages['com.infyz.toms.properties.Comm_type']}" />
</f:facet>
<h:outputText value="#{_shipmentDetail.icCommodityType.commodityTypeCode }" />
</rich:column>
<rich:column id="icCommodity" width="150px" sortable="true" headerClass="head"
sortBy="#{_shipmentDetail.icCommodity.commodityCode}"
filterBy="#{_shipmentDetail.icCommodity.commodityCode}" filterEvent="onkeyup" label="#{messages['com.infyz.toms.entity.Commodity']}">
<f:facet name="header">
<h:outputText styleClass="headerText" value="#{messages['com.infyz.toms.entity.Commodity']}" />
</f:facet>
<h:outputText value="#{_shipmentDetail.icCommodity.commodityCode}" />
</rich:column>
<rich:column id="make" width="120px" sortable="true" headerClass="head"
sortBy="#{_shipmentDetail.icMake.makeCode}" filterBy="#{_shipmentDetail.icMake.makeCode}"
filterEvent="onkeyup" label="#{messages['com.infyz.toms.entity.Make']}">
<f:facet name="header">
<h:outputText styleClass="headerText"
value="#{messages['com.infyz.toms.entity.Make']}" />
</f:facet>
<h:outputText value="#{_shipmentDetail.icMake.makeCode}" />
</rich:column>
<rich:column id="model" width="120px" sortable="true" headerClass="head"
sortBy="#{_shipmentDetail.icCommodityModels.commodityModelCode}" filterBy="#{_shipmentDetail.icCommodityModels.commodityModelCode}"
filterEvent="onkeyup" label="#{messages['com.infyz.toms.entity.Model']}">
<f:facet name="header">
<h:outputText styleClass="headerText"
value="#{messages['com.infyz.toms.entity.Model']}" />
</f:facet>
<h:outputText value="#{_shipmentDetail.icCommodityModels.commodityModelCode}" />
</rich:column>
</rich:extendedDataTable>
<rich:spacer height="5" />
<rich:datascroller fastControls="hide"
page="#{itGateOperationsAction.scrollerPage}" pagesVar="pages" for="shipmentDetailListTable"
id="ds">
<f:facet name="first">
<h:outputText value="#{messages['com.infyz.toms.label.button.First_Page']}" styleClass="scrollerCella"/>
</f:facet>
<f:facet name="first_disabled">
<h:outputText value="#{messages['com.infyz.toms.label.button.First_Page']}" styleClass="scrollerCelld" />
</f:facet>
<f:facet name="last">
<h:outputText value="#{messages['com.infyz.toms.label.button.Last_page']}" styleClass="scrollerCella" />
</f:facet>
<f:facet name="last_disabled">
<h:outputText value="#{messages['com.infyz.toms.label.button.Last_page']}" styleClass="scrollerCelld" />
</f:facet>
<f:facet name="previous">
<h:outputText value="#{messages['com.infyz.toms.label.button.Previous_page']}" styleClass="scrollerCella" />
</f:facet>
<f:facet name="previous_disabled">
<h:outputText value="#{messages['com.infyz.toms.label.button.Previous_page']}" styleClass="scrollerCelld" />
</f:facet>
<f:facet name="next">
<h:outputText value="#{messages['com.infyz.toms.label.button.Next_page']}" styleClass="scrollerCella" />
</f:facet>
<f:facet name="next_disabled">
<h:outputText value="#{messages['com.infyz.toms.label.button.Next_page']}" styleClass="scrollerCelld" />
</f:facet>
<f:facet name="pages">
<h:panelGroup>
<h:outputText value="Page "/>
<h:selectOneMenu value="#{itGateOperationsAction.scrollerPage}"
onchange="#{rich:component('ds')}.switchToPage(this.value)">
<f:selectItems value="#{itGateOperationsAction.totalPagesToScroll}" />
</h:selectOneMenu>
<h:outputText value=" of #{pages}" />
</h:panelGroup>
</f:facet>
</rich:datascroller>
<rich:spacer height="5" rendered="#{cargoDetail.rowCount > 0}"/>
<div align="right">
<a4j:commandButton id="add" rendered="#{cargoDetail.rowCount > 0}"
value="#{messages['com.infyz.toms.label.button.tooltip.Add']} to Gate Operations"
action="#{itGateOperationsAction.takeSelection}"/>
</div> and i am restricting it to 20 rows
and in backing bean i wrote the code in a following manner
private Map<ItShipmentDetail,Boolean> detailSelectionCapital = new HashMap<ItShipmentDetail,Boolean>();
public Map getDetailSelectionCapital() {
return detailSelectionCapital;
}
public String takeSelection(){
List<ItShipmentDetail> temp = new ArrayList<ItShipmentDetail>();
for (ItShipmentDetail line: cargoDetail) {
Boolean selected = detailSelectionCapital.get(line);
log.info("...................................................................."+selected);
if(selected)
temp.add(line);
}
for(ItShipmentDetail t:temp){
ItGateOperationsDetail igd = new ItGateOperationsDetail();
igd.setItGateOperations(selectedItGateOperations);
igd.setItShipmentDetail(t);
igd.setCreatedDate(getCurrentDate());
igd.setModifiedDate(getCurrentDate());
igd.setFActive(selectedItGateOperations.getFActive());
igd.setQuantityReceived(1);
igd.setQuantityPositioned(0);
igd.setQuantityStuffed(0);
selectedIgod=igd;
itGateDetail.add(igd);
}
detailSelectionCapital = new HashMap<ItShipmentDetail,Boolean>();
return"/operations/ItGateOperationsEdit.xhtml";
}here if i get 50 rows then i have 3 pages to view but detailSelectionCapital is holding first 20 rows only when i click on next button i am able to go next page,if i click on any checkbox over there that will results in null bcoz of this i am unable to identify the selected columns
I am unable to identify the problem
plz help me........
if there is any best solution please share with me