I need your help in updating an outputText
with the total Amount field for the selected checkboxes in a dataTable. The jsf has the below code:
<p:dataTable id="PendingRequests" var="hr" selection="#{hrdirector.selectedRequests}"
value="#{hrdirector.listPendingRequests}" rowKey="#{hr.requestNo}"
filteredValue="#{hrdirector.filteredRequests}" widgetVar="dataTableWidgetVar">
<p:column selectionMode="multiple" style="width:16px;text-align:center"></p:column>
<p:column headerText="Request No.">
<h:outputText value="#{hr.requestNo}"/>
</p:column>
<p:column headerText="Request Amount">
<h:outputText value="#{hr.requestAmount}"/>
</p:column>
</p:dataTable>
<h:outputText id="Sum" value="#{hr.Sum}"/>
The user is going to select a number of checkboxes and I need to know the appropriate way to call a method through ajax to update the outputText with the Total Requests Amounts selected.
The method to be called is:
public void ShowTotal() {
try {
String [] tranAmountArr = new String[selectedRequests.size()];
for (int i = 0; i < selectedRequests.size(); i++) {
tranAmountArr[i] = selectedRequests.get(i).getEncashmentAmount();
Sum = Sum + Double.parseDouble(tranAmountArr[i]);
}
System.out.println(Sum);
} catch (Exception e) {
System.err.print(e);
e.printStackTrace();
log.error("Error in ShowTotal()");
}
}