Tuesday, October 29, 2013

PPR on Table Row

Scenario: On Update in Bonus field of selected row, TotalSalary should get updated by Salary+Bonus amounts.

Step1: Create VO. Add TotalSalary as Transient attribute. Create table in JSP page.

Step2: Add ValueChangeListner on Bonus InputText box. Set AutoSubmit to true.

Step3:Create method in bean.
public void setTotalAmt(ValueChangeEvent ve){
        //BigDecimal bonus = (BigDecimal)ve.getNewValue();
        for (Object facesRowKey : t1.getSelectedRowKeys()) { 
            t1.setRowKey(facesRowKey); 
            Object o = t1.getRowData(); 
            JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)o; 
            Row row = rowData.getRow(); 
            BigDecimal salary = (BigDecimal)row.getAttribute("Salary");
BigDecimal bonus = (BigDecimal)row.getAttribute("Bonus");
            row.setAttribute("TotalSalary", salary.add(bonus));
        }
}


Related Posts Plugin for WordPress, Blogger...