I have a boolean inside a Checkbox and i want to validate if it is set to True.
So my entitie object looks kind of like this
@Validate("required,min=1")
private int Int1;
In my tml File (im using Tapestry 5.3.8) there is a Textfield which allows me to set a value for Int1
this works perfectly. If i put something else then an numeric number (or an int small 1) it shows me an error dialog.
but i can't figure out how to do that with a boolean. It needs to be checked an the user should get the same behauvior as with Int1 on a false entry.
Think of it like an Agree to the TOS checkbox which allways has to be checked to proceed.
Greetings Ilja
If I'm not mistaken a checkbox works with a boolean. So the following should achieve your result:
@Component(id = "agreeCheckbox")
private Checkbox agreeCheckbox;
@OnEvent(component = "agreeCheckbox", value = EventConstants.VALIDATE)
private void handleAgreeValidate(boolean agree) {
if(!agree) {
throw new ValidationException("Hey there! You have to agree or we can't do business with you.");
}
}
Disclaimer: I have not tested this code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.