Search in sources :

Example 76 with FacesMessage

use of javax.faces.application.FacesMessage in project deltaspike by apache.

the class JsfUtilsTest method testExistingMessageWithoutSummary.

@Test
public void testExistingMessageWithoutSummary() {
    List<FacesMessage> existingFacesMessage = new ArrayList<FacesMessage>();
    existingFacesMessage.add(new FacesMessage(null, "test"));
    FacesMessage messageToCheck = new FacesMessage(null, "test");
    Assert.assertEquals(Boolean.FALSE, JsfUtils.isNewMessage(existingFacesMessage, messageToCheck));
}
Also used : ArrayList(java.util.ArrayList) FacesMessage(javax.faces.application.FacesMessage) Test(org.junit.Test)

Example 77 with FacesMessage

use of javax.faces.application.FacesMessage in project deltaspike by apache.

the class JsfUtilsTest method testNewMessageWithoutSummary.

@Test
public void testNewMessageWithoutSummary() {
    List<FacesMessage> existingFacesMessage = new ArrayList<FacesMessage>();
    existingFacesMessage.add(new FacesMessage("existing", "message"));
    FacesMessage messageToCheck = new FacesMessage(null, "test");
    Assert.assertEquals(Boolean.TRUE, JsfUtils.isNewMessage(existingFacesMessage, messageToCheck));
}
Also used : ArrayList(java.util.ArrayList) FacesMessage(javax.faces.application.FacesMessage) Test(org.junit.Test)

Example 78 with FacesMessage

use of javax.faces.application.FacesMessage in project oxCore by GluuFederation.

the class FacesMessages method add.

public void add(String clientId, Severity severity, String message) {
    if (facesContext == null) {
        return;
    }
    String evaluatedMessage = evalAsString(message);
    String encodedMessage = StringEscapeUtils.escapeHtml4(evaluatedMessage);
    FacesMessage facesMessage = new FacesMessage(severity, encodedMessage, encodedMessage);
    facesContext.addMessage(clientId, facesMessage);
    messages.put(clientId, facesMessage);
    setKeepMessages();
}
Also used : FacesMessage(javax.faces.application.FacesMessage)

Example 79 with FacesMessage

use of javax.faces.application.FacesMessage in project oxCore by GluuFederation.

the class AttributeValidator method validate.

@Override
public void validate(FacesContext context, UIComponent comp, Object value) {
    GluuAttribute attribute = (GluuAttribute) comp.getAttributes().get("attribute");
    if (attribute == null) {
        ((UIInput) comp).setValid(true);
        return;
    }
    AttributeValidation attributeValidation = attribute.getAttributeValidation();
    Integer minvalue = attributeValidation != null ? attributeValidation.getMinLength() : null;
    Integer maxValue = attributeValidation != null ? attributeValidation.getMaxLength() : null;
    String regexpValue = attributeValidation != null ? attributeValidation.getRegexp() : null;
    String attributeValue = (String) value;
    // Minimum length validation
    if (minvalue != null) {
        int min = attributeValidation.getMinLength();
        if ((attributeValue != null) && (attributeValue.length() < min)) {
            ((UIInput) comp).setValid(false);
            FacesMessage message = new FacesMessage(attribute.getDisplayName() + " should be at least " + min + " symbols. ");
            message.setSeverity(FacesMessage.SEVERITY_ERROR);
            context.addMessage(comp.getClientId(context), message);
        }
    }
    // default maxlength
    int max = 400;
    if (maxValue != null) {
        max = attributeValidation.getMaxLength();
    }
    // Maximum Length validation
    if ((attributeValue != null) && (attributeValue.length() > max)) {
        ((UIInput) comp).setValid(false);
        FacesMessage message = new FacesMessage(attribute.getDisplayName() + " should not exceed " + max + " symbols. ");
        message.setSeverity(FacesMessage.SEVERITY_ERROR);
        context.addMessage(comp.getClientId(context), message);
    }
    if ((attribute.getName().equalsIgnoreCase("mail") && ((regexpValue == null) || (StringHelper.isEmpty(regexpValue))))) {
        regexpValue = "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@" + "[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$";
    }
    if ((regexpValue != null) && StringHelper.isNotEmpty(regexpValue)) {
        java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(regexpValue);
        if ((attributeValue != null) && !(attributeValue.trim().equals(""))) {
            java.util.regex.Matcher matcher = pattern.matcher(attributeValue);
            boolean flag = matcher.matches();
            if (!flag) {
                ((UIInput) comp).setValid(false);
                FacesMessage message = new FacesMessage(attribute.getDisplayName() + " Format is invalid. ");
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                context.addMessage(comp.getClientId(context), message);
            }
        }
    }
}
Also used : AttributeValidation(org.gluu.model.attribute.AttributeValidation) UIInput(javax.faces.component.UIInput) FacesMessage(javax.faces.application.FacesMessage) GluuAttribute(org.gluu.model.GluuAttribute)

Example 80 with FacesMessage

use of javax.faces.application.FacesMessage in project Payara by payara.

the class Game method check.

public String check() throws InterruptedException {
    System.out.println("In Game::check");
    sb.hello();
    if (guess > number) {
        biggest = guess - 1;
    }
    if (guess < number) {
        smallest = guess + 1;
    }
    if (guess == number) {
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Correct!"));
    }
    remainingGuesses--;
    return null;
}
Also used : 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