Tuesday, October 29, 2013

ADF: Mandatory SelectOneChoice component is not firing client side validation.

Let say we have a form which is used to create/edit data and in this form we have one input-text component and one SelectOneChoice component. If both of these fields are mandatory there are times when we see client side validation is happening for input-text but not for select-one-choice.

Take example of this picture


 If we wee LastName and Email validation are happening client side and we get proper error message as 'You must enter a value' but DepartmentId validation is happening in model side, which is causing error message as 'Attribute DepartmentId in HRAppModule.EmployeeVO is required'.

Generally this issue occurs when we include a 'No Selection' item for a mandatory attribute while creating LOV.

If we 'Include 'No Selection' Item: client pushes "" value from UI which is not null so client side validation does not happen.
If we don't include 'No Selection' Item: client shows blank initially which is null and once user hit submit, it performs client side validation on it. The moment user selects a value, he would not be able to select blank again as attribute is mandatory. Yes, he can change value but no more blank value selection. Which is good way of forcing him to select something.

Disclaimer: Any views or opinions presented in this blog are solely those of the author and do not necessarily represent those of the company.


kkapani said...

Thanks a lot Sanjeev. This helped me. :)

Sanjeev Chauhan said...

welcome kkapani.