Search in sources :

Example 96 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 97 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 98 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)

Example 99 with FacesMessage

use of javax.faces.application.FacesMessage in project fit3d by fkaiserbio.

the class LoginView method submit.

public void submit() throws IOException {
    System.out.println(username + ":" + password);
    FacesContext context = FacesContext.getCurrentInstance();
    ExternalContext externalContext = context.getExternalContext();
    HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
    try {
        request.login(username, password);
        logger.info("authenticated {}", request.getUserPrincipal());
        externalContext.redirect(requestedUri);
    } catch (ServletException e) {
        context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Bad login", null));
        logger.warn("failed login attempt {}:{}", username, password);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletException(javax.servlet.ServletException) FacesContext(javax.faces.context.FacesContext) ExternalContext(javax.faces.context.ExternalContext) FacesMessage(javax.faces.application.FacesMessage)

Example 100 with FacesMessage

use of javax.faces.application.FacesMessage in project fit3d by fkaiserbio.

the class SubmitJobView method analyzeTargetList.

private void analyzeTargetList() throws IOException {
    // check if target list contains exclusively PDB-IDs
    List<String> pdbIdentifiers = Files.lines(targetListPath).filter(Pattern.compile("^" + PDBIdentifier.PATTERN.pattern() + "$").asPredicate()).distinct().collect(Collectors.toList());
    List<String> chainIdentifiers = Files.lines(targetListPath).filter(Pattern.compile("^" + PDBIdentifier.PATTERN.pattern() + "\\s[0-9A-Za-z]+$").asPredicate()).distinct().collect(Collectors.toList());
    if (!pdbIdentifiers.isEmpty() && !chainIdentifiers.isEmpty()) {
        if (!blocked) {
            blocked = true;
            RequestContext.getCurrentInstance().update("mainForm:submitButton");
        }
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Your target list is a mix of PDB-IDs and chain-IDs.");
        FacesContext.getCurrentInstance().addMessage(null, message);
    } else {
        if (!pdbIdentifiers.isEmpty()) {
            targetListSize = pdbIdentifiers.size();
            chainTargetList = false;
            pdbTargetList = true;
            if (blocked) {
                blocked = false;
                RequestContext.getCurrentInstance().update("mainForm:submitButton");
            }
            targetListPath = jobPath.resolve("targets.txt");
            Files.write(jobPath.resolve("targets.txt"), pdbIdentifiers.stream().collect(Collectors.joining("\n")).getBytes());
            logger.info("copied PDB-ID target list to {}", targetListPath);
        } else if (!chainIdentifiers.isEmpty()) {
            targetListSize = chainIdentifiers.size();
            pdbTargetList = false;
            chainTargetList = true;
            if (blocked) {
                blocked = false;
                RequestContext.getCurrentInstance().update("mainForm:submitButton");
            }
            targetListPath = jobPath.resolve("targets.txt");
            Files.write(targetListPath, chainIdentifiers.stream().collect(Collectors.joining("\n")).getBytes());
            logger.info("copied chain-ID target list to {}", targetListPath);
        } else {
            if (!blocked) {
                blocked = true;
                RequestContext.getCurrentInstance().update("mainForm:submitButton");
            }
            FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error", "Your target list does not contain valid PDB-IDs.");
            FacesContext.getCurrentInstance().addMessage(null, message);
        }
    }
}
Also used : FacesMessage(javax.faces.application.FacesMessage)

Aggregations

FacesMessage (javax.faces.application.FacesMessage)288 SQLException (java.sql.SQLException)29 ArrayList (java.util.ArrayList)28 FacesContext (javax.faces.context.FacesContext)25 UIInput (javax.faces.component.UIInput)24 ConceptHelper (mom.trd.opentheso.bdd.helper.ConceptHelper)23 ValidatorException (javax.faces.validator.ValidatorException)22 Connection (java.sql.Connection)21 NodeAutoCompletion (mom.trd.opentheso.bdd.helper.nodes.NodeAutoCompletion)17 IOException (java.io.IOException)13 GroupHelper (mom.trd.opentheso.bdd.helper.GroupHelper)13 Test (org.junit.Test)13 UploadedFile (org.primefaces.model.UploadedFile)11 Date (java.util.Date)10 CandidateHelper (mom.trd.opentheso.bdd.helper.CandidateHelper)10 UserHelper (mom.trd.opentheso.bdd.helper.UserHelper)10 Term (mom.trd.opentheso.bdd.datas.Term)9 TermHelper (mom.trd.opentheso.bdd.helper.TermHelper)9 CommandException (edu.harvard.iq.dataverse.engine.command.exception.CommandException)8 InputStream (java.io.InputStream)8