public void excluir() {
   musicaBean.delete(this.musicaSeleccionada);
   consultar();
   musicaSeleccionada = null;
   pesqAux.setMusicaSeleccionada(musicaSeleccionada);
   FacesMessage message =
       new FacesMessage(FacesMessage.SEVERITY_INFO, "Music deleted successfully", "");
   FacesContext.getCurrentInstance().addMessage(null, message);
 }
 public void editar() {
   FacesMessage msg =
       new FacesMessage(FacesMessage.SEVERITY_INFO, "Music edited successfully!", null);
   FacesContext.getCurrentInstance().addMessage(null, msg);
   musicaBean.update(this.musicaSeleccionada);
   pesqAux.setMusicaSeleccionada(musicaSeleccionada);
   musicaSeleccionada = null;
   RequestContext.getCurrentInstance().update(Arrays.asList("frm:musica-table"));
   consultar();
 }
  public void salvar() {
    if (file != null) {
      try {
        Properties props = System.getProperties();
        file.write(
            props.getProperty("user.dir")
                + "\\music\\"
                + user.getCurrent().getId()
                + "_"
                + file.getFileName());
        String path = "/music/" + user.getCurrent().getId() + "_" + file.getFileName();
        this.musicaCriacao.setDono(user.getCurrent());
        this.musicaCriacao.setFilePath(path);
        musicaBean.save(this.musicaCriacao);
        // refresh nos paineis
        RequestContext.getCurrentInstance().update(Arrays.asList("frm:msgs", "frm:musica-table"));
        consultar();
        pesqAux.setMusicaSeleccionada(musicaSeleccionada);
        pesqAux.refreshLists();
        musicaSeleccionada = null;
        // mensagem de sucesso
        FacesMessage message =
            new FacesMessage(FacesMessage.SEVERITY_INFO, "Music added successfully", "");
        FacesContext.getCurrentInstance().addMessage(null, message);

      } catch (Exception e) {
        FacesMessage msg =
            new FacesMessage(
                FacesMessage.SEVERITY_ERROR, "Error occured while uploading file.", null);
        FacesContext.getCurrentInstance().addMessage(null, msg);
        e.printStackTrace();
      }
    } else {
      FacesMessage msg =
          new FacesMessage(
              FacesMessage.SEVERITY_ERROR, "Please select an mp3 file to upload.", null);
      FacesContext.getCurrentInstance().addMessage(null, msg);
    }
  }
 public void onRowSelect(SelectEvent event) {
   pesqAux.setMusicaSeleccionada(musicaSeleccionada);
 }