public String restoreFile() { int id = restoreFileId; Filelog file = null; try { file = filelogService.getFileLog(id); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error loading file with id " + id, e); } if (file != null) { String fileUniqueName = file.getCurrentName(); String fileName = file.getNameOriginal(); String error; try { error = filelogService.callPentaho(FILE_PATH.concat(fileUniqueName)); if (error.length() != 0) { throw new Exception(error); } FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "Carga satisfactoria")); } catch (Exception e) { FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error al cargar", e.getMessage())); LOGGER.log(Level.SEVERE, "Error loading file " + fileName, e); } } return null; }
public String processCreateNew() { try { if (!this.checkAccess()) { throw new PermissionException( SessionManager.getCurrentSessionUserId(), "syllabus_access_athz", ""); } } catch (PermissionException e) { // logger.info(this + ".getEntries() in PostemTool " + e); FacesContext.getCurrentInstance() .addMessage( null, MessageUtils.getMessage( FacesMessage.SEVERITY_ERROR, "error_permission", (new Object[] {e.toString()}), FacesContext.getCurrentInstance())); return "permission_error"; } this.userId = SessionManager.getCurrentSessionUserId(); this.siteId = ToolManager.getCurrentPlacement().getContext(); this.currentGradebook = gradebookManager.createEmptyGradebook(this.userId, this.siteId); this.oldGradebook = gradebookManager.createEmptyGradebook(this.userId, this.siteId); this.csv = null; this.newTemplate = null; this.delimiter = COMMA_DELIM_STR; return "create_gradebook"; }
public String processDelete() { try { if (!this.checkAccess()) { throw new PermissionException( SessionManager.getCurrentSessionUserId(), "syllabus_access_athz", ""); } } catch (PermissionException e) { // logger.info(this + ".getEntries() in PostemTool " + e); FacesContext.getCurrentInstance() .addMessage( null, MessageUtils.getMessage( FacesMessage.SEVERITY_ERROR, "error_permission", (new Object[] {e.toString()}), FacesContext.getCurrentInstance())); return "permission_error"; } gradebookManager.deleteGradebook(currentGradebook); gradebooks = null; currentGradebook = null; csv = null; newTemplate = null; students = null; return "main"; }
public void createBuyShowItem(ActionEvent event) throws IOException { System.err.println("test show item shopping cart!"); setMemberAccount( (MemberAccount) FacesContext.getCurrentInstance() .getExternalContext() .getSessionMap() .get("currentMember")); System.err.println("select section num" + getTicketmanager().getSelectSectionNum()); System.err.println("Show name : " + getTicketmanager().getSelectShowInfo().getName()); System.err.println("section ticket : " + getTicketmanager().getSelectSectionTicket()); String orderName = getTicketmanager().getSelectShowInfo().getName() + " ( section : " + getTicketmanager().getSelectSectionTicket().getSeatSection().getNum() + " )"; System.err.println("Order Name : " + orderName); int quantity = getTicketmanager().getSelectSeats().size(); System.err.println("ticket quantity : " + quantity); float price = getTicketmanager().getSelectSectionTicket().getPrice(); System.err.println("ticket unit price : " + price); this.setShowItem(bimbl.addBuyShowItem(getMemberAccount(), orderName, quantity, (double) price)); FacesMessage msg = new FacesMessage("Your ticket order is succesfully added to Shopping Cart!"); FacesContext.getCurrentInstance().addMessage(null, msg); FacesContext fc = FacesContext.getCurrentInstance(); ExternalContext ec = fc.getExternalContext(); ec.redirect("../CRM/Payment/cart.xhtml"); }
private void resolveBindings() { FacesContext context = null; if (parameters != null) { for (int i = 0; i < parameters.length; i++) { Object o = parameters[i]; if (o instanceof ValueBinding) { if (context == null) { context = FacesContext.getCurrentInstance(); } o = ((ValueBinding) o).getValue(context); } if (o instanceof ValueExpression) { if (context == null) { context = FacesContext.getCurrentInstance(); } o = ((ValueExpression) o).getValue(context.getELContext()); } // to avoid 'null' appearing in message if (o == null) { o = ""; } resolvedParameters[i] = o; } } }
public String twitterLogin() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey(BUNDLE.getString("twt.client_id")) .setOAuthConsumerSecret(BUNDLE.getString("twt.secret")) .setOAuthRequestTokenURL("https://api.twitter.com/oauth/request_token") .setOAuthAuthorizationURL(("https://api.twitter.com/oauth/authorize")) .setOAuthAccessTokenURL(("https://api.twitter.com/oauth/access_token")); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance(); HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse(); request.getSession().setAttribute("twitter", twitter); try { RequestToken requestToken = twitter.getOAuthRequestToken(BUNDLE.getString("twt.redirect_uri")); request.getSession().setAttribute("requestToken", requestToken); LOGGER.info("requestToken.getAuthenticationURL():" + requestToken.getAuthenticationURL()); try { response.sendRedirect(requestToken.getAuthenticationURL()); } catch (IOException e) { e.printStackTrace(); } } catch (TwitterException e) { e.printStackTrace(); } return ""; }
/** * Metodo que busca una historia clinica * * @author David Carranza */ public void buscarListado() { String nombreMetodo = Thread.currentThread().getStackTrace()[1].getMethodName() + "()"; FacesContext context = FacesContext.getCurrentInstance(); try { lista = new ArrayList<>(); lista = admin.listarOrdenada( object.getClass(), "cplFechaMuestra", fechaInicio, "cplEstado", 3, "cplOrdenLlegada", true); if (lista.isEmpty()) { FacesContext.getCurrentInstance() .addMessage( findComponent(context.getViewRoot(), "formDatos").getClientId(), new FacesMessage( FacesMessage.SEVERITY_ERROR, "Busqueda sin resultados", "No se encontro paciente")); } } catch (Exception e) { log.error("{}: {} ", nombreMetodo, e); } }
public void save() { try { String idtest = FacesContext.getCurrentInstance() .getExternalContext() .getRequestParameterMap() .get("idtest"); String idExec = FacesContext.getCurrentInstance() .getExternalContext() .getRequestParameterMap() .get("idExec"); // resultB.setId(Integer.parseInt(id)); resultB.setIdexec(Integer.parseInt(idExec)); resultB.setResulttest(resultB.getResulttest()); resultB.setComment(resultB.getComment()); // resultB.setIdtest(resultB.getIdtest()); resultB.setIdtest(Integer.parseInt(idtest)); // System.out.println(res); // System.out.println(comm); System.out.println(resultB.getComment()); System.out.println(resultB.getIdtest()); // adjustSave(); getPersistence().save(resultB); listAll(); new MessageBean().success(); } catch (Exception e) { new MessageBean().error(); } }
public String salvar() { if (membros.isEmpty()) { FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage( FacesMessage.SEVERITY_WARN, "Por favor selecione pelo menos um membro para o grupo.", "")); return null; } try { Integer idGestor = SessaoUtil.getInstancia().recuperarID("idGestor"); cgt.salvarGrupo(idGestor, grupo, membros); return "grupo_gerenciar.xhtml?faces-redirect=true"; } catch (Exception e) { FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage( FacesMessage.SEVERITY_ERROR, "Erro ao salvar os dados. Por favor, tente novamente.", "")); return null; } }
public String addSubCategory() { CatList = new ListDao().catListByName(subcatname); // set foregin key status from category to subcategory table // subcat.setSubCatId(CatList.get(0).getCatId()); category.setCatId(CatList.get(0).getCatId()); subcat.setCategory(category); // set restof all column in subcategory table subcat.setSubCatName(subcat.getSubCatName()); subcat.setSubCatDesc(subcat.getSubCatDesc()); boolean status = new AddDao().addSubCategory(subcat); if (status) { FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Data Saved Successfully", "")); } else { FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage(FacesMessage.SEVERITY_WARN, "Data not Saved Successfully", "")); } return null; }
JasperPrint createReport( Pair<LocalDate, LocalDate> interval, AgentOrgSocProtect supervisor, AgentRecipient beneficiary) throws JRException, URISyntaxException { Map<String, Object> params = new HashMap<>(); params.put( JRParameter.REPORT_RESOURCE_BUNDLE, ResourceBundle.getBundle( "Bundle", FacesContext.getCurrentInstance().getViewRoot().getLocale())); params.put( JRParameter.REPORT_LOCALE, FacesContext.getCurrentInstance().getViewRoot().getLocale()); params.put("REPORT_LOCALE", FacesContext.getCurrentInstance().getViewRoot().getLocale()); params.put("REPORT_TITLE", reportTitle); params.put("BEGIN_DATE", YearMonth.from(interval.getLeft())); params.put("END_DATE", YearMonth.from(interval.getRight())); params.put("UNDERSIGNED", undersigned); List<ReportEntry> entries = repository.findPaymentsBy(persistenceUnitName, interval, supervisor, beneficiary); entries.addAll( repository.findRefundsBy(persistenceUnitName, interval, supervisor, beneficiary)); if (displayPeriodGaps) { entries = fillForEmptyPeriods(entries, interval); } final String template = resourceLocator.getAbsolutePathToResource( "jasperreports/LegacyChernobylBeneficiaryPayments.jrxml"); JasperReport report = JasperCompileManager.compileReport(template); return JasperFillManager.fillReport(report, params, new JRBeanCollectionDataSource(entries)); }
@SuppressWarnings("unchecked") private SelectItem[] createSelectItems(Object value) { List<SelectItem> items = new ArrayList<SelectItem>(); if (value instanceof SelectItem[]) { return (SelectItem[]) value; } else if (value instanceof Collection) { Collection<Object> col = null; try { col = (Collection<Object>) value; } catch (ClassCastException cce) { throw new FacesException(cce); } for (Object item : col) { if (item instanceof SelectItemGroup) { SelectItemGroup itemGroup = (SelectItemGroup) item; SelectItem[] itemsFromGroup = itemGroup.getSelectItems(); for (int i = 0; i < itemsFromGroup.length; i++) { items.add(itemsFromGroup[i]); } } else { FacesContext.getCurrentInstance() .getExternalContext() .getRequestMap() .put(this.getVar(), item); SelectItem selectItem = this.createSelectItem(); FacesContext.getCurrentInstance() .getExternalContext() .getRequestMap() .remove(this.getVar()); items.add(selectItem); } } } else if (value instanceof Map) { Map<String, Object> map = null; try { map = (Map<String, Object>) value; } catch (ClassCastException cce) { throw new FacesException(cce); } for (Map.Entry<String, Object> item : map.entrySet()) { FacesContext.getCurrentInstance() .getExternalContext() .getRequestMap() .put(this.getVar(), item.getValue()); SelectItem selectItem = this.createSelectItem(); FacesContext.getCurrentInstance() .getExternalContext() .getRequestMap() .remove(this.getVar()); items.add(selectItem); } } return items.toArray(new SelectItem[0]); }
public String adicionar() { try { boolean existencia = validaExistenciaDAO.verificaExistenciaCpf(questionarioPtIAtual.getCpf()); if (existencia) { FacesContext fc = FacesContext.getCurrentInstance(); FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Cpf já cadastrado", null); fc.addMessage("", msg); } else { questionarioPtIDAO.manter(getQuestionarioPtIAtual()); FacesContext fc = FacesContext.getCurrentInstance(); FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Tomador atualizado com sucesso", null); fc.addMessage("", msg); questionarioPtIAtual = new QuestionarioPtI(); } } catch (SQLException e) { e.printStackTrace(); FacesContext fc = FacesContext.getCurrentInstance(); FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Erro ao inserir", null); fc.addMessage("", msg); } return ""; }
public String enviarLance() { String retorno = ""; try { lanceVO.setLeilaoVO(leilaoVO); lanceVO.setUsuarioVO(controladorLoginBean.getUsuario()); String fraseErro = gerenciadorLance.efetuarLance(lanceVO); if (fraseErro != null) { FacesContext.getCurrentInstance() .addMessage( "msg_cadastro", new FacesMessage(FacesMessage.SEVERITY_WARN, fraseErro, "")); } else { FacesContext.getCurrentInstance() .addMessage( "msg_cadastro", new FacesMessage( FacesMessage.SEVERITY_INFO, ConstantesMensagens.INFO_LANCE_SUCESSO, "")); retorno = "index"; } } catch (LeilaoException e) { FacesContext.getCurrentInstance() .addMessage( "msg_cadastro", new FacesMessage( FacesMessage.SEVERITY_FATAL, ConstantesMensagens.FALHA_GENERICA, "")); LOGGER.error("Erro no método enviarLance ", e); } return retorno; }
public void registrarReconocimiento() throws IOException { setReconocimientoDetalle( getReconocimientoService() .registrarReconocimiento(getReconocimiento(), getPersonaOtorgaConsentimiento())); if (getReconocimientoDetalle().getCodigoRespuesta().equals(0)) { FacesContext context = FacesContext.getCurrentInstance(); context.getExternalContext().getFlash().setKeepMessages(true); FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage( FacesMessage.SEVERITY_INFO, "El registro se ha guardado correctamente.", "")); ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); externalContext.redirect( externalContext.getRequestContextPath().concat(ConstantesComunes.DETALLE_RECONOCIMIENTO)); } else { FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage( FacesMessage.SEVERITY_ERROR, "Ocurri\u00f3 un error al guardar el registro.", "")); RequestContext.getCurrentInstance().execute("errorDialog.show()"); } }
public boolean enviar() { boolean ret = false; try { iniciarTransacao(); session.save(instancia); session.flush(); tx.commit(); ret = true; if (isExibeMensagemInsercao()) { FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage( FacesMessage.SEVERITY_INFO, "Cadastro realizado com sucesso", "Registro cadastrado!")); } aposEnviar(); } catch (Exception e) { session.getTransaction().rollback(); e.printStackTrace(); FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage( FacesMessage.SEVERITY_ERROR, "Ocorrreu um erro ao cadastrar", e.getCause().getMessage())); } finally { finallyTransacao(); } return ret; }
public void registrarMatrinonio() throws IOException { getMatrimonio().setNormal(false); getMatrimonio().setHistorico(true); getMatrimonio().setEspecial(false); setMatrimonioDetalle( getMatrimonioService() .registrarMatrimonio( getMatrimonio(), getConsentimientoContrayenteUno(), getConsentimientoContrayenteDos())); if (getMatrimonioDetalle().getCodigoRespuesta().equals(0)) { FacesContext context = FacesContext.getCurrentInstance(); context.getExternalContext().getFlash().setKeepMessages(true); FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage( FacesMessage.SEVERITY_INFO, "El registro se ha guardado correctamente.", "")); ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext(); externalContext.redirect( externalContext.getRequestContextPath().concat(ConstantesComunes.DETALLE_MATRIMONIO)); } else { FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage( FacesMessage.SEVERITY_ERROR, "Ocurri\u00f3 un error al guardar el registro.", "")); RequestContext.getCurrentInstance().execute("errorDialog.show()"); } }
public void guardarFactor() { if (nuevoFactor.getValor().compareTo(BigDecimal.TEN) < 0) { Object obj = this.controller.agregar_factorCalibracion(nuevoFactor); if (obj instanceof Boolean) { lista_fCalibracion = this.controller.listar_factorCalibracion_vigentes(); RequestContext.getCurrentInstance().execute("Factor_Calibracion.hide()"); FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage( FacesMessage.SEVERITY_INFO, "Exitoso!", "Factor de calibración agregado con éxito")); } else { FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage( FacesMessage.SEVERITY_ERROR, "Error!", "No se pudo agregar el factor de calibración")); } } else { FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage( FacesMessage.SEVERITY_ERROR, "Error!", "El valor debe ser menor que diez")); } }
public void incluiEndereco() throws SQLException { selectedEndereco.setCadPessoa(selectedCliente); selectedEndereco.setPubEstado(estDAO.getById(estado)); selectedEndereco.setPubMunicipio(municDAO.getById(municipio)); selectedEndereco.setPubTipoEndereco(eEnderDAO.getById(tipoEndereco)); // verifica inclusão ou alteração de endereço if (selectedEndereco.getIdEndereco() == null) { enderDAO.inserirEndereco(selectedEndereco); msg = "Endereço incluido com sucesso."; FacesContext.getCurrentInstance() .addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg)); } else { enderDAO.updateEndereco(selectedEndereco); msg = "Endereço alterado com sucesso."; FacesContext.getCurrentInstance() .addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg)); } // verifica endereço padrão if (selectedCliente.getCadEnderecos() == null) { selectedCliente.setCadEnderecos(selectedEndereco); pesDAO.updatePessoa(selectedCliente); msg = "Endereço padrão definido."; FacesContext.getCurrentInstance() .addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg)); } // recaregar lista de endereços listEnderecos = enderDAO.listEnderecosByPessoa(selectedCliente); }
public void addDivision() { try { logger.info("addDivision"); Division model = new Division(); model.setDivisionName(getDivisionName()); model.setDivisionShortName(getDivisionShortname()); if (getId() == 0) { divisionService.add(model); } else { model.setId(getId()); divisionService.update(model); } this.setDivisionName(""); this.setDivisionShortname(""); FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage(FacesMessage.SEVERITY_INFO, ParameterModel.STATUS_SAVE_SUCCESS, "")); } catch (Exception e) { e.printStackTrace(); FacesContext.getCurrentInstance() .addMessage( null, new FacesMessage(FacesMessage.SEVERITY_ERROR, ParameterModel.STATUS_SAVE_FAIL, "")); } }
public void createBuyCardItem(ActionEvent event) { System.err.println("TEST"); FacesMessage msg = new FacesMessage("Your Transaction is succesfully added to Shopping Cart!"); setMemberAccount( (MemberAccount) FacesContext.getCurrentInstance() .getExternalContext() .getSessionMap() .get("currentMember")); System.err.println("Get memberID = " + getMemberAccount().getId()); String valuePackage = getBuyCardValue().getTopupType(); System.err.println(valuePackage); if (valuePackage.equals("1000")) { this.setBuyCardValue(bimbl.addCardBuyItem(getMemberAccount(), valuePackage, 1000)); System.err.println("ValueCardValue ID = " + getBuyCardValue()); } else if (valuePackage.equals("2000")) { this.setBuyCardValue(bimbl.addCardBuyItem(getMemberAccount(), valuePackage, 1960)); } else if (valuePackage.equals("3000")) { this.setBuyCardValue(bimbl.addCardBuyItem(getMemberAccount(), valuePackage, 2850)); } else if (valuePackage.equals("5000")) { this.setBuyCardValue(bimbl.addCardBuyItem(getMemberAccount(), valuePackage, 4600)); } else if (valuePackage.equals("8000")) { this.setBuyCardValue(bimbl.addCardBuyItem(getMemberAccount(), valuePackage, 7200)); } else if (valuePackage.equals("10000")) { this.setBuyCardValue(bimbl.addCardBuyItem(getMemberAccount(), valuePackage, 8800)); } FacesContext.getCurrentInstance().addMessage(null, msg); }
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 String process() { if (!this.loggedIn) { try { this.loggedIn = this.authenticateObject.check(new AuthenticateDTO(this.login, this.password)); } catch (EJBException ejbex) { this.loggedIn = false; System.out.println(ejbex.toString()); } } else { this.loggedIn = false; } if (this.loggedIn) { ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()) .getSession(true); this.cartObject.initialize(); } else { FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); Locale loc = externalContext.getRequestLocale(); externalContext.invalidateSession(); facesContext.getViewRoot().setLocale(loc); if (this.cartObject != null) { this.cartObject.setClientId(null); this.cartObject.setMerchandiseId(null); this.cartObject.setAmount(null); this.cartObject.destroy(); } this.currencyObject.setLocalizationLocale(loc); } return null; }
public void login(ActionEvent actionEvent) { SecurityUtils.getSubject() .login(new UsernamePasswordToken(getNombre(), getClave(), isRemember())); WebUtils.getAndClearSavedRequest( (ServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()); logeado = SecurityUtils.getSubject().isAuthenticated(); final RequestContext context = RequestContext.getCurrentInstance(); FacesMessage msg = null; if (logeado) { msg = new FacesMessage( FacesMessage.SEVERITY_INFO, Messages.getString("LoginBean.message.welcome"), // $NON-NLS-1$ nombre); LogManager.info(Messages.getString("LoginBean.log.message.access", nombre)); // $NON-NLS-1$ } else { msg = new FacesMessage( FacesMessage.SEVERITY_WARN, Messages.getString("LoginBean.message.error"), // $NON-NLS-1$ Messages.getString("LoginBean.message.error.details")); // $NON-NLS-1$ LogManager.warn(Messages.getString("LoginBean.log.message.error", nombre)); // $NON-NLS-1$ } FacesContext.getCurrentInstance().addMessage(null, msg); context.addCallbackParam("estaLogeado", logeado); if (logeado) { continuar("home.xhtml"); } }
public String delete() { statusMessage = SUCCESS_MESSAGE; result = "true"; setDeleteId(new Long((linkDelete.getAttributes().get("deleteId").toString()))); setClassificationName((String) linkDelete.getAttributes().get("classificationName")); try { VDCGroup vdcgroup = vdcGroupService.findById(deleteId); vdcGroupService.removeVdcGroup(vdcgroup); HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); String referer = (String) request.getHeader("referer"); result = referer.substring(referer.lastIndexOf("/") + 1, referer.indexOf(".")); result = getFriendlyLinkName(); resultLink = referer; // this.vdcGroupService.updateGroupOrder(order); // TBD } catch (Exception e) { statusMessage = FAIL_MESSAGE + " " + e.getCause().toString(); result = "failed"; } finally { Iterator iterator = FacesContext.getCurrentInstance().getMessages("AddClassificationsPageForm"); while (iterator.hasNext()) { iterator.remove(); } FacesContext.getCurrentInstance() .addMessage("AddClassificationsPageForm", new FacesMessage(statusMessage)); return "success"; } }
/** @return Returns the message to display when a file has been uploaded */ public String getFileUploadSuccessMsg() { // NOTE: This is a far from ideal solution but will do until we have // a pure JSF upload solution working. This method is only called // after a file is uploaded, so we can calculate the mime type and // determine whether to enable inline editing in here. FacesContext fc = FacesContext.getCurrentInstance(); this.mimeType = Repository.getMimeTypeForFileName(fc, this.fileName); this.encoding = "UTF-8"; InputStream is = null; try { if (this.file != null) { is = new BufferedInputStream(new FileInputStream(this.file)); this.encoding = Repository.guessEncoding(fc, is, this.mimeType); } } catch (Throwable e) { // Not terminal logger.error("Failed to get encoding from file: " + this.fileName, e); } finally { try { is.close(); } catch (Throwable e) { } // Includes NPE } this.inlineEdit = (this.mimeType.equals(MimetypeMap.MIMETYPE_HTML)); // get the file upload message String msg = Application.getMessage(FacesContext.getCurrentInstance(), "file_upload_success"); return MessageFormat.format(msg, new Object[] {Utils.encode(getFileName())}); }
public String processInstructorView() { try { if (!this.checkAccess()) { throw new PermissionException( SessionManager.getCurrentSessionUserId(), "syllabus_access_athz", ""); } } catch (PermissionException e) { // logger.info(this + ".getEntries() in PostemTool " + e); FacesContext.getCurrentInstance() .addMessage( null, MessageUtils.getMessage( FacesMessage.SEVERITY_ERROR, "error_permission", (new Object[] {e.toString()}), FacesContext.getCurrentInstance())); return "permission_error"; } Long currentGbId = ((Gradebook) gradebookTable.getRowData()).getId(); currentGradebook = gradebookManager.getGradebookByIdWithHeadingsAndStudents(currentGbId); students = new ArrayList(currentGradebook.getStudents()); return "view_gradebook"; }
public void onEventSelect(SelectEvent selectEvent) { UserEventVisibility visibility; // one of: CREATOR, VIEWER, NO_VISIBILITY int eventID; selectedEvent = (ScheduleEvent) selectEvent.getObject(); eventID = Integer.parseInt(selectedEvent.getData().toString()); String username = sessionUtility.getLoggedUser(); try { visibility = um.getVisibilityOverEvent(eventID); sessionUtility.setParameter(eventID); SYSO_Testing.syso("FilterEvent. Username " + username); SYSO_Testing.syso("FilterEvent. I'm logged, and I've to check the visibility"); if (visibility == CREATOR) { FacesContext fc = FacesContext.getCurrentInstance(); sessionUtility.setParameter(eventID); fc.getApplication().getNavigationHandler().handleNavigation(fc, null, creatorOutcome); return; } else { if (visibility == VIEWER && !ef.find(eventID).isPrivateEvent()) { FacesContext fc = FacesContext.getCurrentInstance(); sessionUtility.setParameter(eventID); fc.getApplication().getNavigationHandler().handleNavigation(fc, null, viewerOutcome); return; } } } catch (NotFoundException ex) { FacesContext fc = FacesContext.getCurrentInstance(); fc.getApplication().getNavigationHandler().handleNavigation(fc, null, errorOutcome); } return; }
public String removerCategoria() { HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest(); try { long idCategoria = Long.parseLong(request.getParameter("idCategoria")); CategoriaDAO categoriaDao = new CategoriaJPADAO(); Categoria categoria = categoriaDao.find(idCategoria); categoriaDao.delete(categoria); } catch (NumberFormatException ex) { ex.printStackTrace(); FacesContext.getCurrentInstance() .addMessage( "Aviso", new FacesMessage(FacesMessage.SEVERITY_WARN, "Categoria inexistente!", "")); } catch (PersistenceException e) { e.printStackTrace(); new CategoriaJPADAO().rollback(); FacesContext.getCurrentInstance() .addMessage( "Aviso", new FacesMessage( FacesMessage.SEVERITY_WARN, "Já existem atividades nesta categoria!", "")); } return "?faces-redirect=true"; }
public void login() { Candidate candidate = getCandidateService().findCandidateByEmailService(email); if (null != candidate) { // is this account created with username and password? if (matchOAuthLoginMethod(candidate, "SIMPLE")) { // does password match? // password is md5+random nonce hashed, this is more secure because of sql injection attact if (null != candidate.getPassword() && candidate.getPassword().equals(UserProfile.MD5(password))) { getJobSearchController().setIsUserLoggedIn(true); getJobSearchController().setLoggedInUser(candidate); // redirect to hidden page try { if (null != redirect) { String copyRedirect = redirect; setRedirect(null); FacesContext.getCurrentInstance().getExternalContext().redirect(copyRedirect); } else { FacesContext.getCurrentInstance().getExternalContext().redirect("index.xhtml"); } } catch (IOException e) { e.printStackTrace(); } } else { // display user not found message LabelController lblController = new LabelController(); FacesContext.getCurrentInstance() .addMessage("atsForm", new FacesMessage(lblController.getUserNamePasswordNotMatch())); } } } }