Search in sources :

Example 86 with FacesMessage

use of javax.faces.application.FacesMessage in project quickstart by wildfly.

the class MemberController method register.

public void register() throws Exception {
    try {
        memberRegistration.register(newMember);
        facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Registered!", "Registration successful"));
        initNewMember();
    } catch (Exception e) {
        String errorMessage = getRootErrorMessage(e);
        FacesMessage m = new FacesMessage(FacesMessage.SEVERITY_ERROR, errorMessage, "Registration Unsuccessful");
        facesContext.addMessage(null, m);
    }
}
Also used : FacesMessage(javax.faces.application.FacesMessage)

Example 87 with FacesMessage

use of javax.faces.application.FacesMessage in project quickstart by wildfly.

the class JsonController method parseJsonStream.

public void parseJsonStream() {
    StringBuilder sb = new StringBuilder();
    String json = getJsonString();
    try {
        JsonParser parser = Json.createParser(new StringReader(json));
        while (parser.hasNext()) {
            Event event = parser.next();
            if (event.equals(Event.KEY_NAME)) {
                sb.append(" - - - -  >  Key: " + parser.getString() + "  < - - - - - \n");
            }
            if (event.equals(Event.VALUE_STRING)) {
                sb.append("Value as String: " + parser.getString() + "\n");
            }
            if (event.equals(Event.VALUE_NUMBER)) {
                sb.append("Value as Number: " + parser.getInt() + "\n");
            }
            if (event.equals(Event.VALUE_TRUE)) {
                sb.append("Value as Boolean: true\n");
            }
            if (event.equals(Event.VALUE_FALSE)) {
                sb.append("Value as Boolean: false \n");
            }
        }
    } catch (JsonException e) {
        FacesContext.getCurrentInstance().addMessage("form:parsed", new FacesMessage(e.getMessage()));
    }
    parsedResult = sb.toString();
}
Also used : JsonException(javax.json.JsonException) StringReader(java.io.StringReader) Event(javax.json.stream.JsonParser.Event) FacesMessage(javax.faces.application.FacesMessage) JsonParser(javax.json.stream.JsonParser)

Example 88 with FacesMessage

use of javax.faces.application.FacesMessage in project opentheso by miledrousset.

the class ExternalResources method addExternalImage.

public void addExternalImage(String idTheso, String idConcept, int idUser) {
    String copyRight = "";
    if (inputUri == null || inputUri.isEmpty()) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("sTerme.error5")));
        return;
    }
    ExternalImagesHelper imagesHelper = new ExternalImagesHelper();
    if (inputLable == null || inputLable.isEmpty()) {
        inputLable = idConcept;
    }
    if (!imagesHelper.addExternalImage(connect.getPoolConnexion(), idConcept, idTheso, inputLable, copyRight, inputUri, idUser)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error-BDD")));
        return;
    }
    loadImages(idTheso, idConcept);
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", langueBean.getMsg("externalResources.addedImage")));
}
Also used : FacesMessage(javax.faces.application.FacesMessage) ExternalImagesHelper(mom.trd.opentheso.bdd.helper.ExternalImagesHelper)

Example 89 with FacesMessage

use of javax.faces.application.FacesMessage in project opentheso by miledrousset.

the class ExternalResources method deleteExternalImage.

public void deleteExternalImage(String idTheso, String idConcept, String imageUri) {
    ExternalImagesHelper imagesHelper = new ExternalImagesHelper();
    if (!imagesHelper.deleteExternalImage(connect.getPoolConnexion(), idConcept, idTheso, imageUri)) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("Error-BDD")));
        return;
    }
    loadImages(idTheso, idConcept);
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", langueBean.getMsg("externalResources.deleteImage")));
}
Also used : FacesMessage(javax.faces.application.FacesMessage) ExternalImagesHelper(mom.trd.opentheso.bdd.helper.ExternalImagesHelper)

Example 90 with FacesMessage

use of javax.faces.application.FacesMessage in project opentheso by miledrousset.

the class FileBean_progress method readSkos2.

/**
 * Cette fonction permet de lire un fichier Skos en utilsant le skosapi et owlapi (officiel)
 *
 * @param event
 */
public void readSkos2(FileUploadEvent event) {
    importSkosHelper = null;
    if (!PhaseId.INVOKE_APPLICATION.equals(event.getPhaseId())) {
        event.setPhaseId(PhaseId.INVOKE_APPLICATION);
        event.queue();
    } else {
        UploadedFile file = event.getFile();
        if (formatDate == null || formatDate.equals("")) {
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", langueBean.getMsg("file.error2")));
        } else {
            try {
                boolean useArk = false;
                ResourceBundle bundlePref = getBundlePref();
                if (bundlePref.getString("useArk").equalsIgnoreCase("true")) {
                    useArk = true;
                }
                String adressSite = bundlePref.getString("cheminSite");
                // lecture du fichier SKOS
                importSkosHelper = new ImportSkosHelper();
                importSkosHelper.setInfos(connect.getPoolConnexion(), formatDate, useArk, adressSite, selectedTerme.getUser().getUser().getIdUser(), langueSource);
                if (!importSkosHelper.readFile(file.getInputstream(), file.getFileName())) {
                    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", importSkosHelper.getMessage()));
                    return;
                }
                FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, langueBean.getMsg("info") + " :", importSkosHelper.getMessage()));
                desabled = false;
            }// }
             catch (IOException | OWLOntologyCreationException | SKOSCreationException ex) {
                Logger.getLogger(FileBean.class.getName()).log(Level.SEVERE, null, ex);
                FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, langueBean.getMsg("error") + " :", ex.getMessage()));
            }
        }
    }
}
Also used : UploadedFile(org.primefaces.model.UploadedFile) OWLOntologyCreationException(org.semanticweb.owlapi.model.OWLOntologyCreationException) ResourceBundle(java.util.ResourceBundle) IOException(java.io.IOException) FacesMessage(javax.faces.application.FacesMessage) ImportSkosHelper(mom.trd.opentheso.core.imports.helper.ImportSkosHelper) SKOSCreationException(org.semanticweb.skos.SKOSCreationException)

Aggregations

FacesMessage (javax.faces.application.FacesMessage)370 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)43 SQLException (java.sql.SQLException)40 Connection (java.sql.Connection)34 FacesContext (javax.faces.context.FacesContext)25 ArrayList (java.util.ArrayList)24 UIInput (javax.faces.component.UIInput)24 ValidatorException (javax.faces.validator.ValidatorException)24 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)22 NodeAutoCompletion (mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)22 CandidateHelper (mom.trd.opentheso.bdd.helper.CandidateHelper)19 UserHelper2 (mom.trd.opentheso.bdd.helper.UserHelper2)19 IOException (java.io.IOException)16 NoteHelper (mom.trd.opentheso.bdd.helper.NoteHelper)15 Test (org.junit.Test)13 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)12 Term (mom.trd.opentheso.bdd.datas.Term)11 UploadedFile (org.primefaces.model.UploadedFile)11 HikariDataSource (com.zaxxer.hikari.HikariDataSource)10 Date (java.util.Date)10