Reputation: 11
I want to ask about bypass validation in tapestry 5
In my form i have some field that have validation required. and i have two submit button. one if i click do some validation for save object. and the other must not validation the form or bypass the validation for add to detail object by Ajax (using zone)
Thank's B4
Upvotes: 1
Views: 2008
Reputation: 3893
Though I don't use client validation by setting the t:clientvalidation="false"
on the t:form
, I believe you can bypass it with a cancel button next to your submit button as follows:
<input t:type="submit" t:mode="cancel" value="Cancel" t:id="cancel" />
<input t:type="submit" value="Submit" t:id="submit" />
Have a look at the component reference for submit. There it states "SubmitMode#CANCEL indicates the client-side validation should be omitted (though server-side validation still occurs)." So you will still need to stop the server side validation. You can do this with:
private boolean cancelCalled;
void onSelectedFromSubmit() {
cancelCalled = false;
}
void onSelectedFromCancel() {
cancelCalled = true;
}
@OnEvent(component = "theIdOfYourForm", value = EventConstants.VALIDATE)
private void validateForm() {
if(cancelCalled) {
newContactForm.clearErrors();
}
}
Upvotes: 2
Reputation: 4000
Trying disabling the input field using javascript on the client side. It works for me. And as joostschouten said, you still need to bypass your server-side validation.
Upvotes: 0