ValidationDelegate delegate = (ValidationDelegate)getBeans().getBean("delegate");
to validate and show the error. In Tapestry5 it is obsolete. In Tapestry5 we need to create as shown below
<form t:type="form" t:id="departmentMasterList"><t:errors />
@Componentprivate Form departmentMasterList;
In Method onValidateFromDepartmentMasterList DepartmentMasterList is the form Name given in Page.
In the above example I am iterating through a list and checking whether category contains a specific value. This is just for testing only. So now when you press the button, it will go to the above method (OnValidateFrom) if the validation fails, it will display the given message in the location where we have given <t:errors />. If there is any error, the program will not call the OnSuccess