public void onClick$btnDeleteEmployee(ForwardEvent fe) { if (lstEmployee.getSelectedItem() != null) { Employee employee = (Employee) (lstEmployee.getSelectedItem().getValue()); if (!_model.remove(employee)) { reportError(Messages.getString("EmployeeController.3"), employee); } } else { UiUtils.showMessage(Messages.getString("EmployeeController.4")); } }
private void reportError(String message, Employee employee) { StringBuilder sb = new StringBuilder(message) .append(Messages.getString("EmployeeController.5")) .append(employee); final String error = sb.toString(); UiUtils.showMessage(error); log.error(error); }
public void onClick$btnUpdateEmployee(ForwardEvent fe) { if (lstEmployee.getSelectedItem() != null) { Employee employee = (Employee) (lstEmployee.getSelectedItem().getValue()); employee.setFirstName(txtFirstName.getText()); employee.setLastName(txtLastName.getText()); employee.setAge(Integer.parseInt(intAge.getText())); } else { UiUtils.showMessage(Messages.getString("EmployeeController.2")); } }
// click events public void onClick$btnAddEmployee(ForwardEvent fe) { String firstName = txtFirstName.getText(); String lastName = txtLastName.getText(); int iAge = Integer.parseInt(intAge.getText()); Employee employee = new Employee(firstName, lastName, iAge); if (!_model.add(employee)) { reportError(Messages.getString("EmployeeController.0"), employee); } }