@Override public String search() { Bomba bomba = new Bomba(); if (StringUtils.hasText(numeroPesquisa)) { bomba.setNumero(Integer.valueOf(numeroPesquisa)); } bomba.setPosto(posto); bomba.setCombustivel(combustivel); this.entities = bombaService.pesquisar(bomba); setCurrentBean(currentBeanName()); setCurrentState(SEARCH); return SUCCESS; }
@Override public String save() { boolean existeTipoCombustivel = bombaService.findPostoCombustivel(this.entity); if (!existeTipoCombustivel) { FacesContext context = FacesContext.getCurrentInstance(); context.addMessage( "posto", new FacesMessage( FacesMessage.SEVERITY_ERROR, null, "Este posto n�o oferece esse tipo de combustivel.")); return FAIL; } boolean existe = bombaService.findBombaPosto(this.entity); if (existe) { FacesContext context = FacesContext.getCurrentInstance(); context.addMessage( "numero", new FacesMessage(FacesMessage.SEVERITY_ERROR, null, "Bomba j� cadastrada neste posto.")); return FAIL; } return super.save(); }