Search in sources :

Example 36 with FacesMessage

use of javax.faces.application.FacesMessage in project rubia-forums by flashboss.

the class JSFUtil method setErrorMessage.

/**
 * @param id
 *            the id of the error message to create
 * @param msg
 *            the text of the error message to create
 */
public static void setErrorMessage(String id, String msg) {
    FacesMessage message = new // severity
    FacesMessage(// severity
    FacesMessage.SEVERITY_ERROR, // summary
    msg, // detail
    msg);
    getCurrentInstance().addMessage(id, message);
}
Also used : FacesMessage(javax.faces.application.FacesMessage)

Example 37 with FacesMessage

use of javax.faces.application.FacesMessage in project rubia-forums by flashboss.

the class JSFUtil method getMessage.

/**
 * @param id
 *            the id of the message to find
 *
 * @return the text of the message
 */
public static String getMessage(String id) {
    String msg = null;
    Iterator<FacesMessage> msgs = getCurrentInstance().getMessages(id);
    if (msgs != null) {
        if (msgs.hasNext()) {
            FacesMessage message = msgs.next();
            msg = message.getDetail();
        }
    }
    return msg;
}
Also used : FacesMessage(javax.faces.application.FacesMessage)

Example 38 with FacesMessage

use of javax.faces.application.FacesMessage in project rubia-forums by flashboss.

the class JSFUtil method handleException.

/**
 * @author sshah
 *
 * @param e
 *            the exception to handle
 *
 * @return the navigation state of the application
 */
public static String handleException(Exception e) {
    String genericNavState = ERROR;
    String msg = e.toString();
    FacesMessage message = new // severity
    FacesMessage(// severity
    FacesMessage.SEVERITY_ERROR, // summary
    msg, // detail
    msg);
    getCurrentInstance().addMessage(ERROR, message);
    return genericNavState;
}
Also used : FacesMessage(javax.faces.application.FacesMessage)

Example 39 with FacesMessage

use of javax.faces.application.FacesMessage in project tutorials by eugenp.

the class MemberController method register.

public void register() throws Exception {
    try {
        memberRegistration.register(newMember);
        FacesMessage m = new FacesMessage(FacesMessage.SEVERITY_INFO, "Registered!", "Registration successful");
        facesContext.addMessage(null, m);
        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 40 with FacesMessage

use of javax.faces.application.FacesMessage in project core by weld.

the class CommentBoard method post.

public Boolean post() {
    if (comment == null || blog == null) {
        return null;
    }
    BlogEntry entry = repository.getEntry(blog.getEntryId());
    if (entry == null) {
        return null;
    }
    comment.checkAuthor();
    repository.addComment(comment, entry);
    FacesContext ctx = FacesContext.getCurrentInstance();
    ctx.addMessage(null, new FacesMessage("Thanks for leaving a comment!"));
    // FIXME doesn't seem to be working; must investigate
    ctx.getExternalContext().getFlash().setKeepMessages(true);
    return true;
}
Also used : FacesContext(javax.faces.context.FacesContext) FacesMessage(javax.faces.application.FacesMessage)

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