Suppose there is a requirement to search for employees based on certain criteria and then add a bonus to their salaries. Let's say the UI for this includes an employee search, an input text box for entering the bonus amount and a button that should add the bonus to the salaries and update the VO.
Here is one way to achieve this:
- Create a method in AMImpl which updates salary for all the rows in currrent VO row set, and expose this method in AM client interface
- On button action listener, pass the bonus value from input box as parameter to AM method and execute it
Here is one way to achieve this:
- Create a method in AMImpl which updates salary for all the rows in currrent VO row set, and expose this method in AM client interface
public void updateSalary(double bonusPct) { RowSetIterator empRow = getEmployeeView1().createRowSetIterator(null); EmployeeViewRowImpl currentRow = new EmployeeViewRowImpl(); double currentSalary = 0; while (empRow.hasNext()) { currentRow = (EmployeeViewRowImpl) empRow.next(); currentSalary = currentRow.getSalary().doubleValue(); currentRow.setSalary(new oracle.jbo.domain.Number(currentSalary + (currentSalary * bonusPct/100))); } getDBTransaction().commit(); }- Add the AM method in page bindings
- On button action listener, pass the bonus value from input box as parameter to AM method and execute it
public void addBonus(ActionEvent actionEvent) { BindingContainer bc = BindingContext.getCurrent().getCurrentBindingsEntry(); OperationBinding op = bc.getOperationBinding("updateSalary"); op.getParamsMap().put("bonusPct", getBonus()); //getBonus() gets the entered bonus value op.execute(); }Now, when you click Add Bonus button, updateSalary will be called and the bonus will be added to the salary of employess.
<< A Request >>
Please contribute in making this world a better place to live by adopting a pet from your nearest pet shelter (btw cats are my favourite :-) )
<< Thank You >>
Please contribute in making this world a better place to live by adopting a pet from your nearest pet shelter (btw cats are my favourite :-) )
<< Thank You >>