Search in sources :

Example 11 with ValidatorException

use of javax.faces.validator.ValidatorException in project acs-community-packaging by Alfresco.

the class CreateUserWizard method validatePassword.

// ------------------------------------------------------------------------------
// Validator methods
/**
 * Validate password field data is acceptable
 *
 * @deprecated Method is never used
 */
public void validatePassword(FacesContext context, UIComponent component, Object value) throws ValidatorException {
    int minPasswordLength = Application.getClientConfig(context).getMinPasswordLength();
    int maxPasswordLength = Application.getClientConfig(context).getMaxPasswordLength();
    String pass = (String) value;
    if (pass.length() < minPasswordLength || pass.length() > maxPasswordLength) {
        String err = MessageFormat.format(Application.getMessage(context, LoginBean.MSG_PASSWORD_LENGTH), new Object[] { minPasswordLength, maxPasswordLength });
        throw new ValidatorException(new FacesMessage(err));
    }
}
Also used : ValidatorException(javax.faces.validator.ValidatorException) FacesMessage(javax.faces.application.FacesMessage)

Example 12 with ValidatorException

use of javax.faces.validator.ValidatorException in project acs-community-packaging by Alfresco.

the class CreateGroupDialog method validateGroupName.

// ------------------------------------------------------------------------------
// Helpers
public void validateGroupName(FacesContext context, UIComponent component, Object value) throws ValidatorException {
    int minGroupNameLength = Application.getClientConfig(context).getMinGroupNameLength();
    String name = ((String) value).trim();
    if (name.length() < minGroupNameLength || name.length() > 100) {
        String err = MessageFormat.format(Application.getMessage(context, MSG_GROUPNAME_LENGTH), new Object[] { minGroupNameLength, 100 });
        throw new ValidatorException(new FacesMessage(err));
    }
    if (name.indexOf('"') != -1 || name.indexOf('\\') != -1) {
        String err = MessageFormat.format(Application.getMessage(context, MSG_ERR_NAME), new Object[] { "\", \\" });
        throw new ValidatorException(new FacesMessage(err));
    }
}
Also used : ValidatorException(javax.faces.validator.ValidatorException) FacesMessage(javax.faces.application.FacesMessage)

Example 13 with ValidatorException

use of javax.faces.validator.ValidatorException in project dataverse by IQSS.

the class LoginPage method validateUserSum.

// TODO: Consolidate with SendFeedbackDialog.validateUserSum?
public void validateUserSum(FacesContext context, UIComponent component, Object value) throws ValidatorException {
    // The FacesMessage text is on the xhtml side.
    FacesMessage msg = new FacesMessage("");
    ValidatorException validatorException = new ValidatorException(msg);
    if (value == null) {
        throw validatorException;
    }
    if (op1 + op2 != (Long) value) {
        throw validatorException;
    }
}
Also used : ValidatorException(javax.faces.validator.ValidatorException) FacesMessage(javax.faces.application.FacesMessage)

Example 14 with ValidatorException

use of javax.faces.validator.ValidatorException in project dataverse by IQSS.

the class LinkValidator method validate.

@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
    UIInput taglineInput = (UIInput) component.getAttributes().get("taglineInput");
    UIInput linkUrlInput = (UIInput) component.getAttributes().get("linkUrlInput");
    String taglineStr = (String) taglineInput.getSubmittedValue();
    String urlStr = (String) linkUrlInput.getSubmittedValue();
    FacesMessage msg = null;
    if (taglineStr.isEmpty() && !urlStr.isEmpty()) {
        msg = new FacesMessage("Please enter a tagline for the website to be hyperlinked with.");
        msg.setSeverity(FacesMessage.SEVERITY_ERROR);
        FacesContext.getCurrentInstance().addMessage(taglineInput.getClientId(), msg);
    }
    if (msg != null) {
        throw new ValidatorException(msg);
    }
}
Also used : ValidatorException(javax.faces.validator.ValidatorException) UIInput(javax.faces.component.UIInput) FacesMessage(javax.faces.application.FacesMessage)

Example 15 with ValidatorException

use of javax.faces.validator.ValidatorException in project dataverse by IQSS.

the class ThemeWidgetFragment method validateTagline.

public void validateTagline(FacesContext context, UIComponent component, Object value) throws ValidatorException {
    if (!StringUtils.isEmpty((String) value) && ((String) value).length() > 140) {
        FacesMessage msg = new FacesMessage("Tagline must be at most 140 characters.");
        msg.setSeverity(FacesMessage.SEVERITY_ERROR);
        throw new ValidatorException(msg);
    }
}
Also used : ValidatorException(javax.faces.validator.ValidatorException) FacesMessage(javax.faces.application.FacesMessage)

Aggregations

FacesMessage (javax.faces.application.FacesMessage)24 ValidatorException (javax.faces.validator.ValidatorException)24 UIInput (javax.faces.component.UIInput)5 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 AttributeValidation (org.gluu.model.attribute.AttributeValidation)2 Period (com.artezio.arttime.datamodel.Period)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 UIComponent (javax.faces.component.UIComponent)1 FacesContext (javax.faces.context.FacesContext)1 Validator (javax.faces.validator.Validator)1 Part (javax.servlet.http.Part)1 ConstraintViolation (javax.validation.ConstraintViolation)1 TenantDomainMismatchException (org.alfresco.repo.tenant.TenantDomainMismatchException)1 GluuAttribute (org.gluu.model.GluuAttribute)1 AttributeDataType (org.gluu.model.attribute.AttributeDataType)1 AttributeService (org.gluu.oxtrust.service.AttributeService)1