Apache Wicket Interview Questions and Answers
Question: How to create custom validator in apache-wicket?Answer:See summary steps to create a custom validator : 1. Implements IValidator. import org.apache.wicket.validation.IValidator; public class StrongPasswordValidator implements IValidator<String>{ ... } 2. Override validate(IValidatable validatable). public class StrongPasswordValidator implements IValidator<String>{ ... @Override public void validate(IValidatable<String> validatable) { //get input from attached component final String field = validatable.getValue(); } } 3. Attached custom validator to form component. public class CustomValidatorPage extends WebPage { public CustomValidatorPage(final PageParameters parameters) { final PasswordTextField password = new PasswordTextField("password",Model.of("")); //attached custom validator to password field password.add(new StrongPasswordValidator()); //... } } |
Is it helpful?
Yes
No
Most helpful rated by users:
- What is Wicket Framework?
- What are Wicket Models?
- What is Base class for HTML pages?
- What are the Ways to create a page in wicket?
- How to integrate apache-wicket with Spring?