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
Page
<form t:type="form" t:id="departmentMasterList">
<t:errors />
@Component
private Form departmentMasterList;Java
1 2 3 4 5 6 7 8 9 10 | void onValidateFromDepartmentMasterList() { Iterator<DepartmentMasterListVO> iter = deptMasterList.iterator(); while (iter.hasNext()) { DepartmentMasterListVO departmentListVO = iter.next(); if (!departmentListVO.getCategory().equals("Test")) { departmentMasterList.recordError("Category entered is wrong"); break; } } } |
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
No comments:
Post a Comment