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