public boolean hasShipType(String descricao) { Tbshiptype shipType = null; List<Tbshiptype> embarcacoes = null; try { embarcacoes = shipTypeService.getShipTypeByDescription(descricao); if (embarcacoes != null && !embarcacoes.isEmpty()) { FacesMessageUtil.addErrorMessage( FacesContext.getCurrentInstance(), "msgsGrowl", FacesMessageUtil.getMessage("label_embarcacao_ja_cadastrado", null), null); FacesContext.getCurrentInstance().validationFailed(); return true; // FacesContext.getCurrentInstance().validationFailed(); } } catch (Exception e) { FacesMessageUtil.addGlobalErrorMessage( FacesContext.getCurrentInstance(), e.getMessage(), null); e.printStackTrace(); } return false; }
public static void addGlobalErrorMessage(FacesContext facesContext, String key, Object[] args) { String clientId = null; addErrorMessage(facesContext, clientId, key, args); }