/**
  * This method is responsible for loading the required values when required to handle countries.
  */
 public void load() {
   currentCountry = null;
   if (selectedRowDataTable != null) {
     currentCountry = countriesFacade.find(Short.parseShort(selectedRowDataTable.getColumn1()));
   }
   if (currentCountry != null) {
     btnEditDisabled = false;
     btnRemoveDisabled = false;
     if (currentCountry.getName() != null) {
       name = currentCountry.getName();
     } else {
       name = "";
     }
   }
 }
 /** This method is responsible to save a new record */
 public void saveRegistry() {
   // determinar consecutivo
   if (newName.trim().length() != 0) {
     int max = countriesFacade.findMax() + 1;
     newName = newName.toUpperCase();
     Countries newRegistry = new Countries((short) max);
     newRegistry.setName(newName);
     countriesFacade.create(newRegistry);
     newName = "";
     currentCountry = null;
     selectedRowDataTable = null;
     createDynamicTable();
     btnEditDisabled = true;
     btnRemoveDisabled = true;
     FacesMessage msg =
         new FacesMessage(FacesMessage.SEVERITY_INFO, "CORRECTO", "Nuevo registro almacenado");
     FacesContext.getCurrentInstance().addMessage(null, msg);
   } else {
     FacesMessage msg =
         new FacesMessage(FacesMessage.SEVERITY_ERROR, "SIN NOMBRE", "Se debe digitar un nombre");
     FacesContext.getCurrentInstance().addMessage(null, msg);
   }
 }
 /** This method allows to update a record. */
 public void updateRegistry() {
   // determinar consecutivo
   if (currentCountry != null) {
     if (name.trim().length() != 0) {
       name = name.toUpperCase();
       currentCountry.setName(name);
       countriesFacade.edit(currentCountry);
       name = "";
       currentCountry = null;
       selectedRowDataTable = null;
       createDynamicTable();
       btnEditDisabled = true;
       btnRemoveDisabled = true;
       FacesMessage msg =
           new FacesMessage(FacesMessage.SEVERITY_INFO, "CORRECTO", "Registro actualizado");
       FacesContext.getCurrentInstance().addMessage(null, msg);
     } else {
       FacesMessage msg =
           new FacesMessage(
               FacesMessage.SEVERITY_ERROR, "SIN NOMBRE", "Se debe digitar un nombre");
       FacesContext.getCurrentInstance().addMessage(null, msg);
     }
   }
 }