use of javax.faces.component.UIInput in project oxTrust by GluuFederation.
the class UpdatePersonAction method validateConfirmPassword.
public void validateConfirmPassword(FacesContext context, UIComponent comp, Object value) {
if (comp.getClientId().endsWith("custpasswordId")) {
this.password = (String) value;
} else if (comp.getClientId().endsWith("custconfirmpasswordId")) {
this.confirmPassword = (String) value;
}
if (!StringHelper.equalsIgnoreCase(password, confirmPassword)) {
((UIInput) comp).setValid(false);
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Password and Confirm Password should be same!", "Password and Confirm Password should be same!");
context.addMessage(comp.getClientId(context), message);
}
}
use of javax.faces.component.UIInput in project wildfly by wildfly.
the class Game method validateNumberRange.
public void validateNumberRange(FacesContext context, UIComponent toValidate, Object value) {
if (remainingGuesses <= 0) {
FacesMessage message = new FacesMessage("No guesses left!");
context.addMessage(toValidate.getClientId(context), message);
((UIInput) toValidate).setValid(false);
return;
}
int input = (Integer) value;
if (input < smallest || input > biggest) {
((UIInput) toValidate).setValid(false);
FacesMessage message = new FacesMessage("Invalid guess");
context.addMessage(toValidate.getClientId(context), message);
}
}
use of javax.faces.component.UIInput in project oxCore by GluuFederation.
the class GluuAttribute method validateAttribute.
public void validateAttribute(FacesContext context, UIComponent comp, Object value) {
Integer minvalue = this.attributeValidation != null ? this.attributeValidation.getMinLength() : null;
Integer maxValue = this.attributeValidation != null ? this.attributeValidation.getMaxLength() : null;
String regexpValue = this.attributeValidation != null ? this.attributeValidation.getRegexp() : null;
String attribute = (String) value;
// Minimum length validation
if (minvalue != null) {
int min = this.attributeValidation.getMinLength();
if ((attribute != null) && (attribute.length() < min)) {
((UIInput) comp).setValid(false);
FacesMessage message = new FacesMessage(this.displayName + " 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 = this.attributeValidation.getMaxLength();
}
// Maximum Length validation
if ((attribute != null) && (attribute.length() > max)) {
((UIInput) comp).setValid(false);
FacesMessage message = new FacesMessage(this.displayName + " should not exceed " + max + " symbols. ");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
context.addMessage(comp.getClientId(context), message);
}
if ((this.name.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 ((attribute != null) && !(attribute.trim().equals(""))) {
java.util.regex.Matcher matcher = pattern.matcher(attribute);
boolean flag = matcher.matches();
if (!flag) {
((UIInput) comp).setValid(false);
FacesMessage message = new FacesMessage(this.displayName + " Format is invalid. ");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
context.addMessage(comp.getClientId(context), message);
}
}
}
}
use of javax.faces.component.UIInput in project oxTrust by GluuFederation.
the class FacesComponentUtility method resetInputComponents.
private static void resetInputComponents(UIComponent rootUIComponent) {
if ((rootUIComponent == null) || (rootUIComponent.getChildCount() == 0)) {
return;
}
for (UIComponent comp : rootUIComponent.getChildren()) {
if (comp instanceof UIInput) {
UIInput uiInput = (UIInput) comp;
uiInput.setSubmittedValue(null);
uiInput.setValid(true);
uiInput.setLocalValueSet(false);
uiInput.resetValue();
}
resetInputComponents(comp);
}
}
use of javax.faces.component.UIInput in project oxTrust by GluuFederation.
the class ConfigureCacheRefreshAction method validateProperty.
public void validateProperty(FacesContext context, UIComponent comp, Object value) {
System.out.println("inside validate method");
String newkeyAttr = (String) value;
int size = keyAttributes.size();
for (SimpleProperty keyAttribute : keyAttributes) {
int i = 0;
if (newkeyAttr.equalsIgnoreCase(keyAttribute.getValue())) {
i = i + 1;
if (i == 2) {
((UIInput) comp).setValid(false);
FacesMessage message = new FacesMessage("key attribute already Exist! ");
//message.setSeverity(Severity.ERROR);
context.addMessage(comp.getClientId(context), message);
}
}
}
}
Aggregations