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);
}
}
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();
}
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")));
}
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")));
}
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()));
}
}
}
}
Aggregations