Esempio n. 1
0
  /**
   * Callback method that is called just before rendering takes place. This method will
   * <strong>only</strong> be called for the page that will actually be rendered (and not, for
   * example, on a page that handled a postback and then navigated to a different page). Customize
   * this method to allocate resources that will be required for rendering this page.
   */
  @Override
  public void prerender() {
    cargaFiltro();
    if (viewForm) {
      gridPanelForm.setRendered(true);
      gridPanelBotones.setRendered(true);
      if (updating) {
        btnAceptar.setRendered(false);

        try {
          RowKey rowKey = tableRowGroup.getRowKey();
          getListaClientes();
          cliente = listaClientes.get(Integer.parseInt(rowKey.getRowId()));
          if (cliente != null) {
            txtNombre.setText(cliente.getNombre());
            txtDireccion.setText(cliente.getDireccion());
            txtCi.setText(cliente.getCi());
            txtApellido.setText(cliente.getApellido());
            txtRuc.setText(cliente.getRuc());
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      if (inserting) {
        btnUpdate.setRendered(false);
      }
    } else {
      gridPanelForm.setRendered(false);
      gridPanelBotones.setRendered(false);
    }
  }
Esempio n. 2
0
  public String botonEliminar_action() {
    try {
      btnBuscar_action();
      RowKey rowKey = tableRowGroup.getRowKey();
      cliente = listaClientes.get(Integer.parseInt(rowKey.getRowId()));
      clienteFacade.remove(cliente);
      info("Registro eliminado con exito!");

    } catch (Exception e) {
      error("Error al eliminar el registro. " + e);
    }
    return null;
  }
Esempio n. 3
0
  public String btnUpdate_action() {

    btnBuscar_action();
    RowKey rowKey = tableRowGroup.getRowKey();
    cliente = listaClientes.get(Integer.parseInt(rowKey.getRowId()));
    cliente.setNombre(txtNombre.getText().toString());
    cliente.setDireccion(txtDireccion.getText().toString());
    cliente.setCi(txtCi.getText().toString());
    cliente.setApellido(txtApellido.getText().toString());
    cliente.setRuc(txtRuc.getText().toString());
    try {
      clienteFacade.edit(cliente);
      viewForm = false;
      info("El registro se ha actualizado con exito!");
    } catch (Exception e) {
      error("Ha ocurrido un error! " + e);
      e.printStackTrace();
    }
    return null;
  }
Esempio n. 4
0
 public Object getSelectedValue() {
   RowKey rowKey = (RowKey) getValue("#{currentRow.tableRow}");
   return (rowKey != null) ? rowKey.getRowId() : null;
 }