i'm writing a custom validator to check the url entered by the user :
package tn.talan.testFramework.validators;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
import org.apache.commons.validator.UrlValidator;
public class URLCustomValidator implements Validator{
public void validate(FacesContext context, UIComponent component,Object value) throws ValidatorException {
String enteredURL = (String) value;
String[] schemes = {"http","https"};
System.out.println(enteredURL);
FacesMessage message = null ;
String messageStr = null ;
UrlValidator urlValidator = new UrlValidator(schemes);
if (!urlValidator.isValid(enteredURL)) {
System.out.println("url is invalid valid");
message = new FacesMessage();
messageStr = (String)component.getAttributes().get("message");
if (messageStr == null) {
messageStr = "Inavalid URL";
}
message.setDetail(messageStr);
message.setSummary(messageStr);
message.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ValidatorException(message);
}
}
}
I get this warning and i want to solve it :
The type UrlValidator is deprecated
Thank u in advance
UrlValidator from package org.apache.commons.validator.UrlValidator is deprecated, please use UrlValidator from this Routines package:
According to JavaDoc:
Use the new UrlValidator in the routines package. This class will be removed in a future release.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With