Exemple #1
0
  @Override
  public Object getAsObject(FacesContext context, UIComponent component, String value) {
    if (value == null || value.isEmpty()) {
      return null;
    }

    try {
      RentalManager manager = Management.getManager();
      return manager.getCarById(Integer.valueOf(value));
    } catch (Exception ex) {
      return null;
    }
  }
  @Override
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    Customer customer = (Customer) request.getAttribute("data");
    prepareCustomer(customer);

    try {
      RentalManager manager = Management.getManager();
      manager.addCustomer(customer);
    } catch (Exception ex) {
      throw new ServletException(ex);
    }

    response.sendRedirect("index.jsp");
  }